Re: Apples's code examples... It is me
Re: Apples's code examples... It is me
- Subject: Re: Apples's code examples... It is me
- From: "Yanko Ivanov" <email@hidden>
- Date: Wed, 6 Feb 2008 15:10:58 +0100
Kyle, I did notice the "static" keyword. However the it is still
confusing for me (Java programmer).
Stéphane, yes it is me.
I should have made a test (http://pastie.textmate.org/148207) before posting :)
Regards,
Yanko
> On Feb 6, 2008, at 12:24 , Kyle Sluder wrote:
>
> On Feb 6, 2008 6:05 AM, Yanko Ivanov <email@hidden> wrote:
> Please take a look at the code at http://pastie.textmate.org/148159
>
> It is clear that the code's intention is to instantiate the managed
> object context only once... however it seems to me that a new instance
> will be created every time the method is being called.
>
> Did you miss the "static" keyword before the variable declaration?
>
> I also noticed the following pattern used in the Docs for creating
> instance members that are expensive to create:
>
> begin method
> if instance_member not nil
> return instance_member
>
> instantiate instance_member
> return instance_member
> end method
>
>
> Why just not use:
>
> begin method
> if instance_member is nil
> instantiate instance_member
>
> return instance_member
> end method
>
> Style. Which is easier to read, assuming initialization of
> "instance_member" is non-trivial? Of course, they're using static
> variables here, not instance variables, but that's a secondary issue.
>
> --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