• 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: Q: how do you generate get/set methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: how do you generate get/set methods?


  • Subject: Re: Q: how do you generate get/set methods?
  • From: Patrick Machielse <email@hidden>
  • Date: Wed, 21 Jan 2004 14:56:27 +0100

op 21-01-2004 03:19 schreef Karl Goiser

> Without wanting to act like a wet blanket, I would like to point out
> that one of the foundation principles of object oriented programming is
> 'encapsulation'. This is the idea that one object should not know
> about the internal state of another. This is a well established design
> principle and is fundamentally important in writing large, well behaved
> applications.

True. However two 'features' of Objective-C make accessors more prominent in
this language.

* absence of namespaces / packages. So you need to provide accessors short
of making all your ivars public.

* Objective-C accessors to pointers are mostly not only accessors, they also
serve as memory managers. Sadly this expands your public API, since there is
no such thing as a private method in Objective-C.

> Personally, I regard the automation of accessor method writing as
> counter this principle. Large numbers of accessor methods, to me, are
> an indication of poor design and a potential source of problems and
> unnecessary complexity.

Let's minimize the number of accessors we write in 2004, but let's write
them automated :-)

patrick
_______________________________________________
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.

  • Follow-Ups:
    • Re: Q: how do you generate get/set methods?
      • From: Daniel Jalkut <email@hidden>
    • CMKY <-> RGBA transforms?
      • From: lbland <email@hidden>
  • Prev by Date: Re: Loading CFM from Mach-o...
  • Next by Date: Re: How to get hard drive name
  • Previous by thread: Re: Q: how do you generate get/set methods?
  • Next by thread: CMKY <-> RGBA transforms?
  • Index(es):
    • Date
    • Thread