Monday, May 3, 2010

How (not) to Name Your Class API

Basically something you should NOT do: don't start your own API calls with "set" or "get", just in case.

By default - invisible from developer eyes - iPhone SDK @synthesize creates setters and getters for the selected class instance variables. If part of your API allows changing these values somehow, you might accidentally overwrite a default setter or getter.

Perfectly legal thing, something you migth want to do on purpose. Very difficult to debug, if you did that by mistake.

Instead of setVariable you could use changeVariable.

No comments:

Post a Comment