Posts

Showing posts from April, 2017

An exercise in refactoring groovy code

Legacy Code 1: public def getDBSectionContent_Deprecated(designSectionId) { 2: def dbSectionObj = databaseQueries.getSectionBySectionId(designSectionId, false) 3: com.vce.scs.section.domain.Section dbSectionObject = sectionContentValidator. 4: convertDBSectionResponseToDomain(dbSectionObj) 5: def dbSectionContentListObject = new CopyOnWriteArrayList<Content>() 6: dbSectionContentListObject.addAll(dbSectionObject.contents) 7: def fieldInfoMap 8: def dbfieldTypeValueListObject 9: def deleteSectionContentObject = new CopyOnWriteArrayList<String>() 10: if (dbSectionContentListObject.size() > 0) { 11: for (def i = 0; i <= dbSectionContentListObject.size() - 1; i++) { 12: log.info dbSectionContentListObject[i].type 13: if (dbSectionContentListObject[i].