• 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: Is encapsulation deprecated in ObjC?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is encapsulation deprecated in ObjC?


  • Subject: Re: Is encapsulation deprecated in ObjC?
  • From: Ondra Cada <email@hidden>
  • Date: Thu, 16 Aug 2001 18:18:54 +0200

Brian,

>>>>>> Brian Hill (BH) wrote at Thu, 16 Aug 2001 10:08:18 -0500:
BH> Another point I'd emphasize is that sometimes what looks like public
BH> accessors in Cocoa aren't really accessors at all (in the sense that
BH> they just give up the value of an instance variable).
BH>
BH> For example, the 'objectValue', 'intValue', etc... methods on various
BH> NSControls really don't just return the value of the instance variable
BH> named 'objectValue'. They wrap a reasonably complex code path going down
BH> into the internal NSCell instance and then the NSFormatter (if there is
BH> one).

OTOH, in a *VERY REMOTE* sense, encapsulation _IS_ deprecated -- see the
key/value protocol.

But, as for new classes, the idea is quite clean: do implement just those
accessor methods you *DO* need for the abstraction, and no more! *IF* some
code *HAPPENS* to need to violate the encapsulation, well, the key/value
protocol is here.

(Actually, it is questionable whether it does violate encapsulation or not;
I would like not to raise flamewar on it. Do study the thing and decide for
yourself whether you feel it does /go across encapsulation/ or not. What's
important: you don't really need accessor methods, unless they truly are part
of the abstract class API.)
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


  • Follow-Ups:
    • Re: Is encapsulation deprecated in ObjC?
      • From: Brian Hill <email@hidden>
References: 
 >Re: Is encapsulation deprecated in ObjC? (From: Brian Hill <email@hidden>)

  • Prev by Date: Re: Online C++ resources?
  • Next by Date: Re: Online C++ resources?
  • Previous by thread: Re: Is encapsulation deprecated in ObjC?
  • Next by thread: Re: Is encapsulation deprecated in ObjC?
  • Index(es):
    • Date
    • Thread