mark dixon, socce soft 136page 1 02 – software development life-cycle

29
Mark Dixon, SoCCE SOFT 136 Page 1 02 – Software Development Life-Cycle

Post on 19-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 1

02 – Software DevelopmentLife-Cycle

Page 2: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 2

Admin

• Technicians (Babbage 205) can provide you with free copies of (bring your own blank CDs):

– MS Visual Studio 6.0 (4 CDs), includes• Visual BASIC 6.0• Visual InterDev 6.0• Visual C++ 6.0

Page 3: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 3

Questions: Events

• Consider the following code:

a) How many unique events does it contain?

b) Name the event(s).

Private Sub btnAns_Click() Me.BackColor = vbBlue lblComment.Caption = "Correct, well done!"End Sub

1

Click

Page 4: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 4

Questions: Properties

• Consider the following code:

a) How many properties does it contain?

b) Name the properties.

2

BackColor, Caption

Private Sub btnAns_Click() Me.BackColor = vbBlue lblComment.Caption = "Correct, well done!"End Sub

Page 5: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 5

Questions: Keywords

• Consider the following code:

a) How many unique keywords does it contain?

b) Name the keywords.

3

Private, Sub, End

Private Sub btnAns_Click() Me.BackColor = vbBlue lblComment.Caption = "Correct, well done!"End Sub

Page 6: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 6

Questions: Objects

• Consider the following code:

a) How many objects does it contain?

b) Name the objects.

3

btnAns, Me, lblComment

Private Sub btnAns_Click() Me.BackColor = vbBlue lblComment.Caption = "Correct, well done!"End Sub

Page 7: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 7

Object naming conventions• all objects have name property

used to identify them in code (identifier) txtSurname.Caption = "Smith"

• 3 letter prefix to denote type, followed by short meaningful word/phrase:– frm: form (e.g. frmMain, frmAdd)– pic: picture box (e.g. picDisplay, picFace)– txt: text box (e.g. txtMonth, txtDrink)– lbl: label (e.g. lblName, lblAge)– btn: command button (e.g. btnClear, btnExit)

• makes it easy to read code

Page 8: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 8

Session Aims & Objectives• Aims

– introduce you to fundamental software development lifecycle concepts

• Objectives, by end of this week’s sessions, you should be able to:– Run through the software development cycle.

• Implement simple software design– Create (draw) user interface– Put instructions in:

» correct event handler procedure for desired result» correct sequence for desired result

• Test this design– Identify and correct simple logical and syntax errors– Identify & correct simple user interface (usability) problems

Page 9: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 9

Project Files: Create New Folder

• Create new folder for each project (on U: drive),use Windows Explorer:

Page 10: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 10

Project Files: Create New Folder

• Save all project files into that folder (using VB6)– project file (.vbp)– form files (.frm)

Page 11: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 11

Version Control: Copy Folder• At regular intervals copy whole folder to create

new version– drag the folder and hold down CTRL key

Page 12: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 12

Version Control: Rename Folder• Rename the copy of the folder, using the date

and time it was created:

Page 13: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 13

Software Development Cycle

• Software development follows this pattern:– analyse problem – what does the user need?– design solution – how can I help?– implement (code) solution – build it!– test & debug solution (code) – does it work?

• However, it is:– cyclic/iterative (not linear)

Page 14: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 14

Example 1: Ball v1 - Analysis

•User Requirements– describe user's objectives

no mention of technology

•Software Requirements– Functional

• list facilities to be provided (often numbered)

– Non-functional• list desired characteristics

(often more subjective)

SPECIFICATION• User Requirements

– keep play schoolchildren occupied

• Software Requirements– Functional:

move cartoon characteraround the screen

– Non-functionalcharacter should beinteresting and colourful

Page 15: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 15

Example 1: Ball v1 - Design

• User interface design:

• Functional design:

Trigger (when) Actions (what)click event of Right button move ball character right

click event of Left button move ball character left

click event of Up button move ball character up

click event of Down button move ball character down

Page 16: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 16

Example 1: Ball v1 - Form• Properties (setting at design-time):

– initial value only– change using properties window

name: used internally to identify object (programmer)

caption: displayed on button (user)

left:

horizontal position

Page 17: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 17

Example 1: Ball v1 - Code

Option Explicit

Private Sub btnRight_Click() picBallChar.Left = picBallChar.Left - 200End Sub

• Properties (setting at run-time)– use code, assignment operator (=)– can change while program is running

btnRight

picBallChar

BallChar

Page 18: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 18

Testing & Debugging: Errors• 3 error types :

– syntax: computer unable to understand your instructions (program does not execute), e.g.

• variable not defined (probably most common)

– run-time: program can't execute instruction and exits (future lecture)

• Device unavailable (e.g. floppy drive)

– logical: program executes but does not not match specification (do what was intended), e.g.

• clicking on button does nothing, when you thought you attached code to it

• clicking on blue button changes colour to red (when it should change to blue)

Page 19: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 19

• Computer – just symbol matching– No intelligence

Example: Hello Errors

Sub Command1_Cluck LabelL.Caption = "Hello"End Sub

L instead of 1: causes syntax error (variable not defined)

u instead of i: causes logical error (Command1 button does nothing)

Page 20: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 20

Question: Errors

• The following example is from lecture 1,– Spot the errors (you should find 6), and– decide whether they are syntax or logical

Private Sub btnBlue_Cluck() lblResult.BackColor = vbRedEnd Sub

Private Sub btnRed_lick() lblResult.BackColor vbRedEnd Sub

Private Sub lb1Result_DblClick() lblResult.BackColour = vbWhiteEnd Sub

Page 21: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 21

Debugging: Testing

• Functional Decomposition– break it into logical chunks

• Incremental Development– type a bit– test it

• Testing– test all/most combinations

• Regression Testing– repeat all previous tests

Page 22: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 22

Sequence

• Execution sequence controlled in two ways:– procedures controlled by order of events– instructions (lines) controlled by order in code

Private Sub btnBlue_Click() lblResult.BackColor = vbBlueEnd Sub

Private Sub btnRed_Click() lblResult.BackColor = vbGreen lblResult.BackColor = vbRedEnd Sub

Private Sub lblResult_DblClick() lblResult.BackColor = vbWhiteEnd Sub

VB

Page 23: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 23

Example: Ball v2 (animation)

Option Explicit

Private Sub Form_Load() tmrBall.Enabled = FalseEnd Sub

Private Sub btnGo_Click() tmrBall.Interval = 100 tmrBall.Enabled = TrueEnd Sub

Private Sub tmrBall_Timer() picBall.Left = picBall.Left + 100End Sub

• Need a– picture box– command button– timer control

Trigger (when) Actions (what)click event of Go button ball character moves left

continuously

Page 24: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 24

Example: Garden Wildlife

Page 25: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 25

Questions: Parts of Code• consider the following code: Private Sub btnThing_Click()

lblResult.BackColor = vbRed lblResult.Caption = "Testing" End Sub

– name all objects

– name all properties

– name all keywords

– name all events

btnThing, lblResult

BackColor, Caption

Private, Sub, End

Click

Page 26: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 26

Questions: BallChar Code• consider the following code:

– how many event procedures?

– name all properties

– name all objects

– name all events

3

Enabled, Interval, Left

Form, btnGo, tmrBall, picBall

Load, Click, Timer

Option Explicit

Private Sub Form_Load() tmrBall.Enabled = FalseEnd Sub

Private Sub btnGo_Click() tmrBall.Interval = 100 tmrBall.Enabled = TrueEnd Sub

Private Sub tmrBall_Timer() picBall.Left = picBall.Left + 100End Sub

Page 27: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 27

Tutorial Exercise: Ball Char v1• LEARNING OBJECTIVE:

to understand objects, events, properties, and event handler procedures,

• TASK 1: Get the Right button from the Ball Character example working. (code provided, images in resources area on server).

• TASK 2: Get the Left, Down, and Up buttons working.(You will need to work out what code to use. Use the code provided as inspiration)HINT: there isn't a right property, there is a top property

Page 28: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 28

Tutorial Exercise: Ball Char v2• LEARNING OBJECTIVE:

to understand objects, events, properties, and event handler procedures,

• TASK 1: Get Ball Character example v2 (from the lecture) working. (code provided, images in resources area on server).

• TASK 2: Add a button that places the ball character back on the left hand side

• Task 3: Make the ball character blink when clicked

Page 29: Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle

Mark Dixon, SoCCE SOFT 136 Page 29

Tutorial Exercise: Garden• LEARNING OBJECTIVE:

to understand objects, events, properties, and event handler procedures,

• TASK 1: Get the Garden Animals example working. Clinking an image should change the document (page) background colour to something suitable for the animal (e.g. ladybird – red), and display the name of the animal below the images. (no code provided, but images in resources area on server)