Dependency Injection Breaks Encapsulation

Tony,

Again, you have no argumentative foot to stand on, when it comes to defining anything as being “appropriate” or “inappropriate”, because you don’t know what they mean in terms of OOP programming. Your 9000 line monster class is the proof. Your defending it only makes you look less and less professional. It is wrong. It is poor programming. It isn’t even outdated or archaic, because no able OOP programmer would program like that to begin with, not even 30 years ago. Not only Tom or I have noted this, there are a few others who have too now. Yet, you still continue to argue you know better? You still argue a 9000 line class is proper and even good?

You know what your framework looks like to me? It looks like you were relatively good at PHP’s procedural programming paradigm with PHP4, then decided to try and make your framework work with PHP5 and OOP, but only with your old procedural knowledge and not really with a proper understanding of OOP. You worked incredibly hard to put your framework together with what you thought was OOP, but instead of properly learning OOP, you just continued to do bad practice, after bad practice. And instead of learning the right way to do OOP and/ or leaving your mind open to that paradigm the whole time, you started to declare everyone else as the “idiots”, because they don’t follow your poor methodologies.

You need to stop, take a step back, and look at your work and be totally honest with yourself. What you’ve done is fantastic, because you worked hard on it and were very determined to make it work, which is something I actually admire. However, the basis is simply wrong. The basis comes from your incorrect perspectives on OOP. Your framework may work. Great. But, the design is NOT good. You simply cannot sit there and go, “My perspective on OOP is right, because it works with my framework.” That is all the argumentation you bring to the table and it simply isn’t enough and why we cannot move forward with this argument/ thread.

DI does not break encapsulation. It indirectly supports it.
9000 line monster classes are a big “no, no” in any terms of OOP.
DI is a great design pattern, used by practically every framework, which aims to be modular and testable in design. It is very appropriate to use, in order to meet those goals.
OOP, at its core, is about being modular in design, which in turn supports reusability of code (and says NO to 9000 line classes!!!) DI supports that core OOP principle. In other words, even a dumb blind idiot monkey programmer would be right in using DI for meeting those goals, which any good framework should try to achieve.

Scott

1 Like