[Newbies] My first program. Design/style advice requested.
peter h meadows
phm at sdf.lonestar.org
Mon May 26 17:21:36 UTC 2008
Hi. I wondered if anyone could take a look at my code and answer some
questions. I'm trying to write a program that lets people play Arimaa
(Arimaa is a board game that can be played with a standard chess set. You
can find the rules at arimaa.com but you won't need to know how to play to
understand my code)
My code is on squeaksource: http://www.squeaksource.com/Arimaa.html
I run it by: ArimaaGameZone new openInWindow .
Click on the last two rows to position white pieces, then press the send
button. Then click on the first two rows to position the black pieces. The
move logic is not yet implemented, but I'm sure you get the idea of what I
want to do.
I've tried to use a MVC design where ArimaaBoardMorph is the View,
ArimaaBoard is the Model and ArimaaEventHandler is the controller.
So I have a different class to handle gold setup, silver setup, gold move
and silver move (in arimaa we have gold/silver instead of black/white).
All inherited from the ArimaaEventHandler. The board morph sends a message
to the controller and depending on which controller is set you get
different behaviour.
Is this the best way to do what I want? I think it's probably wrong that
when I switch between controllers I have to copy the variables that
contain the model and the view. How should it be done with good smalltalk
style? Is there a simpler way? Is it right to use inheritance as I have
done?
Any comments on other aspects are most welcome, but my main question is;
have I done the MVC thing right? Don't be afraid to say it's all wrong,
this is my first project and I don't mind rewriting the whole thing from
scratch.
I realise helping me with this may take some of your time, and I am very
grateful for any response. I hope I will stick with squeak and one day do
something useful for the community.
More information about the Beginners
mailing list