adam bien's blog

How Many "Util"(-ities) Classes Ship With Java 8? 📎

The Util name is considered evil. So, how many "Util*" classes are shipped with Java 8?

Exactly 8 out of 4240. It is remarkable how well most of the Java classes are named. There are only eight exceptions, but most of them could be easily renamed to emphasize their responsibility:

  1. AttributeSetUtilities: extension of AttributeSet functionality from Java's printing library. This either decorates the AttributeSet or validates that. AttributeSetViews or AttributeSetViewProvider would be a better name.
  2. BasicGraphicsUtils: gathers "BasicGraphics" operations. The suffix "Utils" seems to be superfluous.
  3. JTree.DynamicUtilTreeNode: also here the name "Util" does not contribute any valuable information. The name: "Decorator" would probably be more appropriate.
  4. SwingUtilities: a kitchen sink for Swing functionality. The methods for asynchronous UI updates: invokeLater or invokeAndWait are probably the most popular methods.
  5. SynthGraphicsUtils: a kitchen sink for Swing's skinnable look and feel. "Utils" also seems to be superfluos. Just "SynthGraphics" is shorter.
  6. Util: a kitchen sink of CORBA functionality. Comes with the most "interesting" JavaDoc: "Provides utility methods that can be used by stubs and ties to perform common operations."
  7. UtilDelegate: it delegates to the Util above.
  8. Utilities from Swing. The worst possible name for a class. The JavaDoc says: "A collection of methods to deal with various text related activities." I guess "Text" would be a better name.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.