When using jmock, you can mock a particular class if you install a class improvisator. I noticed that the class humidifier is in an inherited package, so I really don't want to use it (especially because it is very easy to extract the interface using refactoring tools in my IDE). I also don't like instance variables of specific classes.
Extracting the interface, however, I noticed a pattern appearing in my code base. A lot of time an interface has only one implementing a specific class. I prefer to use the interface wherever possible, but it seems that there really are all these additional files. Also, it’s a little tedious to update the interface and update the implementation every time I want to add a new class to the class.
Is it just the price you pay for the right abstraction, or is there a better approach that I haven't thought about? Should all classes implement an interface, even if the only thing in the interface is getters / setters?
source
share