Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I haven't studied OOP extensively in a strict setting, but I would have said that in the OO world, a property is completely separate to a method.

There is absolutely no reason for that, and the grandparent of all things object-oriented (Smalltalk) very strongly disagrees with you: everything is a message, and there are no properties.

> A property defines data about an object, and a method defines something you can 'do' with the object.

A getter method is a property and a method. Properties are irrelevant, access should be uniform, the implementation details of an object (whether a "property" provides direct access to internal data or not) is of no concern to the user of the object.

A property is nothing more than a method whose contract is "give me some data"



That's a fine answer, and some people may find that a helpful way to organize programs.

However, for me, and the CPU, we treat code execution differently to data access.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: