When Matthew saw this attempt at a JSON serializer, he had one question: why didn’t you use one of the many libraries we already use in this application?

The answer was, “Because on ‘big data’ procession you should to avoid creation of many objects in the Java!”

private String createItemString(Map<String, String> aKeyValueStore)
{
       StringBuilder item = new StringBuilder();
       String schedNumber = aKeyValueStore.get(Constants.ATTRIBUTE_UP_SCHEDULE_NUMBER);   
       final String date = Utils.convertMicroTmStringToDateString(aKeyValueStore.get(Constants.ATTRIBUTE_UP_TM));
       String userName = aKeyValueStore.get(Constants.ATTRIBUTE_WORKING_USERNAME_12);
       /* SNIP: many more lines where hash keys are extracted into variables */

       item.append(Constants.CURLY_BRACKET_OPEN);   
       item.append(Constants.QUOTE_SIGN);   
       item.append(Constants.SCHEDULE_NUMBER);
       item.append(Constants.QUOTE_SIGN);     
       item.append(Constants.COLON);   
       item.append(schedNumber);   //Editor: Aren't you glad we parsed all those variables out, now?
       item.append(Constants.COMMA);   
       item.append(Constants.QUOTE_SIGN);   
       item.append(Constants.DT);   
       item.append(Constants.QUOTE_SIGN);   
       item.append(Constants.COLON);   
       item.append(date);   
       item.append(Constants.COMMA);   
       item.append(Constants.QUOTE_SIGN);   
       item.append(Constants.ITEM);         
       item.append(Constants.COLON);        
       item.append(Constants.CURLY_BRACKET_OPEN);   
       ...
       /* SNIP: You get the idea */
       ...
       return item.toString();
}

I’m surprised he used StringBuilder- after all, in big data procession, you should to avoid the creation of many objects in the Java, and StringBuilder is definitely an object in the Java.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!