jbreak JBreak 2017 (04.04.2017 — 04.04.2017)

Utility Classes Are Killing Us


Utility Classes are popular and very wrong. They must not exist in object-oriented programming, as well as static methods and global variables.

Utility classes are a very convenient tool for sharing commonly used procedures in Java and many other object-oriented languages. There are Apache Commons, Guava, and JDK by itself who ship that utility classes to us, with sometimes hundreds of procedures in them. The question is whether this design is really object-oriented and how much does it help us keep our code clean. Do we really need these procedures in OOP? And if not, what is the alternative? How can we share code between classes in Java?