• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Newbie Question on Style
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie Question on Style


  • Subject: Newbie Question on Style
  • From: Chris Ryan <email@hidden>
  • Date: Tue, 15 Aug 2006 19:43:48 -0700

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


  • Prev by Date: Re: Unit testing and Xcode integration
  • Next by Date: Re: Applying a Drop Shadow to an NSView
  • Previous by thread: Re: NSDirectoryEnumerator Question
  • Next by thread: Question about NSTableView and column reordering...
  • Index(es):
    • Date
    • Thread