Code Smell 18 - Static Functions
Yet another global access coupled with laziness.
Class Single Responsibility Principle is to create instance. Honor it.
Delegate method to instance.
Create stateless objects. Don't call them helpers.
Static class methods
We can enforce a policy to avoid static methods (all class methods but constructors).
Class are globals disguised. Polluting their protocol with "library methods" breaks cohesion and generates coupling. We should extract static with refactorings.
In most languages we cannot manipulate classes and use them polymorphically, so we can't mock them or plug them on tests.
Therefore, we have a global reference too difficult too decouple.
There is no programming problem that can't be solved with one more level of indirection.
This article is part of the CodeSmell Series.