DekGenius.com
[ Team LiB ] Previous Section Next Section

1.8 Naming Conventions

Several naming conventions have become widespread within the Objective-C community. To create code that your peers can maintain more easily, try to use the following conventions:

  • Always capitalize class names.

  • Begin variable and method names with lowercase letters. If a variable or method name consists of multiple words, capitalize the first letter of the second and any following words. This practice is known as camelcase.

  • Begin accessor methods that set an instance variable value with the word "set," and make sure the instance variable name follows in camelcase.

  • Give accessor methods that return the value of an instance variable the same name as the variable. It is also acceptable—though uncommon—to prefix the variable name with the word "get" and have the instance variable name follow in camelcase.

  • Do not begin method names that you create with an underscore. By convention, Apple uses underscores to implement system level private functionality.

We've implemented these conventions throughout the book.

    [ Team LiB ] Previous Section Next Section