I’m just working through the Agile web dev book (which is great) and i’m
at the point i’d like to put together something to test my
understanding. Luckily I have a project that will help my gaming
community organise games on modern warfare 2. It also doesn’t map onto
the depot like for like which is good
The basic idea is you have a list of game modes and a list of maps.
These lists can be added to. They can’t be removed but they can be set
Now a game consists of a map and a game mode. A match consists of one or
more games (specified by the user). The games for a particular match get
chosen at random - the one rule being that the a map and game mode may
only appear once in the match.
The application should allow the user to enter the number of games they
want to play and generate a match. this match is given a short
description (e.g. Team 1 v Team 2) and gets stored so that people
playing the match can see what games they will be playing.
So far i’ve got the models i think i need:
I’ve created the map, game_model and match using scaffold as i want to
be able to maintain them through the UI.
I’ve created game and match_game as pure models as they are part of the
So far, am i on the right track based on good practice and design?
One consideration i did have was whether, based on the fact that the
maps and game_modes tables will always have a relatively small number of
entries, i should just autogenerate the rows (20 in each table = 400
rows. random generate a number between 1 and 400 and it picks the game).
If i was to do this where would i embed the method to autopopulate the
game table? (in the game model itself or a helper - i’m not sure on best
practice). This could also be called if the admin decided to update the
table with a new entry (i.e. it would create the extra matches needed).
At this stage i haven’t even thought through how the actual UI will
build all the bits and put them together but i’m thinking this would be
the job of my match controller which creates a match object, x game
objects and sets the ‘games’ property of the match object before
committing the changes to the DB and letting rails do some magic to save
it all (i’m not looking for someone to tell me as i’d like to work it
out but if i’m way off track here then a pointer or 2 would be
Thanks for taking the time to read and i appreciate any comments or
opinions you can offer this newbie