jeudi 4 juin 2015

Are static utility/helper classes still considered a 'code smell' if you're not unit testing?

When I am extracting code out of a class (for DRY or SRP reasons), I often lean toward putting the code in a 'service' class, and injecting that class as a dependency where it is needed. But this is just out of habit. If I am not unit testing, why not just extract the code into a static utility/helper class?

The reason I ask is because I've often read, and agree, that dependency injection is more favorable than calling static methods on utility/helper classes.

Aucun commentaire:

Enregistrer un commentaire