3 ms·
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 insta
by delackner 18y ago
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.
- gamble 18y agoIf 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)