On Dec 8, 2008, at 1:43 PM, [EMAIL PROTECTED] wrote:
This decisions was purposeful, explicit, and intentional.
I find this an interesting point. Why was such a decision made? It seems counter intuitive.


Performance

An NSMutableDictionary instance can be returned from a method declared as returning (NSDictionary*) without risk that the client is going to go and change the contents behind your back. If "test for mutability" were common, then all kinds of methods across the 'kits would have to - copy the return value and, potentially, deeply.

Simplicity

What does "mutable" even mean in the case of a collection? If an NSArray of NSDictionaries is "mutable", does that also mean the NSDictionaries contained within are mutable? The current design point is that pretty much everything is immutable unless (a) you specifically created a mutable data structure or (b) the 'kit explicitly returned a mutable data structure.

Reliability

Having lots of "if (mutable) this else that" decision points would reduce the reliability of code in that it would increase the testing load. Example: Unit tests would have to explicitly test the code for both the immutable vs. mutable variants. And that doesn't consider the "mutable container vs. immutable contents" potential myriad of combinations.

b.bum
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to