[Seaside] isolate: not working properly

Jon Paynter kittle at mail.yans.net
Thu Sep 23 19:31:50 CEST 2004


---------- Original Message ----------------------------------
From: Avi Bryant <avi at beta4.com>
Reply-To: "The Squeak Enterprise Aubergines Server - general discussion."
Date: Wed, 22 Sep 2004 14:12:23 +0200

>
>On Sep 9, 2004, at 11:36 AM, Avi Bryant wrote:
>
>> Incidentally, I'm not sure why you need a solution this complex.  
>> Instead of replacing Main and RenderLoop, just use a subclass of 
>> WATask as your root component, with this #go method:
>>
>> ChildrenTestTask>>go
>> 	self authenticateWith: self during: [self call: 
>> (ChildrenTestRootComponent new)]
>>
>> That doesn't fix the problem, but it does provide a more minimal test 
>> case for it.
>>
>> I may not have time to look into this more until next week.
>
>Or, as it happens, the week after...
>
>The problem, ultimately, is that I'm lazily initializing the 
>"decoration" StateHolder in WAComponent.  I knew this was risky, but 
>had convinced myself that it would always work.  But you found a case 
>where it didn't; thanks.  Lesson: *never* use lazy initialization for 
>StateHolders, even if you think you know what you're doing.
>
>What this means, however, is that WAComponent needs to do explicit 
>initialization.  I've never been very comfortable with patterns for 
>doing this in classes that are widely subclassed - I can put the 
>initialization of decoration inside #initialize, but that means that 
>all subclasses with #initialize have to make sure to do the super send, 
>and not only are there hundreds of component classes out there that 
>don't do this and would have to be updated, but I suspect even after 
>the change there will be hundreds more where people forget to do it.  
>So what I've got now is:
>
>WAComponent class>>new
>	^ self basicNew initializeDecoration initialize
>
>But that doesn't feel like a great solution either.
>Comments?

Try this:

code WAComponent>>initialize like you want.

Then,  In the spot where you were doing lazy initilization, put in an error check that will raise a walkback if decoration is nil.  Include an error message that points people to their lack of 'super initialize' ... "verify you are calling super initialize in your initialize method", or add an explaination in the method comments.

painful in the short run.. but long term its a good thing.

Jon.



More information about the Seaside mailing list