2 ms·
Why is that arbitrary? Encapsulation is a core principle of OOP. Re: there being no problem, that depends. Pure OOP has advantages and violating the properties
by naasking 8y ago
Why is that arbitrary? Encapsulation is a core principle of OOP.
Re: there being no problem, that depends. Pure OOP has advantages and violating the properties often sacrifice some of those advantages.
- int_19h 8y ago> Encapsulation is a core principle of OOP. That's exactly the assertion that I'd like substantiated. I don't think there's consensus on this. Sure, it's mentioned in the oft-cited "encapsulation, inheritance, polymorphism, abstraction" mantra - but so is inheritance, and yet prototype-based OO doesn't have it. Personally, I would say that the only core principles of OOP are object identity (i.e. objects are distinguishable aside from their state), and polymorphism via dynamic dispatch. Everything else is optional.
- naasking 8y agoThere's a historical argument: encapsulation was in Cardelli's original object calculi, and part of every OO language of the time. There's also a conceptual argument: dynamic dispatch and object identity both require encapsulation. What do you think you're dispatching or comparing equality on if not hidden state?