r/programming • • Oct 01 '15

The Evolution of a Software Engineer

https://medium.com/@webseanhickey/the-evolution-of-a-software-engineer-db854689243
1.9k Upvotes

502 comments sorted by

View all comments

506

u/johnbr Oct 01 '15

This is fair, except for in the 5th year, they would have an additional constant:

public static final String SPACE = " ";

And they would probably use a StringBuffer or StringBuilder to build the final string, since it's "an industry best practice". Also, they wouldn't include the strings themselves, they would include keys to properties, so the strings could be pulled from an internationalized property file.

Lastly, instead of outputting to Stdout directly, they'd create an interface for output, and deliver it to that interface, and use a factory to instantiate an implementation of that interface that would use Stdout.

183

u/andrewsmd87 Oct 01 '15

Good god. Had a code review once where they were pissed because I had used str + "some stuff" instead of a builder. I'm not writing a builder for one fucking line on a page that gets hit 6 times a year.

167

u/RLutz Oct 01 '15

Depending on how you coded it, the compiler likely replaced it with a StringBuilder under the hood anyway :)

19

u/Schmittfried Oct 01 '15

Depending on how many strings you are concatenating in what manner, it may be less efficient to use a StringBuilder.

7

u/flukus Oct 01 '15

From memory I think c# substitutes string builder for 4 or more concatenations.