Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Newbie Question on Style
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie Question on Style



I'm writing my first Cocoa app--actually my first app in a C-like OO language. One of its functions is to convert between different data formats. I have an object class to which my app controller hands data (e.g. initializes) in one format, and then uses instance methods to convert to others and return the converted data. Two stylistic questions:

(1) The main conversion method(s) call other (repetitively used) utility methods to perform some of their work. There is data (conversion in progress) and flags involved. Is it better to set these as object instance variables, or pass the data back and forth between the methods? The former seems a bit of a waste because the flags, at least, will not be common to the several different conversions yet would always exist in each object instance--perhaps (slightly) inefficient in terms of memory use. On the other hand, I wonder about the performance overhead of passing the data back and forth on every method call.

(2) Is the general rule to store data in an instance of an immutable class (e.g. NSData), do work--e.g. a conversion--in, say, NSMutableData, and then release the former and set the instance variable to point to the latter? If so, is this mostly for performance reasons? I've seen it suggested somewhere--perhaps in Hillegass [1]--that mutable classes are less efficient.

Hopefully the above is not too abstract to understand without seeing the source.

By the way, if there is anyone in Vancouver (BC) who would be interested in starting a group something like Seattle Xcoders [1], please get in touch.

[1] http://bignerdranch.com/products/cocoa1.shtml
[2] http://www.seattlexcoders.org/


Thanks,

Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.