Dependency Injection Breaks Encapsulation

Agreed. Though, as a side effect, I am also learning too. For instance, Tony pointed to an article, which also pointed to another article about the “Tell, don’t ask” principle (I’d actually call it a paradigm) of OOP encapsulation. It’s the single most pertinent principle that Tony constantly regurgitates in his argumentation about encapsulation and it sort of actually defends his poor 9000 line monster class, if you happen to read only the first sentence and forget about the rest. Martin succinctly describes the principle he believes in as “co-locating behavior and data”. I knew about that, but never considered it as “Tell, don’t ask” from a simple functional perspective. I know taking that “way of thinking” can actually help me do a better job at OOP programming now. So I am thankful for this “argument” and for those rare gems of learning.

Though, if you do read on in Martin Fowler’s article, he talks about “GetterEradicators”, when people take this principle too far and Martin actually says he doesn’t use (and I understand the word “use” as “propagate” or “teach”) the “Tell, don’t ask” principle himself, because of this.

I think in Tony, we’ve found another person who takes this principle way too far. He isn’t a “GetterEradicator” though. Tony is a “MonsterBuilder” and completely misinterprets both the art of encapsulation in OOP and at the same time ignores or redefines SRP, all in the name of protecting his poor OOP work. And even worse, he loudly and arrogantly tells everyone else, they are wrong too.

The fact he doesn’t want to accept he is basing all his argumentation on misconceptions or twisting of OOP principles only shows he’s missed the OOP bus at one point (actually probably from the beginning) and could use some help “getting it”. (Too bad he doesn’t ask for any). I actually want him on the right bus. But if you ask Tony, we are all on the wrong bus.

Like I said earlier, the PHP world needs passionate developers. We just need passionate devs with an open mind to always improve and not someone telling us, our own efforts to improve and our ways at looking at OOP are wrong, without substantiating those differing opinions with at least partially related facts.

If he’d release his mother hen mentality over his framework and his perspectives and just say, “Ok, I did this many years ago, I was still learning at the time and I do see where I can improve it and my outlooks on OOP too.” Then we can all go home.

Scott

Post edited by @Jasmine to remove inflammatory and inappropriate language. Be nice.

1 Like