• 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: "Erik M. Buck" <email@hidden>
  • Date: Thu, 16 Aug 2001 12:47:43 -0500

Sometimes the purpose of a class is to store a value. The class would be
useless if there was no "set" accessor to set the value.

Having a "set" accessor does not violate encapsulation. Directly setting an
instance variable via structure de-reference does violate encapsulation. A
"set" accessor perfectly preserves encapsulation. In the extreme case, a
class could be modified so that it no longer contains an instance variable,
and the corresponding "set" accessor could be modified to store the value
some other way (a dictionary, on disk, whatever). The code that uses the
class via the "set" accessor does not need to change. The "set" accessor
enhanced (created) the encapsulation that enabled the complete
re-implementation of a class without changes to code that uses the class.

A Class that lets outsiders arbitrarily change its internal state is a bad
idea, unless the sole purpose of the class is to store an arbitrary state.


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

  • Prev by Date: Re: Category vs Subclass
  • Next by Date: Re: Searchable Archives Are Here
  • Previous by thread: Re: Is encapsulation deprecated in ObjC?
  • Next by thread: Re: Is encapsulation deprecated in ObjC?
  • Index(es):
    • Date
    • Thread