Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "string bashing" and why is it bad?

Tags:

java

string

My boss keeps using the term "string bashing" (we're a Java shop) and usually makes an example out of me whenever I ask him anything (as if, I'm supposed to know it already). I Googled the term only to find results pertaining to theoretical physics and string theory.

I am guessing it has something to do with using String/StringBuilders incorrectly or not in keeping with best practices, but for the life of me, I can't figure out what it is.

like image 879
Zac Avatar asked Feb 26 '23 18:02

Zac


2 Answers

"String bashing" is a slang term for cutting up strings and manipulating them: splitting, joining, inserting, tokenizing, parsing, etc..

It's not inherently bad (despite the connotation of "bashing"), but as you point out, in Java, one needs to be careful not to use String when StringBuilder would be more efficient.

like image 113
uncleO Avatar answered Mar 01 '23 10:03

uncleO


Why don't you ask your boss for an example of string bashing. Don't forget to ask him for the correct way of refactoring the examples he gives you.

like image 37
Niels Basjes Avatar answered Mar 01 '23 09:03

Niels Basjes