[Seaside] Design Question of a very small game

Alexandre Bergel bergel at iam.unibe.ch
Thu Oct 21 15:36:26 CEST 2004


Tasks are used to embed the logical flow of an application whereas the rendering is in charge of components.
As concequences, the entry point of an application should always be a Task's go method.


Cheers,
Alexandre


On Thu, Oct 21, 2004 at 12:27:10PM +0200, Avi Bryant wrote:
> 
> On Oct 20, 2004, at 10:05 PM, Alexandre Bergel wrote:
> 
> >I would like to know a bit your opinion about the code I just wrote.
> >It consist in a very small game: the computer choose randomly a number 
> >between 0 and 100, and the user has to guess it. For each answer, the 
> >computer says: 'too litle' or 'too big'.
> >
> >It is composed of 5 classes with a couple of method for each of them.
> >Do you have a better design for this simple game ?
> 
> Well, one thing that's odd is your use of SimpleGame and 
> SimpleGameTask.  There's no need to have a SimpleGame that just calls 
> SimpleGameTask as the only thing it does - just set SimpleGameTask as 
> the root component (put the class side initialize method with 
> #registerAsApplication on it instead).  And the way you do this call is 
> wrong - you send #call: from SimpleGame's #renderContentOn:, which you 
> should never do (yes, it sometimes works, but it has unpredictable 
> consequences).  I understand why you did it, but that's exactly the 
> problem that WATask was written to solve.  So dump SimpleGame and go 
> right to the task.
> 
> The other thing that strikes me is that you have no component reuse.  
> Both Victory and Loose (which should be Lose or Loss, btw) just display 
> a single text string, and could be replaced by a generic component that 
> takes the message as a parameter.  And, in fact, for a first version of 
> this game I would just use the built in dialogs (using #request: rather 
> than GetNumberComponent and #inform: rather than Victory and Loss).  
> From a teaching point of view, that might be a good first step - you'd 
> end up with a single method on a single class as the whole application 
> - and then you could progress to replacing one of the standard dialogs 
> with a custom component as you have now, etc.
> 
> HTH,
> Avi
> 
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.iam.unibe.ch/~bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.


More information about the Seaside mailing list