I am tidying up my ancient Cocoa code to use modern naming conventions. There has been lots of discussion on best practices, but I'm unsure of one thing.
I'm thinking about adding a prefix to category method names, to ensure uniqueness. It seem generally agreed that this is a good idea, though most people probably don't bother.
My question is: what about a NSDictionary
category method like -copyDeep
that does a deep copy? The method used to be named -deepCopy
, but I reversed the words as the analyzer looks for a prefix of "copy". Therefore I presumably couldn't add a prefix. And having the "prefix" in the middle or end of the method name seems messy and inconsistent.
I'd also be interested in thoughts on the style of prefix -- I currently use DS
(for Dejal Systems) for class prefixes. But I know that Apple now wants to reserve all two-character prefixes for themselves, so am thinking about using Dejal
, e.g. my class DSManagedObject
would be renamed as DejalManagedObject
. And getting back to categories, their methods would be renamed to add a dejal
prefix, e.g. from -substringFromString:
to -dejalSubstringFromString:
. But -dejalCopyDeep
would confuse the analyzer, so maybe I'd have to be inconsistent for such methods, and use -copyDeepDejal
or -copyDeep_dejal
?
I will be re-releasing my categories and various classes as open source once I've cleaned them up, so following the latest conventions will be beneficial.