Hacker News new | past | comments | ask | show | jobs | submit login

"JSONObjectWithData" means that it produces an object from NSData input. This is perfectly reasonable because valid JSON can also be an array and the input could be something else than a buffer, for example a string.

I don't find Cocoa's verbose names to be a problem because the logic behind them is very consistently applied and Xcode's autocomplete fills them in anyway.

Personally I greatly prefer Cocoa's excessively "literary" style to the arbitrarily shortened style used in many dynamic languages like Ruby. Unlike "JSONObjectWithData", method names like "eql?", "gsub" and "len" can't be deduced, you just have to remember them or look them up.




I agree entirely. It's just as fast to read and typing abbreviations is actually slower than typing full words most of the time because of keystroke muscle memory. Sure, it can make a screenful of code 'look' uglier but in the end it reads explicitly and that can only be a good thing.


I don't think anyone is advocating for abbreviations.


> This is perfectly reasonable because valid JSON can also be an array

Are arrays (and primitives which can be boxed) not considered objects in every OO language ever?

Agreed re: usls ctrctns. That's the other extreme. One wants to convey the required meaning in the minimum amount possible - no more, no less.

Edit: thinking about it, you probably mean that the top level object is a hashtable, since ObjC is strongly typed. If I was going to do that I'd rather check the whole structure (rather than just the top) with an interface.


Yeah, that's what I meant. Because JSON is based on JavaScript, its data types are often called by their JS names: a name/value pair collection is an "object" and an ordered list is an "array"... But of course an array is an object as well, so there's ample room for confusion.


JSONObjectWithData can return an NSArray or an NSDictionary in the general case, and a NSString, NSNull or NSNumber if you direct it to allow fragments. It can also return nil.

So aside from being verbosely named, it's also incorrectly named.

If they'd called it [NSJSON parseData:] you wouldn't have been confused.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: