[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fwd: RFC GDL2: move +load implementations to +initialize]

From: Adam Fedor
Subject: Re: [Fwd: RFC GDL2: move +load implementations to +initialize]
Date: Fri, 17 Jan 2003 09:16:55 -0700

On Friday, January 17, 2003, at 08:31 AM, Mirko Viviani wrote:

David Ayers <d.ayers@inode.at> ha scritto:

Why the EODatabaseChannel should have received the +initialize before the
notification of the EOObjectStoreCoordinator ?
You should invoke it manually, it has no sense.

No, no, both +load and +initialize are guaranteed to be sent by the
runtime, not by any explicit code!

I know...

In the very unlikely event that no messages get sent to
EODatabaseContext before the the EOCooperatingObjectStoreNeeded
Notification gets posted, we should just make sure to call some
EODatabaseContext method (like [EODatabaseContext class]) real early to
force the runtime to send +initialize to EODatabaseContext.

The problem is really this... how to be sure that a message will be sent to
these classes ?

+initialize will always be sent to a class before it is used. If you are really paranoid, you could take one class's +initialize method that you know is being used first, and add a bunch of

[ThisClass class]
[AnotherClass class]
[Etc class]

and all those classes will be initialized also.

(2) Objective-C code should never be used in a +load method. A lot of basic Objective-C/Foundation code is not setup when the +load messages are sent (like NSString). Trying to send messages in +load can potentially cause a nightmare of recursive initialization.

(3) My personal preference is to not put any 'executable' code (Objective-C or otherwise) in +load OR +initialize methods. If at all possible, classes should be setup in a lazy manner, which avoids a lot of startup costs. Although I realize this is not possible in many cases.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]