• 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
Re: Memory management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory management question


  • Subject: Re: Memory management question
  • From: Alastair Houghton <email@hidden>
  • Date: Sat, 27 Mar 2004 23:43:15 +0000

On 27 Mar 2004, at 18:00, Jerry Krinock wrote:

> I don't understand the recommendation to use the getter method [snip]
> and the advice to always use the getter method [snip] instead of just
> a direct reference [snip] when using foo in other methods in the
> class.
>
> What's the effective difference between these two expressions? All I
> can
> see is that the getter has the overhead of a message, while the direct
> reference does not and should run faster.

The difference is that with the method in place, you can easily change
the implementation of your class (for instance, you may decide that
it's better to compute a value on the fly rather than keeping a copy in
each object). If you don't use the getter method, you may have to
change a lot more code.

The getter method also allows you to do other things, like log changes
to a property, which is pretty much impossible without using a
getter/setter approach.

I have to say that I do vary my implementations; for simple classes
whose implementation is unlikely to change and that are unlikely to be
subclassed, I often write direct references. For more complex classes,
or classes that might be subclassed, using the method approach is
certainly better.

Kind regards,

Alastair.

--
http://www.alastairs-place.net

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Memory management question (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Question about Deprecated Methods
  • Next by Date: Re: Question about Deprecated Methods
  • Previous by thread: Re: Memory management question
  • Next by thread: Re: Memory management question
  • Index(es):
    • Date
    • Thread