Introduction Java decompilers are great tools to give insight about efficiency of compiled code. Currently there are two popular java decompilers: cavaj and jd-gui. Comparison Case It is a well-known fact that concatenation of strings is not an efficient way of building strings using some number of other string obects. Since string objects are immutable, each concatenation creates a new string, this will continue until final string object is created. All created string objects other than the final one, are intermediate objects and nothing but garbage. For this reaseon java compiler converts string concatenations into StringBuilder statements. Using decompilers lets see if this is really true. Below are the original source code and decompiled versions of original code using two decompilers. // original source code logger . debug ( "bulkId:" + bulkId + " is TIME_RULES_VIOLATED..." ); logger . debug ( new StringBuilder ( "bulkId:...
Software Engineering experiences and best practices