The essence of OOP is to encapsulate state / data along with appropriate behavior. The static methods of the utility are akin to global functions in the procedural language - you separate the behavior (static method) from the state (parameters to this method), thereby breaking encapsulation.
What does this mean in practice? Instead of calling reader.read() , you should call ReaderUtils.read(file) , which means that you are now closely connected with the implementation - you made the implicit assumption that you will always use ReaderUtils and always transfer the file.
If you use a common Reader interface, you can use FileReader today, but replace it with DatabaseReader or HttpReader tomorrow without having to change any other code - all reader.read() calls will continue to work the same.
casablanca
source share