• 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: Mutability
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mutability


  • Subject: Re: Mutability
  • From: Drew McCormack <email@hidden>
  • Date: Wed, 21 Nov 2001 09:19:42 +0100

Exactly. Using immutable classes would effectively be saying "You are not supposed to change these arrays/dictionaries", so you have to ask "Why are you changing them to begin with?".

Really, using things like "isKindOfClass" is often a symptom of bad design. Sometimes it can't be avoided, but I think this is an example of when it can.

Drew McCormack


On Wednesday, November 21, 2001, at 07:54 , Raphael Sebbe wrote:

I would say that if it is your intent to add objects later in the hierarchy, then use only mutable classes from the ground up. This will make it a lot easier...

Raphael

On Wednesday, November 21, 2001, at 05:43 AM, Angela Brett wrote:

That's true, but consider the case where the object is deep in nested NSArrays or NSDictionaries. Assuming the object is immutable means you have to add the mutableCopy of it to its parent array/dictionary in place of the original object, and if you don't know whether the parent is mutable or not you'll also have to make a mutableCopy of that and add it to its parent, and so on until you get to the 'root' object. That's quite a lot of unnecessary steps if the original objects were actually mutable anyway and you didn't know it. Or perhaps this post is all newbie nonsense. :)
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


================================
Dr. Drew McCormack
Department of Theoretical Chemistry
Science Faculty
Free University Amsterdam
De Boelelaan 1083
1081 HV Amsterdam
The Netherlands

Email :: email@hidden
Tel. :: +31 20 44 47623
Fax :: +31 20 44 47629


  • Follow-Ups:
    • Re: Mutability
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Mutability (From: Raphael Sebbe <email@hidden>)

  • Prev by Date: Re: Mutability
  • Next by Date: Cocoa & UNIX
  • Previous by thread: Re: Mutability
  • Next by thread: Re: Mutability
  • Index(es):
    • Date
    • Thread