Once I joined a team that was handed over by a bunch of paired crap from outsourcing. Initial project - Java-based multimedia content manager, Struts, Hibernate | Oracle - was well structured (it seems that this is the work of several people, programming for a couple, the reasonable use of design patterns, some unit tests). Then someone else inherited the project and endlessly copied the nested functions, loosened the business rules, fixed it, forked it until it became a huge spaghetti monster with a thin processed part of such codes as:
List<Stuff> stuff = null; if (LOG.isDebugEnabled()) { stuff = findStuff(); LOG.debug("Yeah, I'm a smart guy!"); for (Stuff stu : stuff) { LOG.debug("I've got this stuff: " + stu); } } methodThatUsesStuff(stuff);
hidden among other brilliant ingenuity.
I tamed the beast through patient refactoring (extraction methods and classes more time), commenting on the code from time to time, reorganizing everything until the code base decreases by 30%, over time it becomes more and more manageable.
source share