Car extends Vehicle kindergarten, or, Replace Jargon With Pedagogy
I feel the need to defend Martin Fowler’s article because it had such a profound effect on me when it was published. Although I had been playing with “objects” and “classes” before, this article finally made me understand what OOP was all about. This is not true for many other articles and yes, I’m looking at you, shitty
Car extends VehicleOOP tutorial.
(Which made me laugh.)
Aristotle is right when he says that the concept of dependency injection should be so ubiquitously understood that it shouldn’t get its own brand name. But at the same time it represents the very essence of object-orientation and most people are not using it.
I can see what he’s talking about. It took me a lot of time to take to OOP at all, and I’m still not particularly passionate. In my hands it is purely a tool, a means to an end – I reach for it either when I have a lot of functions that operate on a particular data structure, or when I need to be able to pass around interchangeable implementations of a set of behaviours. The latter is precisely what Dependency Injection is about. That is indeed the essence of object orientation – in the abstract.
I suppose that my intuitive understanding of this principle puts me in a minority. For me, instead, the defining moment with regard to OOP was when I read Replace Conditional With Polymorphism. That is the essence of object orientation – in the concrete. That article made a lightbulb go off; for the first time I could verbalise what I had so long been doing intuitively, and why. For the first time, I could look at code and figure out a better design objectively, without handwaving.
Maybe it is time for someone to put together a non-shitty introduction to object orientation, based on explaining the idea of Replace Conditional With Polymorphism first, and how to reap the benefit by consistently using the idea of Dependency Injection second. Perhaps novices would spend less time thrashing about then, and we could finally stop inventing pompous names for perfectly trivial concepts.