• 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: Best Practice for Returning Immutable Objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best Practice for Returning Immutable Objects?


  • Subject: Re: Best Practice for Returning Immutable Objects?
  • From: "Kyle Sluder" <email@hidden>
  • Date: Tue, 3 Jun 2008 16:25:25 -0400

On Tue, Jun 3, 2008 at 3:07 PM, Seth Willits <email@hidden> wrote:
> I used to think that. Now I'm converting to making sure it truly is
> returning an immutable object. There have been cases where I've changed it
> under myself and run into problems. I figure if it says it's immutable, it'd
> better be immutable.

I always do [[mutableInstance copy] autorelease] for two reasons:
1) I told you I've given you an immutable object.  The other portions
of my code had better be able to rely on that object's immutability.
2) It is not my responsibility to optimize creating immutable
instances out of mutable instances.  If it can be done, it is the
mutable class's implementor's problem.  (Of course that might be "me"
the person, but it isn't "me" the client of the mutable class.)

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Best Practice for Returning Immutable Objects? (From: Karl Moskowski <email@hidden>)
 >Re: Best Practice for Returning Immutable Objects? (From: j o a r <email@hidden>)
 >Re: Best Practice for Returning Immutable Objects? (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Copying NSTextStorage
  • Next by Date: Re: Alert Sheets hard wired in Interface Builder
  • Previous by thread: Re: Best Practice for Returning Immutable Objects?
  • Next by thread: Re: Best Practice for Returning Immutable Objects?
  • Index(es):
    • Date
    • Thread