DI induced damage results from situations where the use of DI makes the code harder to understand, maintain, or otherwise use.
DI induced damage
A long constructor parameter list
A long constructor parameter list is perhaps the most common and most often complained about code damage caused by DI. While DI is not the root cause of code damage, it certainly doesn't help.Â
Consider the following example, which uses constructor injection:
func NewMyHandler(logger Logger, stats Instrumentation,
parser Parser, formatter Formatter,
limiter RateLimiter,
cache Cache, db Datastore) *MyHandler {
return &MyHandler{
// code removed
}
}
// MyHandler does something fantastic
type MyHandler struct {
// code removed...