Jan 26 2009
util vs utils
Dear open source software community,
Utilities are an important part of programming packages. It is commonly held that a utility class be one with static methods; the association that they may hold may be as simple as the type they operate on.
A utility for manipulating strings may be called StringUtil or StringUtils. There is no consensus on this in the community.
If you hold that each method in the class IS a utility, you would probably assume the class should be named StringUtils. (like apache lucene, apache commons, spring)
If you hold that the class itself is the utility, bound together by its common association. Each method is simply that, a method in the utility that operates on strings, you would probably assume the class should be named StringUtil. (like apache lucene, apache poi or jetty)
Thats right, in lucene they can’t even decide within the same project…
They have packages named util and utils, and utilities name SUBJECTutil and SUBJECTutils.
Kind of like my codebase at work… As soon as you decide.. can you let me know?
- Joshua
Update: At my work developer poll ”util” has it. Three to one with one abstaining.
To further confuse the issue…
In my mind, a utility class is not a StringUtils-style class. It’s a class that is design to be instantiated and performs some utility task. Those utility classes typically live in ‘util’ (or ‘utils’) packages.
StringUtils is a collection of utility methods (i.e., a function library), which is a very different construct. It’s class-nature is predicated by the everything-is-an-class nature of Java and other similar languages.