2 ms·
> when my software engineering professor listed the 3 fundamental tenets of OO—inheritance, encapsulation, and polymorphism—and then asked us which one was opti
by mehrdadn 8y ago
> when my software engineering professor listed the 3 fundamental tenets of OO—inheritance, encapsulation, and polymorphism—and then asked us which one was optional.
None of these is a fundamental tenet. See the article linked here [1]. The fundamental tenets are the five "SOLID" [2] principles.
Object-oriented design is not well-taught in general. The impression most people normally have of it is quite different from what it actually is.
P.S. You may also find [3] interesting.
[1] https://news.ycombinator.com/item?id=18250255 https://news.ycombinator.com/item?id=18250255
[2] https://en.wikipedia.org/wiki/SOLID https://en.wikipedia.org/wiki/SOLID
[3] https://news.ycombinator.com/item?id=16468796 https://news.ycombinator.com/item?id=16468796
- weberc2 8y agoThis seems very much like a semantic debate. Either OOP is characterized by inheritance—which is consistent with the notoriously “OOP” languages like Java, C#, and C++<11 and probably the overwhelming majority of intro-to-OOP literature—or you exclude inheritance as a hallmark and make it so general as to be indistinguishable from many other paradigms, many of whom came before it. If the latter, why bother fighting the semantic debate at all? If OOP really is that unremarkable, why advocate for it as a meaningful label instead of advocating for SOLID generally?
- JamesBarney 8y agoI'm not a huge fan of SOLID. It's treated as a pillar of software development, but I feel like some of the advice sounds good or is right but isn't terribly useful(SL), one was so terrible it was rebranded(O), and some are a useful tool more than a design goal(ID). Single responsibility principle - something we can all agree on but doesn't help you decide between two non hideous designs Open/Closed Principle - the original advice was so terrible that we ignore it and pretend it means something else that has very little to do with open/closed Liskov - technically true but very few applications are bad or incorrect because of this violation(especially with the recent move away from inheritance) Interface Segregation - Sure it's useful to split up interfaces sometimes. Dependency Injection - Sometimes useful for testing or IOC.
- harimau777 8y agoCan't the SOLID principles apply equally well to functional programming by just replacing "class" with function, object, or type (depending on the principle)? Single Responsibility is achieved by composition Open/Closed is probably the one that fits least with FP, but it seems like FP achieves the same result by replacing both extension and modification with composition. Liskov Substitution can be replaced by a subtyping or duck typing. Interface Segregation seems like its more about design than programming. However, to the degree that it applies to programming, composition seems like it actually better meets this principle than inheritance. In terms of Dependency Inversion: If anything, it seems like one of the biggest problems with FP is that it makes it easy to take this principle too far by making things too abstract (e.g. the category theory aspects of languages like Haskel seem like they could easily be abused). I'm not super experienced with OO so am I maybe misinterpreting these principles?