Re:Alan Kay on the Meaning of “Object-Oriented Programming” ...
by edwinyzh on Monday March 18, 2019 @02:26AM
(#19419061)
I especially agree with "This means that objects can only communicate by calling methods".
I think we can add another thing - the object can also expose readonly properties, which allows external modules easy accessing the object's state but cannot change it.
[ Parent
| on HN ]
Re:Alan Kay on the Meaning of “Object-Oriented Programming” ...
by jakobegger on Monday March 18, 2019 @03:55AM
(#19419350)
Read-only properties would be implemented as methods that return the value of an internal variable. There should be no way to directly access the internal state of an object, even if it is read-only -- because that would prevent you from changing internal details (eg. do you store the property in a float or a double?), breaking the "encapsulation".