Re: question about -init methods
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