I owe Charles Scalfani a great debt of gratitude. Thanks to his article, which has garnered tremendous viewership and 28 thousand upvotes, as well as hundreds of comments, I can use Scalfani as the poster child for someone who failed to properly understand object-oriented programming because they learned OOP not from Smalltalk, but from C++ and C# and Java.
Scalfani thus represents many thousands of OOP developers who are abusing and misusing OOP. The basic issue, I believe, is that they learned OOP from the standpoint of Abstract Data Types. As Alan Kay famously said: Actually I made up the term “object-oriented,” and I can tell you I did not have C++ in mind.
Thank you very much from the bottom of my heart, Charles. You’ve endowed me with a nuclear-tipped cruise missile that I could not otherwise have secured.
Basically, Charles Scalfani doesn’t know what the hell he’s talking about. First of all, there is no banana-gorilla-jungle problem if you know what you’re doing, if you apply OOP concepts in a sensible fashion. For a clear explanation of OOP, read A Simple Explanation of OOP.
Similarly, there is no diamond problem if you avoid multiple inheritance and instead employ things like interfaces (Java) and traits (Pharo).
There’s also no fragile base class problem if you know what you’re doing. It all comes down to how intelligently you design your OOP solution. The Smalltalk system is a great example of OOP done right — it’s very solid and robust.
There is no hierarchy problem. Inheritance should be applied whenever it makes sense. OOP does not require you to use inheritance. You can use composition or aggregation where appropriate. Read Chamond Liu’s excellent book, “Smalltalk, Objects, and Design” (© 2000 iUniverse).
The proper design of OOP solutions requires that you know what you’re doing. This is no different from procedural or functional programming. Can you blindly create programming solutions in all of these paradigms without thought or care?
Can you abuse OOP to create the abovementioned problems? Absolutely. But you can abuse ANY programming tool to arrive at nonsensical code…any programming language, any programming paradigm, any framework.
Scalfani’s reference problem is bullshit. He doesn’t understand encapsulation. There’s nothing wrong with maintaining references to objects. These referenced objects are only ever used to send messages to. That’s the whole foundation of OOP as espoused by Alan Kay! For more info, watch Alan Kay’s video explanation here: Back to the Future with Smalltalk.
I think that Scalfani’s problem with OOP is due to the fact he learned OOP the wrong way. He said he started with C++ which probably warped his mind to begin with. He further reinforced this with C# and Java.
Scalfani claims he learned Smalltalk, too. I’ll bet dollars to donuts he didn’t learn Smalltalk very well. How much time did he spend with Smalltalk? How deeply did he go? Did he really and truly understand Alan Kay’s conception of OOP?
My guess? No.