Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
SnafuAI6846yI would say that the problem is not with the framework but with the people using it. We all know the expression "When you have a hammer all problems start looking like nails. This seems to be the root of your complaint here.
The answer to this issue is not to take away the hammer, but to teach people to look for other more appropriate tools for the job at hand. -
In a way, with DI and IoC containers we're going to do the same crap as we did with inheritance, abusing.
We're ending up with the same situation and same problem we were trying to solve, coupled stuff that over time becomes untouchable.
I personally support messaging approach to its maximum possible extent, pub/sub if you prefer. Every injected stuff, or every class you may inherit from, can be represented as a separate aspect, and more important, is not your freaking business how and if it does whatever it does.
"Go thru a message bus and keep things decoupled" my motto.
Not that the global dependency tree decrease in size, but at least the codebase gets manageable. -
LLAMS36636y@SnafuAI 100% agree.
There is a time and a place for IOC containers and DI frameworks. I just dont think that place is “scattered throughout the business logic of your app”
Related Rants
-
Mindstormer61911Jesus Christ. Dagger2's documentation has got to be the most convoluted shit I have ever laid my eyes on. The...
-
progresshuh19Dependency Injection Frameworks are absolute shit. I have yet to encounter one that doesn't make code take ho...
-
k0pernikus1As I was refactoring a class in a TypeScript project, I changed calls from `this.config` to `this.getConfig()`...
A quick rant about dependency injection.
I see far too often in projects, a huge over-reliance on dependency injection / IOC frameworks which permeate throughout the entire codebase.
I cringe every time I see a constructor annotated with @Inject and 10 params.
The benefit of these frameworks is how easy they make it to manage many dependencies. What I dislike about them, is exactly that. I feel that they make it TOO easy to manage many dependencies.
How trivial is it to simply add another constructor param? exactly. And people then wonder why their dependency tree looks insane.
I am a strong believer in injecting dependencies the traditional way, via the constructor with no fancy framework. The reason being that it forces you to think more about the dependencies you are adding to your classes, and consider if they are really all needed.
The other problem I have with it, is it basically encourages you to inject everything because its so easy. The purpose of dependency injection is inversion of control and allowing classes to depend on abstraction rather than concrete implementation. All that goes out the window when you @Inject 6 different concrete classes.
Use dependency injection for its intended purpose, not as an excuse to be lazy and avoid thinking about dependencies.
rant
dependency injection
inversion of control