- Hands-On Dependency Injection in Go
- Corey Scott
- 144字
- 2021-06-10 19:17:44
Code smells that indicate you might need DI
The saying to a man with only a hammer, every problem looks like a nail is old and yet is never truer than in programming. As professionals, we should be continually striving to acquire more tools to be better equipped for whatever our job throws at us. DI, while a highly useful tool, is useful only for particular nails. In our case, these nails are code smells. Code smells are indications in the code of a potentially deeper problem.
There are many different types of code smell; in this section, we will examine only those that can be alleviated by DI. In later chapters, we will reference these smells as we attempt to remove them from our code.
Code smells generally fall into four different categories:
- Code bloat
- Resistance to change
- Wasted effort
- Tight coupling