In objective-C it is common to prefix two or three letters to the beginning of a class name or C function, for Example an array class is named NSArray the NS because it was originally developed by Next Step. This avoids namespace collisions. Now if I was to go off and create my own library it's common to prefix my initials to the beginning of new classes I create, for example I might decide in my infinite wisdom that the world need another array class and I might create a brand new array class called a BGArray .
So now I'm working on an open-source project that was originally developed by Prince Witherham The Second (Totally fictitious name) and He's got all the classes in the project prefixed with PW2. I want to expand on the project and add a few classes of my own to the project, How should I name these new objects, Should I:
Prefix the new objects with PW2: This keeps consistence across the project but could create namespace collision for the Prince, if say for example I create a new PW2Foo class and the Prince already has a PW2Foo class in some other project that he is working on.
Prefix the new objects with BG (My initials): This would avoid any namespace collisions but would put my initials on something I didn't really start and it could also add confusion to people using the project in the future.
Ask Prince Witherham the Second what he would prefer: This is probably the most strait forward but I can see it being problematic, if the Prince isn’t as activly maintaining the project anymore because he is vacationing of on his private island where they don't always have an internet connection.
I believe it's common to prefix classes with your own name, but also quite common to prefix with the name of the project. Note that NS is not the only Cocoa prefix: there is CG as well, and CV, and CA, all depending on which framework the class comes from. You get the point.
As such, I believe the best of these options (although option 3 can certainly override it, if the project manager would prefer something else) is option 1: all the classes in the project should have the same prefices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With