Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: name that method!




If I were in your position, I would do something like

- (NSString *)serializeWithFormat:(SerialFormat)format;

e.g.

[myDictionary serializeWithFormat:JSONFormat]

It would return different representations of the dictionary based on what enum constant of type SerialFormat was passed in (e.g. JSONFormat, XMLRPCFormat, OPMLFormat, etc), and that way I wouldn't be locking myself into one particular representation of the dictionary like I would if I chose a JSON-specific name for the method. Which means I could reuse the dictionary category in other projects where I might need representations other than JSON. Which means I'd to write less code the next time around.

-- Ilan



On Sep 28, 2007, at 7:40 AM, Stig Brautaset wrote:

Dear all,

I'm currently writing a JSON framework (http://code.brautaset.org/ JSON/ )[0]. It contains a collection of categories adding JSON support to existing Cocoa classes.

I add a method to NSDictionary and NSArray to return an NSString instance containing their JSON representations, and therein lies my problem. What do I name this method? I initially went with - JSONString, but that is slightly ambiguous and can be confused with JSON's own string type. I'm leaning towards simply -JSON[1]. What do you think?

[0] yes, I'm aware there are a couple of existing projects floating around. Call it intellectual curiosity.
[1] I also considered -JSONText, as "JSON text" is the term used in the RFC (http://www.ietf.org/rfc/rfc4627.txt?number=4627) but this would seem to indicate that we're returning an NSText instance, which is not the case.


PS: sorry to bother you all with such banal questions but I find coming up with good names to be one of the hardest problems in software development.

Stig
--
http://code.brautaset.org
http://blog.brautaset.org


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

Ilan Volow "Implicit code is inherently evil, and here's the reason why:"



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >name that method! (From: Stig Brautaset <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.