PDA

View Full Version : Conflicting Global Class Names?




Darkroom
Jun 11, 2008, 09:10 PM
i've just read the following:

"To keep the global variables from conflicting with another company's global variables, you have prefixed them with BNR (for Big Nerd Ranch). Global variables from Cocoa are prefixed with NS. These prefixes are important only when you start using classes and frameworks developed by third parties. (NOTE that class names are also global. You might prefer to prefix all your class names with BNR to keep them from conflicting with anyone else's classes)"

i understand it's extremely common for developers to have certain classes often titled the same, namely "AppController". so if two applications are running on one computer, and both applications have classes called "AppController", will they conflict with one another?



lee1210
Jun 11, 2008, 09:43 PM
No. This is only for cases of code reuse through libraries, etc. Conflicts will only occur if the classes are defined in the same namespace in one program.

If I wrote a great graphing library, but called my classes MyClass, MyController, AppController, etc. there's a high probability when someone tried to use it in their program, they'd have issues using my library with some classes they already have. If I called a class NSArray, you couldn't use it with the foundation classes, so you couldn't use it in any project, really.

-Lee

Darkroom
Jun 11, 2008, 09:50 PM
ok, understood. thanks for clearing that up for me :)