• 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: Accessor method idioms...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessor method idioms...


  • Subject: Re: Accessor method idioms...
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Thu, 24 Mar 2005 19:17:38 +0100

At 11:53 Uhr -0500 24.03.2005, John Brownlow wrote:
I've tried writing like this but it always starts to feel redundant, an unnecessary layer of indirection. Maybe there are circumstances where it's helpful but... I haven't found them.

Here's a simple one: maybe one day you decide that instead of NSArray you want to use another (faster, or more flexible, or whatever) data structure. With objectFromThingsAtIndex: it's easy. With [[self things] objectAtIndex:] you're bound to supporting access via an NSArray.


The less of such details your class exposes to its clients, the easier it is for you to change it without having to change the clients. That's the entire reason encapsulation and accessors exist for in the first place.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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
  • Follow-Ups:
    • A Challenge WAS Accessor method idioms...
      • From: John Brownlow <email@hidden>
References: 
 >Accessor method idioms... (From: Mike Ferris <email@hidden>)
 >Re: Accessor method idioms... (From: John Brownlow <email@hidden>)

  • Prev by Date: Random image problem solved, but...
  • Next by Date: A Challenge WAS Accessor method idioms...
  • Previous by thread: Re: Accessor method idioms...
  • Next by thread: A Challenge WAS Accessor method idioms...
  • Index(es):
    • Date
    • Thread