On 08.10.2012 13:25, Igor Stasenko wrote:
On 8 October 2012 13:06, Henrik Sperre Johansen <henrik.s.johansen@veloxit.no> wrote:
On 08.10.2012 13:03, Henrik Sperre Johansen wrote:
IMO, lazily checking whether the image has been restarted whenever you want to do something stinks. Registering to be notified when image starts/stops is a lot better.
Not to mention, less error-prone. Miss one session check that the current session is the right one somewhere... and everything might blow up if that is the first piece of functionality used.
True. I did not said that my method should replace old. Sometimes lazy initialization is not what you want. But having no way to perform lazy initialization is even worse. Ah, I just objected to the notion that startup lists inherently stinks, and took the diametrical view for the sake of argument :) Yes, lazy initialization has its uses too, but some guidelines/advice* on when to what those uses are, and when you'd use startUp: registration instead, is needed I think.
Notice; in most cases where such cleanup at startup is needed (sockets, window handles, etc.), additional cleanup is needed when the object goes out of scope during regular use, and so a registry usually exist. Thus, your startup code isn't usually X allInstancesDo: #something but X weakRegistry allEntriesDo: #someting. which stinks a whole lot less. Cheers, Henry *So in my view, to use lazy init over startUp registration, it would need to: - Concern instance data. - Not need weak cleanup. - Be containable to a single accessor