javacode-organization

Code organisation and differentiation between tools and utils packages


About code organisation in packages, i have seen both tools and util used for the same purpose, ie. to contain classes that help with trivial and frequent tasks.

Example:

+ foo.util
|--  StringManipulation.java
|--  MyLogger.java
+ foo.tools
|--  InputSanitization.java
|--  IdentifyOS.java
|--  Whatever.java

From your experience, is there anything that distinguishes tools from utils?
How should such reusable code be organised?

What is the generaly accepted responsibility (historically or semantically) of both and when should I use one over the other when organizing my code.

Conversely, where should I expect to find the more specialized or on the contrary more low level code in those.


Solution

  • Both "tools" and "utils" are bad names for classes/packages. It is not object oriented. It is a way of saying, "I don't know what to name this thing so I'll just give it a generic name".

    What you should do is figure out what these tools/utils are really doing and name them appropriately.