18: Program design. Introduction. When constructing a software solution a number of elements are addressed (These will become more sophisticated as knowledge and experience grows) The user interface (Form1) The program design Class definition / construction / importation
When constructing a software solution a number of elements are addressed (These will become more sophisticated as knowledge and experience grows)
The user interface (Form1)
The program design
Construct test cases and form test plan
Consider the game of noughts and crosses played by two people (not against the computer ….yet!) The required program is to provide a platform to play the game by recording the ‘goes’, identifying a winner and keeping score.
Accordingly we may envisage something similar to the game played with pencil and paper:
Requires some knowledge of the implementation (programming language) to be aware of the facilities available.
Player 1 Player 2
Are players to be identified?
Do players take turns to be noughts and then crosses?
Game over – Crosses win
Label controls and, if significant, indicate names:
Player 1 Player 2
The players are identified as Player 1 and Player 2, and Player 1 is identify before the program is run.
Player 1 - Crosses start
Play will alternate during a game and on the start of subsequent games
A game can be abandoned by clicking the ‘Abandon’ button
Use 50 pixel black and white squareslocated by top left vertex
Identify any class definitions to be imported:
Identify any classes to be constructed and specify their members
Game – cont’d
Brainstorm what operations need to carried out and order them:
Decide how methods will be invoked: click-handler, call from within some other method?
In this way the problem is broken down into smaller subtasks.
Tackle each of these subtasks; if necessary, develop their solution in separate projects. Assemble the whole and adjust to work. This might mean going back and modifying some of the constituent components.
Revisit the code to
Perform tests to identify problems, deficiencies, etc.Each time you complete a set of changes, re-run all test cases.
Manage a ‘go’
What happens if a player selects an occupied cell?
What will happen if player continues after game has been won?
- Need to identify and prohibit these situations.
Accordingly, we have