DEV Community

Discussion on: Top 10 Object-Oriented Design Principles for writing Clean Code

Collapse
 
bennyflint profile image
Benjamin Flint • Edited

Good info. However, you are conflating dependency injection and dependency inversion (aka Inversion of Control). They are related, but definitely not the same thing. It would be worth it to clarify, as this is the SOLID principle that, in my experience, is the least followed (perhaps excepting interface segregation).

Collapse
 
melston profile image
Mark Elston

I saw this right away, as well. While other elements of the article are pretty good (or close enough) this one, IMHO, misses the mark entirely. Dependency Injection and Dependency Inversion are only tangentially related. Uncle Bob had a really good explanation of this principle (I think he coined the term).

I agree that this is probably the most overlooked (or misunderstood) principle in the list.

Collapse
 
mindplay profile image
Rasmus Schultz

Dependency injection is not only the last followed principle, it also should be the #1 principle - I've seen the code style and quality of an entire team improve substantially after teaching them DI, IOC and how DI containers work.

So many OO concepts fall into place once you really understand this :-)

Collapse
 
wangvnn profile image
wangvnn • Edited

Alan Kay once said that he did not foresee any things like these with OO. That does not mean DI, IOC are not good. Maybe we just need to call it something else like dependency driven design rather than calling its OO principles. OO is too far from Alan's original idea and land to a place where we deal with classes and their dependencies rather than objects themselves. I am just wondering.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted