It's not style, but a technical consideration. Class-level things are shared and common between all object instances. They are thus like globals, but obviously better organized. Class-level methods cannot access things at the object level. Objects have their own different values of attributes.

Putting things on the stack is only an optimization which some OO languages let you do, if you know certain conditions will be met.

Ian

On 08/08/2008, at 3:08 AM, Lee, Frederick wrote:

Greetings:

   I just came across a NSObject subclass written by someone, that
contains a couple of date/Time-processing methods (stringToDate,
visa-versa).

The methods were all class-level methods (+) vs (-); and hence, didn't
require the familiar alloc & init instantiation methods.



I've been writing NSObjects via instantiation (requiring alloc & init)
that I use to model business logic (packing XML data vectors, etc.) and
hold a lot of common methods to use.



I can see a project using class methods instead of instantiated methods;
and hence, avoid the alloc/init memory hassles.



My question (which is ELEMENTARY), is....

1) why use instantiated objects versus classes (via class methods)?

2)      Are classes stored in the stack & instatiated objects on the
heap?





Ric.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/i.joyner%40acm.org

This email sent to [EMAIL PROTECTED]
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to