Holy crap, I'm embarassed to say I actually googled BLOCKED SCRIPT, thinking it was a PHP or Perl thing I hadn't heard of.
Looks like I'm in the right place.
tpierzina
@tpierzina
0
Reputation
3
Posts
44
Profile views
0
Followers
0
Following
Best posts made by tpierzina
This user hasn't posted anything yet.
Latest posts made by tpierzina
-
RE: The Daily MetaWTF
-
Java: String vs. StringBuffer
So what's the conventional wisdom here among Java folks? Not on the
obvious cases, like building a string up in a loop or working with very
large strings that need to be modified, but on the more typical,
non-literal cases?
- This seems to be the prevailing sentiment: http://fishbowl.pastiche.org/2002/09/04/the_stringbuffer_myth
- Similar sentiments in this thread: http://www.caucho.com/support/resin-interest/0106/0576.html
- Good stuff here: http://www.jroller.com/page/sterat
- ...and here: http://www-128.ibm.com/developerworks/java/library/j-jtp04223.html?ca=dgr-lnxw10JavaUrbanLegends
I've always been old-school--any time I concatenate more than 2 strings I would try to use a StringBuffer. But I did some reading last night and it appears that I've been wasting my time, and even making things worse (aside from writing less-readable code).
I did learn/re-learn some things while reading up on this though:
- StringBuffers are synchronized (StringBuilder in 5.0 is not)
- Initial capacity of StringBuffer is key to helping performance. I knew this about ArrayLists, but I'm embarassed to say that I did not apply the idea to my (valid) use of StringBuffers.
- My insistence on using "final" for private variables that are, indeed, final, might actually be useful (at least for Strings), since the compiler can then easily treat them as literals.
Any thoughts to add? [By the way, I've been enjoying this site immensely since a friend sent me the link last week.]
--
Todd