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

What do you do to avoid this? I try to name my heavy-lifting methods so that they do not look like simple accessors, but sometimes it is inevitable.

For instance, a large dataset may have a method to get the length of the dataset. If the dataset does not maintain a member variable that has that value, then you have to calculate it. Later, for performance, you might implement an ivar that is updated whenever the dataset changes, thus making the method a simple accessor.



If something walks and quacks like a member variable, I'm happy to make it a member variable. Otherwise, it gets to be a function.

(Obviously this doesn't apply in languages like ObjC or C++ where accessors are often necessary for memory management)




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: