• 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: @properties and Information Hiding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @properties and Information Hiding


  • Subject: Re: @properties and Information Hiding
  • From: Charles Steinman <email@hidden>
  • Date: Thu, 1 Nov 2007 08:01:48 -0700 (PDT)

--- Karl Goiser <email@hidden> wrote:

> It was interesting to read how the new @properties
> feature of
> Objective-C 2.0 are justified in terms of
> encapsulation.  Of course,
> one of the other major principles of object-oriented
> programming is
> information hiding, that is, only exposing (making
> public) the parts
> of an object which are necessary for interaction
> with it.  At first
> look, it seems that properties make it much easier
> to break this
> principle.

How do you mean? I really don't see it, unless you
mean "It's easier to write a class in general, and
thus by extension it's easier to write a class with
poor encapsulation." I don't think the requirement of
declaring accessors as methods did very much to
safeguard implementation details.

> Along these lines, I am looking for advise on how to
> implement a
> pattern that I am sure many people use: having a
> private setter and a
> public getter.  Before properties, I'd implement the
> two methods in
> the implementation part and only declare the getter
> in the interface
> part.  But now, in the 2.0 world, how can I leverage
> the magic of
> synthesis to implement such a pattern?

I don't think you can synthesize it. I'd just declare
the property read-only and do it the same way you've
always done it for the private setter.

Cheers,
Chuck

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >@properties and Information Hiding (From: Karl Goiser <email@hidden>)

  • Prev by Date: NSMailDelivery now in deprecation w/Leopard
  • Next by Date: Re: @properties and Information Hiding
  • Previous by thread: Re: @properties and Information Hiding
  • Next by thread: Re: @properties and Information Hiding
  • Index(es):
    • Date
    • Thread