Note that there are some explanatory texts on larger screens.

plurals
  1. POKeeping track of utility classes
    primarykey
    data
    text
    <p>I've recently been more and more frustrated with a problem I see emerging in my projects code-base.</p> <p>I'm working on a large scale java project that has >1M lines of code. The interfaces and class structure are designed very well and the engineers writing the code are very proficient. The problem is that in an attempt to make the code cleaner people write Utility classes whenever they need to reuse some functionality, as a result over time and as the project grows more and more utility methods crop up. However, when the next engineer comes across the need for the same functionality he has no way of knowing that someone had already implemented a utility class (or method) somewhere in the code and implements another copy of the functionality in a different class. The result is a lot of code duplication and too many utility classes with overlapping functionality.</p> <p>Are there any tools or any design principles which we as a team can implement in order to prevent the duplication and low visibility of the utility classes?</p> <p><strong>Example:</strong> engineer A has 3 places he needs to transform XML to String so he writes a utility class called <em>XMLUtil</em> and places a static <code>toString(Document)</code> method in it. Engineer B has several places where he serializes Documents into various formats including String, so he writes a utility class called <em>SerializationUtil</em> and has a static method called <code>serialize(Document)</code> which returns a String.</p> <p>Note that this is more than just code-duplication as it is quite possible that the 2 implementations of the above example are different (say one uses transformer API and the other uses Xerces2-J) so this can be seen as a "best-practices" problem as well...</p> <p><strong>Update:</strong> I guess I better describe the current environment we develop in. We use Hudson for CI, Clover for code coverage and Checkstyle for static code analysis. We use agile development including daily talks and (perhaps insufficient) code reviews. We define all our utility classes in a .util which due to it's size now has 13 sub-packages and about 60 classes under the root (.util) class. We also use 3rd party libraries such as most of the apache commons jars and some of the jars that make up Guava.</p> <p>I'm positive that we can reduce the amount of utilities by half if we put someone on the task of refactoring that entire package, I was wondering if there are any tools which can make that operation less costly, and if there are any methodologies which can delay as much as possible the problem from recurring.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload