• 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: question about -init methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about -init methods


  • Subject: Re: question about -init methods
  • From: j o a r <email@hidden>
  • Date: Mon, 10 Jul 2006 08:44:08 +0200


On 10 jul 2006, at 07.57, Vinay Prabhu wrote:

Instead of releasing and recreating already created object ,
one can re-use already created object(improves the performance, at least in
my application).
This concept is used in the "shared object" approach.

If you need to re-use some objects, a lot of times, you can use an "object pool". When you're done with an object, return it to the pool, and when you need a new object, get one from the pool. It's a pretty common design pattern. Like Sherm suggested, you should in that case implement a "reset" method (you may call it whatever you want) to restore the objects to their default state when returning them to the pool. You should not, as has been pointed out many times already, re-use the "initXXX" machinery for that purpose.


Don't fight the framework! Use it as it was intended, that way you'll save yourself a lot of trouble. Using object pools and reset methods you'll get all the benefits that you're looking for, and none of the potential problems of re-using the init methods. The choice should be very easy.

j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >RE: question about -init methods (From: Vinay Prabhu <email@hidden>)

  • Prev by Date: Re: where have all the IVARS gone? (long time passing...)
  • Next by Date: RE: where have all the IVARS gone? (long time passing...)
  • Previous by thread: RE: question about -init methods
  • Next by thread: How to identify the host app is Carbon or Cocoa in a context menu plugin.
  • Index(es):
    • Date
    • Thread