3 ms·
You can have encapsulation without oop. Polymorphism is the real benefit of oop imho
by gentleman11 3y ago
You can have encapsulation without oop. Polymorphism is the real benefit of oop imho
- gorjusborg 3y ago> Polymorphism is the real benefit of oop imho It's pretty much the definition of OOP. The core feature of OOP is just bundling functions with the state it processes. When you bundle state and functions together, you can't predict what calling the function will do without knowing both the code and state. You can say its 'the real benefit', I guess, but that feels like circular reasoning. Its pretty much the definition of what OOP is, so calling it a benefit feels weird. Unfortunately, designing systems as a collection of distributed state machines tends to become maintenance nightmare. Functions and data being separated tends to make code better, even when working in so-called 'OOP' languages.
- jcelerier 3y ago> You can say its 'the real benefit', I guess, but that feels like circular reasoning. Its pretty much the definition of what OOP is, so calling it a benefit feels weird. It's a benefit compared to how people were writing code before it became mainstream (for polymorphism: by jumping to data-defined parts of the code and hoping for the best, and for encapsulation: subroutines working on global variables).
- tubthumper8 3y agoWhich kind of polymorphism? Subtype polymorphism I'm guessing?