What's your preference with naming ObjC classes? I'm a little uncertain what would be the most reasonable approach on this so it would be nice to hear some other opinions.
Apple recommends prefixing cocoa classes, because ObjC doesn't support namespaces. The Google ObjC styleguide (which i mostly aim for) does away with them, unless you're extending (category, class extension etc.) a NSClass.
My preference would be NOT to prefix classes, because i also think it's a waste of letters and doesn't contribute to a cause. It should only be used in framework code to signal that this class belongs to it and not to your app's classes, but i wouldn't use it on application level.
What's yours, and most importantly WHY?
My Conclusion (please feel free to add your comments to produce the most informed decision)
Application Level Classes:
- I decided to go with 1 Letter Prefixes (like CMyClass). The main reasons are for file organization purposes (e.g. better grouping in Finder), and it still uses less class name letters than prefixes with length 2 or more.
- Use the prefix 'C' for cocoa classes (e.g.
CAudioController.h
) - Use the prefix 'U' for utility collections (plain C, e.g.
USystemAudio.h
)
- Use the prefix 'C' for cocoa classes (e.g.
Framework Level Classes:
- Prefix classes with 2 or more custom letters, preferrably unique, since it will probably be shared with other apps.
Categories
- Categories are named as follows:
NSClassName+ExtensionPurpose