While I'm in whining mood these days (so it seems), let's me talk about a part of Objective-C which I don't like too much: the lack of namespace. This has a unfortunate effect on the way Cocoa can be confusing at time simply because in order to avoid name collision, everyone is prefixing his stuff with some kind of 2 to 3 letters abbreviation. For example, Apple have been using
Since namespaces are a relatively recent addition to C++, the fact that is missing from Objective-C isn't much of a surprise. However, one may wonders why it has still not been added. In any case, this is somewhat irrelevant, since it is unlikely that Apple will go over Cocoa (and other framework such as Foundation) and make use of some
Like our Hungarian friends like to said: A little prefixing can go a long way ...
NS
since back in the NeXTSTEP days and thus everything in Cocoa is prefixed as such (e.g NSApplication, NSController ...). And this is the problem since at first glance, there is no easy way to tell what a particular keyword is, unless you already know about it. For example, is NSPoint
a class? No, it's a structure. NSNumber
? a class, NSInteger
? a type ... 9_9Since namespaces are a relatively recent addition to C++, the fact that is missing from Objective-C isn't much of a surprise. However, one may wonders why it has still not been added. In any case, this is somewhat irrelevant, since it is unlikely that Apple will go over Cocoa (and other framework such as Foundation) and make use of some
Cocoa
namespace; braking everyone code in the process. Alas, something like NS::TInteger, NS::CNumber will have make the developers life a little easier ... Like our Hungarian friends like to said: A little prefixing can go a long way ...
1 comment:
Don't forget to file a bug. :)
Post a Comment