lecture (18)program design
TRANSCRIPT
![Page 1: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/1.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 115
FSB23103 1
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Lecture 19Program design
Mdm Ratnawati Ibrahim
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 215
FSB23103 2
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
IntroductionWhen constructing a software solution a number of elements are addressed (These will become moresophisticated as knowledge and experience grows)
1 The user interface (Form1)2 The program design
(a) Class definition construction importation
(b) Module definition construction importation(c) Interface methods (Form1 code)
3 Testing(a) Identify inputs
(b) Identify outputsbull Construct test cases and form test plan
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 315
FSB23103 3
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
The user interfaceUsers of a program need to interact with it in some way
This might be viewed as the users conducting a dialoguewith the computerAccordingly they mightbull Read and interpret information that instructs them
how to use the systembull Issue commands to the system to indicate what they
want it to dobull Enter words and numbers into the system to provide it
with data to work withbull Read and interpret the results that are produced by
the system either on screen or as a printed report andbull Respond to and correct errorsNote that theses are secondary tasks concerned withusing the system rather than the usersrsquo primary systemobjectives
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 415
FSB23103 4
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
ExampleConsider the game of noughts and crosses played by twopeople (not against the computer hellipyet)
The required program is to provide a platform to play thegame by recording the lsquogoesrsquo identifying a winner andkeeping score
Accordingly we may envisage something similar to thegame played with pencil and paper
ScorePeter John
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 515
FSB23103 5
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form designRequires some knowledge of the implementation(programming language) to be aware of the facilitiesavailable
First thoughts
Questions
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
Are players to beidentified Do players take turnsto be noughts and
then crosses Who starts Start Game over ndash Crosses win
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 615
FSB23103 6
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form design ndash contrsquod
Label controls and if significant indicate names
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
PictureBox picbox Labels
RadioButtonsrdbPlayer1
rdbPlayer2
TextboxestxtPlayer1ScoretxtPlayer2Score
ButtoncmdFinish
Button cmdDraw
StartLabel (Flashing)
PlayButtoncmdPlay
LabellblResult
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 715
FSB23103 7
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
AnalysisSuppose
1 The players are identified as Player 1 and Player 2 andPlayer 1 is identify before the program is run2 Player 1 - Crosses start3 Play will alternate during a game and on the start of subsequent games
4 A game can be abandoned by clicking the button
5 Picture designUse 50 pixel black and white squares
located by top left vertex
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 2: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/2.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 215
FSB23103 2
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
IntroductionWhen constructing a software solution a number of elements are addressed (These will become moresophisticated as knowledge and experience grows)
1 The user interface (Form1)2 The program design
(a) Class definition construction importation
(b) Module definition construction importation(c) Interface methods (Form1 code)
3 Testing(a) Identify inputs
(b) Identify outputsbull Construct test cases and form test plan
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 315
FSB23103 3
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
The user interfaceUsers of a program need to interact with it in some way
This might be viewed as the users conducting a dialoguewith the computerAccordingly they mightbull Read and interpret information that instructs them
how to use the systembull Issue commands to the system to indicate what they
want it to dobull Enter words and numbers into the system to provide it
with data to work withbull Read and interpret the results that are produced by
the system either on screen or as a printed report andbull Respond to and correct errorsNote that theses are secondary tasks concerned withusing the system rather than the usersrsquo primary systemobjectives
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 415
FSB23103 4
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
ExampleConsider the game of noughts and crosses played by twopeople (not against the computer hellipyet)
The required program is to provide a platform to play thegame by recording the lsquogoesrsquo identifying a winner andkeeping score
Accordingly we may envisage something similar to thegame played with pencil and paper
ScorePeter John
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 515
FSB23103 5
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form designRequires some knowledge of the implementation(programming language) to be aware of the facilitiesavailable
First thoughts
Questions
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
Are players to beidentified Do players take turnsto be noughts and
then crosses Who starts Start Game over ndash Crosses win
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 615
FSB23103 6
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form design ndash contrsquod
Label controls and if significant indicate names
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
PictureBox picbox Labels
RadioButtonsrdbPlayer1
rdbPlayer2
TextboxestxtPlayer1ScoretxtPlayer2Score
ButtoncmdFinish
Button cmdDraw
StartLabel (Flashing)
PlayButtoncmdPlay
LabellblResult
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 715
FSB23103 7
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
AnalysisSuppose
1 The players are identified as Player 1 and Player 2 andPlayer 1 is identify before the program is run2 Player 1 - Crosses start3 Play will alternate during a game and on the start of subsequent games
4 A game can be abandoned by clicking the button
5 Picture designUse 50 pixel black and white squares
located by top left vertex
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 3: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/3.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 315
FSB23103 3
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
The user interfaceUsers of a program need to interact with it in some way
This might be viewed as the users conducting a dialoguewith the computerAccordingly they mightbull Read and interpret information that instructs them
how to use the systembull Issue commands to the system to indicate what they
want it to dobull Enter words and numbers into the system to provide it
with data to work withbull Read and interpret the results that are produced by
the system either on screen or as a printed report andbull Respond to and correct errorsNote that theses are secondary tasks concerned withusing the system rather than the usersrsquo primary systemobjectives
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 415
FSB23103 4
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
ExampleConsider the game of noughts and crosses played by twopeople (not against the computer hellipyet)
The required program is to provide a platform to play thegame by recording the lsquogoesrsquo identifying a winner andkeeping score
Accordingly we may envisage something similar to thegame played with pencil and paper
ScorePeter John
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 515
FSB23103 5
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form designRequires some knowledge of the implementation(programming language) to be aware of the facilitiesavailable
First thoughts
Questions
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
Are players to beidentified Do players take turnsto be noughts and
then crosses Who starts Start Game over ndash Crosses win
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 615
FSB23103 6
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form design ndash contrsquod
Label controls and if significant indicate names
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
PictureBox picbox Labels
RadioButtonsrdbPlayer1
rdbPlayer2
TextboxestxtPlayer1ScoretxtPlayer2Score
ButtoncmdFinish
Button cmdDraw
StartLabel (Flashing)
PlayButtoncmdPlay
LabellblResult
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 715
FSB23103 7
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
AnalysisSuppose
1 The players are identified as Player 1 and Player 2 andPlayer 1 is identify before the program is run2 Player 1 - Crosses start3 Play will alternate during a game and on the start of subsequent games
4 A game can be abandoned by clicking the button
5 Picture designUse 50 pixel black and white squares
located by top left vertex
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 4: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/4.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 415
FSB23103 4
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
ExampleConsider the game of noughts and crosses played by twopeople (not against the computer hellipyet)
The required program is to provide a platform to play thegame by recording the lsquogoesrsquo identifying a winner andkeeping score
Accordingly we may envisage something similar to thegame played with pencil and paper
ScorePeter John
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 515
FSB23103 5
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form designRequires some knowledge of the implementation(programming language) to be aware of the facilitiesavailable
First thoughts
Questions
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
Are players to beidentified Do players take turnsto be noughts and
then crosses Who starts Start Game over ndash Crosses win
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 615
FSB23103 6
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form design ndash contrsquod
Label controls and if significant indicate names
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
PictureBox picbox Labels
RadioButtonsrdbPlayer1
rdbPlayer2
TextboxestxtPlayer1ScoretxtPlayer2Score
ButtoncmdFinish
Button cmdDraw
StartLabel (Flashing)
PlayButtoncmdPlay
LabellblResult
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 715
FSB23103 7
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
AnalysisSuppose
1 The players are identified as Player 1 and Player 2 andPlayer 1 is identify before the program is run2 Player 1 - Crosses start3 Play will alternate during a game and on the start of subsequent games
4 A game can be abandoned by clicking the button
5 Picture designUse 50 pixel black and white squares
located by top left vertex
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 5: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/5.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 515
FSB23103 5
UNIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form designRequires some knowledge of the implementation(programming language) to be aware of the facilitiesavailable
First thoughts
Questions
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
Are players to beidentified Do players take turnsto be noughts and
then crosses Who starts Start Game over ndash Crosses win
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 615
FSB23103 6
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form design ndash contrsquod
Label controls and if significant indicate names
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
PictureBox picbox Labels
RadioButtonsrdbPlayer1
rdbPlayer2
TextboxestxtPlayer1ScoretxtPlayer2Score
ButtoncmdFinish
Button cmdDraw
StartLabel (Flashing)
PlayButtoncmdPlay
LabellblResult
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 715
FSB23103 7
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
AnalysisSuppose
1 The players are identified as Player 1 and Player 2 andPlayer 1 is identify before the program is run2 Player 1 - Crosses start3 Play will alternate during a game and on the start of subsequent games
4 A game can be abandoned by clicking the button
5 Picture designUse 50 pixel black and white squares
located by top left vertex
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 6: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/6.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 615
FSB23103 6
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form design ndash contrsquod
Label controls and if significant indicate names
Finish
Score
Player 1 Player 2
3 4
Noughts Crosses
Draw
PictureBox picbox Labels
RadioButtonsrdbPlayer1
rdbPlayer2
TextboxestxtPlayer1ScoretxtPlayer2Score
ButtoncmdFinish
Button cmdDraw
StartLabel (Flashing)
PlayButtoncmdPlay
LabellblResult
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 715
FSB23103 7
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
AnalysisSuppose
1 The players are identified as Player 1 and Player 2 andPlayer 1 is identify before the program is run2 Player 1 - Crosses start3 Play will alternate during a game and on the start of subsequent games
4 A game can be abandoned by clicking the button
5 Picture designUse 50 pixel black and white squares
located by top left vertex
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 7: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/7.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 715
FSB23103 7
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
AnalysisSuppose
1 The players are identified as Player 1 and Player 2 andPlayer 1 is identify before the program is run2 Player 1 - Crosses start3 Play will alternate during a game and on the start of subsequent games
4 A game can be abandoned by clicking the button
5 Picture designUse 50 pixel black and white squares
located by top left vertex
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 8: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/8.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 815FSB23103 8
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class design1 Identify any class definitions to be imported
Square
2 Identify any classes to be constructed and specify theirmembers
(a) a (chequered) board
display areashow to make the board visible
(b) A lsquogorsquo ndash either a nought or a crossdisplay areavalue to indicate whether nought or cross
show to make symbol visible
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 9: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/9.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 915FSB23103 9
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitionsbull Board
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 10: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/10.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1015FSB23103 10
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Class definitions ndash contrsquodbull Go
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 11: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/11.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1115FSB23103 11
U
NIVERSITIKUALALUMPUR
MalaysiaFranceInstitute
Form1 methodsBrainstorm what operations need to carried out and orderthembull Initialisation
Set initial values of global () variablesEg scores
Set up interface
bull Start gameInitialise variables specific to a particular gameEg record of goes number of turnsDisplay board
bull Flash promptbull Manage a lsquogorsquobull Check for a winbull Identify winner
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 12: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/12.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1215FSB23103 12
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Form1 methods ndash contrsquodDecide how methods will be invoked click-handler call fromwithin some other method
bull Initialisation - MyBaseLoadbull Start game - cmdPlaybull Flash prompt - Timer1Tickbull Manage a lsquogorsquo - picBoxMouseDown
bull Check for a win - called from picBoxMouseDown bull Identify winner - called from picBoxMouseDown
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 towork This might mean going back and modifying some of theconstituent components
R un
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 13: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/13.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1315FSB23103 13
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Review codeRevisit the code tobull
Eliminate redundancybull Make more readableintelligible by restructuringbreaking large methods into smaller parts considerintroducing functions
bull Check the need for global variables and where possible
make localbull Introduce comments if not already present
Perform tests to identify problems deficiencies etcEach time you complete a set of changes re-run all testcases
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 14: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/14.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1415FSB23103 14
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Example - deficiency
What happens if a player selects an occupied cell
- Need to identify and prohibit this
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run
![Page 15: Lecture (18)Program Design](https://reader034.vdocument.in/reader034/viewer/2022052516/577d396b1a28ab3a6b99b3bc/html5/thumbnails/15.jpg)
8142019 Lecture (18)Program Design
httpslidepdfcomreaderfulllecture-18program-design 1515FSB23103 15
U
NIVERSITIKUALALUMPUR
M
alaysiaFranceInstitute
Deficiency ndash contrsquod
Replaced by
and
Run