Why Static is Bad and How to Avoid It - DZone Java
Now you can replace Utility by a mocked instance for tests, you can use a wrapped instance for logging or make it implement an interface and so one. Basically you are back in OO world. Of course you can use your favorite DI-Framework to inject the dependency (just make sure you do it properly), or if you don't mind the compile time dependency you can create an alternative constructor in the Client which uses the default implementation.
Read full article from Why Static is Bad and How to Avoid It - DZone Java
No comments:
Post a Comment