The "optimal" String concatenation

I've now read quite a few forum topics on the subject and most people seem to argue for one or the other method (the "+" operator, StringBuffer, StringBuilder or whatever). Only a very few posts reflected my opinion: you use the method that makes your code the most robust and easiest to maintain. Then you create a dataset that resembles real-life application and run some tests. If the code runs outside the expected time limits, then you drive it through a profiler, find what makes it crawl and fix it. There's not much purpose in writing the "ultimate" code (ie. spending a lot of time on overall optimization) if only 10% will be used in 90% of the time. And don't take me wrong: there're good coding practises that you should learn and follow. But as with everything else: they are worth only as much as they help you get home earlier. Smiling The point of all coding is to create software that fits the requirements of the customer/user/etc. If you write code that is superior to that in any way, then it's either just a waste of time or it's only good for its "inner beauty". Smiling Of course the latter can be satisfying too for a developer from time to time ... Eye-wink
I pretty much like what Jeff Atwood had to say on the topic in his blog. And I'm most grateful that somebody else took the time to prove me right. Smiling

Syndicate content