slide 1 software development 1. requirement specification 2. analysis 3. algorithm design 4....

45
Slide 1 Software Development Software Development 1. Requirement Specification 1. Requirement Specification 2. Analysis 2. Analysis 3. Algorithm Design 3. Algorithm Design 4. Implementation 4. Implementation 5. Testing 5. Testing 6. Documentation 6. Documentation

Upload: carmel-heath

Post on 02-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 1

Software Development Software Development

1. Requirement Specification1. Requirement Specification2. Analysis2. Analysis

3. Algorithm Design3. Algorithm Design

4. Implementation4. Implementation

5. Testing5. Testing

6. Documentation6. Documentation

Page 2: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 2

1. 1. Requirement SpecificatioRequirement Specificationn The first, but the most important step The first, but the most important step

in the process of problem solvingin the process of problem solving We have to We have to understandunderstand exactly exactly whatwhat

the problem is:-the problem is:- What is needed to solve it ?What is needed to solve it ? What the solution should provide ?What the solution should provide ? Whether there is any Whether there is any constraintsconstraints or or

special conditions ?special conditions ?

Page 3: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 3

1. 1. Requirement SpecificatioRequirement Specification (cont‘d)n (cont‘d) How precisely we can define a How precisely we can define a

problem depends on our problem depends on our degree of degree of familiarityfamiliarity with the problem domain with the problem domain

If we are not familiar with the If we are not familiar with the problem domain, acquire the problem domain, acquire the knowledge the soonestknowledge the soonest

Example : your friend want you to Example : your friend want you to develop a program to calculate his develop a program to calculate his salary taxsalary tax ... ...

Page 4: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 4

1. 1. Requirement SpecificatioRequirement Specification (cont‘d)n (cont‘d) Having acquired the information from the web Having acquired the information from the web

site of HK government, you know that for the site of HK government, you know that for the fiscal Year 2004/2005, the tax of a person is fiscal Year 2004/2005, the tax of a person is calculated on the basis of both (a) and (b):- calculated on the basis of both (a) and (b):- (www.ird.gov.hk(www.ird.gov.hk))

(a) (a) Progressive Tax rateProgressive Tax rate NET Income/Cumulative Rate NET Income/Cumulative Rate

Tax/CumulativeTax/Cumulative First 30,000 2% First 30,000 2%

600 600 Next 30,000Next 30,000 8% 2,400 8% 2,400 Next 30,000 Next 30,000 14% 4,200 14% 4,200 Remainder Remainder 20% 7,200 20% 7,200

Page 5: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 5

1. 1. Requirement SpecificatioRequirement Specification (cont‘d)n (cont‘d) ((b) b) Standard Tax rateStandard Tax rate

which is simple formulaewhich is simple formulae

Tax = Income × 16%Tax = Income × 16% Tax charged by the HK government Tax charged by the HK government

is thus equal to either (a) or (b), is thus equal to either (a) or (b), WHICHEVER LOWERWHICHEVER LOWER

where where Net incomeNet income = Income - Sum = Income - Sum of all entitled allowancesof all entitled allowances

Page 6: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 6

1. 1. Requirement SpecificatioRequirement Specification (cont‘d)n (cont‘d) where the where the allowancesallowances are as follows: are as follows: (i) Basic Personal Allowance(i) Basic Personal Allowance 100,000 100,000 (ii) Dependent (Grand)/Parent Allowance(ii) Dependent (Grand)/Parent Allowance

30,000 per Head30,000 per Head It should be noted that (i) is always It should be noted that (i) is always

entitled; whereas (ii) is determined by the entitled; whereas (ii) is determined by the total no. of Dependent (Grand)/Parents of total no. of Dependent (Grand)/Parents of the taxpayerthe taxpayer

As a simple example, we assume a As a simple example, we assume a constraintconstraint on the problem domain: this on the problem domain: this program is for single taxpayers onlyprogram is for single taxpayers only

Page 7: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 7

1. 1. Requirement SpecificatioRequirement Specification (cont‘d)n (cont‘d) Then we come up with the following Then we come up with the following

requirement specification for our problem:requirement specification for our problem:

(1) A single taxpayer can determine his salary tax by (1) A single taxpayer can determine his salary tax by

calculating his calculating his incomeincome and all entitled and all entitled allowancesallowances;;

(2) After that, his tax is calculated on the basis of (a) (2) After that, his tax is calculated on the basis of (a)

ProgressiveProgressive Tax Rate and (b) Tax Rate and (b) StandardStandard Tax Rate; Tax Rate;

(3) Then the (3) Then the chargeable taxchargeable tax will be either (a) or (b), will be either (a) or (b),

whichever lower.whichever lower.

Page 8: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 8

1. 1. Requirement SpecificatioRequirement Specification (cont‘d)n (cont‘d)We have to develop a program to do the following:We have to develop a program to do the following:

1. Prompt the user to interactively enter his (annual) 1. Prompt the user to interactively enter his (annual) incomeincome * *

2. Prompt the user to interactively enter the no. of 2. Prompt the user to interactively enter the no. of hishis

Dependent (Grand)Dependent (Grand)/Parents/Parents * *

3. Calculate the chargeable 3. Calculate the chargeable taxtax as above mentioned as above mentioned

4. 4. OutputOutput the result including his Income, Net the result including his Income, Net Income, Income,

Progressive Tax, Standard Tax, and Chargeable Progressive Tax, Standard Tax, and Chargeable TaxTax

*subject to validation*subject to validation

Page 9: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 9

2. Analysis2. Analysis

In the analysis phase we should In the analysis phase we should identifyidentify the following: the following:

1. 1. InputsInputs to the problem, their to the problem, their formform and the input and the input mediamedia;;

2. 2. OutputsOutputs from the problem, their from the problem, their form and the input media;form and the input media;

3. Any special 3. Any special constraintsconstraints or or conditions;conditions;

4. 4. FormulasFormulas or equations to be used. or equations to be used.

Page 10: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 10

2. Analysis (cont’d)2. Analysis (cont’d)

For the sample problem, we have the following:For the sample problem, we have the following:1. 1. InputInput -- consists of the income and no. of -- consists of the income and no. of

dependent (grand)/parents. All inputs will be dependent (grand)/parents. All inputs will be interactively captured through the keyboardinteractively captured through the keyboard

2. 2. OutputOutput -- four output items are expected : Net -- four output items are expected : Net Income, Progressive Tax, Standard Tax, and Income, Progressive Tax, Standard Tax, and Chargeable TaxChargeable Tax

3. 3. ConstraintsConstraints -- The program should not accept any -- The program should not accept any input data with values beyond the reasonable input data with values beyond the reasonable range. Generally speaking, the upper limit for range. Generally speaking, the upper limit for income and no. of Dependent (Grand)/Parents income and no. of Dependent (Grand)/Parents should be10,000,000 and 6. For both input data, should be10,000,000 and 6. For both input data, their lower limits are 0.their lower limits are 0.

4. 4. FormulaeFormulae -- given in the requirements specification -- given in the requirements specification

Page 11: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 11

3. Algorithm Design3. Algorithm Design

1. An Algorithm is a 1. An Algorithm is a sequencesequence of a of a finite number of finite number of stepssteps arranged in a arranged in a specific logical order, which, when specific logical order, which, when executed, produce the executed, produce the solutionsolution for a for a problemproblem

2. Alternatively, an algorithm is a 2. Alternatively, an algorithm is a procedureprocedure that takes a set of input that takes a set of input values and TRANSFORMs them into a values and TRANSFORMs them into a set of output valuesset of output values

Page 12: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 12

3. Algorithm Design 3. Algorithm Design (cont’d)(cont’d)

An algorithm must satisfy some An algorithm must satisfy some criteriacriteria::

1. 1. UnambiguousnessUnambiguousness -- Computer cannot cope with -- Computer cannot cope with unambiguousness. Every step in an algorithm unambiguousness. Every step in an algorithm must be clear as to what it is supposed to domust be clear as to what it is supposed to do

2. 2. GeneralityGenerality -- Take inch-to-cm conversion as -- Take inch-to-cm conversion as example; a procedure that can only prints “1 inch example; a procedure that can only prints “1 inch is 2.54 cm” is no algorithm at all !is 2.54 cm” is no algorithm at all !

3. 3. CorrectnessCorrectness -- it must solve correctly the problem -- it must solve correctly the problem for which it is designedfor which it is designed

4. 4. FinitenessFiniteness -- a never-ending algorithm is -- a never-ending algorithm is unacceptableunacceptable

Page 13: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 13

3. Algorithm Design 3. Algorithm Design (cont’d)(cont’d)

1. For a given problem, we have to design an 1. For a given problem, we have to design an algorithm and algorithm and verify its correctnessverify its correctness

2. An algorithm design must be done 2. An algorithm design must be done on paperon paper, not , not just visualise in our mindsjust visualise in our minds

3. Therefore, we should be able to represent and 3. Therefore, we should be able to represent and document our algorithms using an appropriate document our algorithms using an appropriate representation toolrepresentation tool

4. Any 4. Any natural languagenatural language, is no good for representing , is no good for representing algorithms due to their ambiguousnessalgorithms due to their ambiguousness

5. 5. Pseudo-codePseudo-code and and Flow-chartFlow-chart are appropriate tools are appropriate tools for representing algorithmsfor representing algorithms

Page 14: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 14

3.1 Representation of 3.1 Representation of AlgorithmsAlgorithms

On top of designing algorithms, On top of designing algorithms, Pseudo-Pseudo-codecode and and

Flow-chartFlow-chart can be used for can be used for

1. 1. CommunicatingCommunicating algorithms to computer algorithms to computer laymen, e.g. userslaymen, e.g. users

2. 2. ImplementingImplementing algorithms as programs algorithms as programs

3. 3. DebuggingDebugging logic errors in program logic errors in program

4. 4. DocumentingDocumenting programs for future programs for future maintenance and/or expansionmaintenance and/or expansion

Page 15: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 15

3.2 Pseudo-coding3.2 Pseudo-coding

A Pseudo-code language is a A Pseudo-code language is a semiformal, English-like language with semiformal, English-like language with a limited vocabulary that can be used a limited vocabulary that can be used to design and describe algorithmsto design and describe algorithms

Regardless of their complexity, all Regardless of their complexity, all algorithms can be described using only algorithms can be described using only three type of three type of basic control constructsbasic control constructs: :

(1) (1) sequencesequence, (2) , (2) selectionselection, & (3) , & (3) repetitionrepetition

Page 16: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 16

3.2.1 Sequence Control 3.2.1 Sequence Control StructureStructure

The The SequenceSequence Control Structure is a series of steps Control Structure is a series of steps that are that are

executed in the order in which they are written in an executed in the order in which they are written in an algorithm, e.g., in our sample examplealgorithm, e.g., in our sample example

1.1. Read_Annual_IncomeRead_Annual_Income2.2. Read_No_of_ParentsRead_No_of_Parents3.3. Calculate_Net_IncomeCalculate_Net_Income4.4. Calculate_Progressive_TaxCalculate_Progressive_Tax5.5. Calculate_Standard_TaxCalculate_Standard_Tax6.6. Print_Chargeable_TaxPrint_Chargeable_Tax

Page 17: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 17

3.2 .1 Sequence Control 3.2 .1 Sequence Control Structure (cont’d)Structure (cont’d)

It is useful to mark the beginning and end of a block of statement using ‘begin’ and ‘end’.

Statements in the blocks are indented to improve readability, e.g., in the following procedure:

Calculate_Net_IncomeBegin

Parent_Allowance = No_of_Parents×30000Net_Income = Annual_Income -

Parent_AllowanceEnd

Page 18: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 18

3.2.2 The Selection 3.2.2 The Selection Control StructureControl Structure

The The SelectionSelection Control Structure defines two Control Structure defines two courses of action, depending on the outcome of a courses of action, depending on the outcome of a conditioncondition. A condition is an expression that, when . A condition is an expression that, when evaluated, computes to either evaluated, computes to either TRUE or FALSETRUE or FALSE..

The Selection structure requires the use of the The Selection structure requires the use of the keywords keywords ‘‘ifif’’, , ‘‘elseelse’’ and and ‘‘end_ifend_if’’ as in the following as in the following format:format:

ifif <condition> <condition>

then-statements 1,2,3,…then-statements 1,2,3,…

elseelse

else-statements 5,6,7,…else-statements 5,6,7,…

end_ifend_if

Page 19: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 19

3.2.2 The Selection 3.2.2 The Selection Control StructureControl Structure (cont’d) (cont’d)

ifif Progressive_Tax <= Standard_TaxProgressive_Tax <= Standard_Taxbeginbegin

Tax_Payable = Progressive_TaxTax_Payable = Progressive_TaxDisplay Tax _PayableDisplay Tax _Payable

endendelseelse

beginbeginTax _Payable = Standard_TaxTax _Payable = Standard_TaxDisplay Tax _PayableDisplay Tax _Payable

endend

Page 20: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 20

3.2.2 The Selection 3.2.2 The Selection Control StructureControl Structure (cont’d) (cont’d)

IndentationIndentation helps to visually differentiate the helps to visually differentiate the then-statements and else-statements from then-statements and else-statements from those that follow the end_if. those that follow the end_if.

In certain decision-making situations, the In certain decision-making situations, the elseelse--statements may be statements may be missingmissing. The format of the . The format of the selection structure becomes:selection structure becomes:

if <condition>if <condition>then-statementsthen-statements

end_ifend_if

Page 21: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 21

3.2.2 The Selection 3.2.2 The Selection Control StructureControl Structure (cont’d) (cont’d)

This structure means that if the condition is This structure means that if the condition is FALSE, NO ACTION will be taken at all. FALSE, NO ACTION will be taken at all.

The program execution will continue with the The program execution will continue with the statement that follows statement that follows ‘‘end_ifend_if’’..

How about How about more than 2 different possibilitiesmore than 2 different possibilities ? ?

Page 22: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 22

3.2.2 Nested Selection 3.2.2 Nested Selection StructureStructure

The if-else selection structure is useful for The if-else selection structure is useful for 2-way decision-making. When we have 2-way decision-making. When we have more than 2 courses of action, we can use more than 2 courses of action, we can use nested selection structures.nested selection structures.

Consider the calculation of Progressive Tax Consider the calculation of Progressive Tax in our sample example. It can be in our sample example. It can be expressed as pseudo-code which defines 4 expressed as pseudo-code which defines 4 separate courses of actions by nesting the separate courses of actions by nesting the if-else structures to 4 levels:if-else structures to 4 levels:

Page 23: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 23

3.2.2 Nested Selection 3.2.2 Nested Selection Structure Structure (cont’d)(cont’d)

if if Net_income <= 30000Net_income <= 30000

Progressive_Tax = Net_income x 2%Progressive_Tax = Net_income x 2%

else ifelse if Net_income <= 60000 Net_income <= 60000

Progressive_Tax = 600 + (Net_income - 30000) x 8%Progressive_Tax = 600 + (Net_income - 30000) x 8%

else ifelse if Net_income <= 90000 Net_income <= 90000

Progressive_Tax = 3000 + (Net_income - 60000) x Progressive_Tax = 3000 + (Net_income - 60000) x 14%14%

elseelse

Progressive_Tax = 7200 + (Net_income - 90000) x Progressive_Tax = 7200 + (Net_income - 90000) x 20%20%

end_ifend_if

Page 24: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 24

3.2.2 Nested Selection 3.2.2 Nested Selection Structure Structure (cont’d)(cont’d)

Nested Selection StructureNested Selection Structure can be confusing if can be confusing if the nesting is excessively deep.the nesting is excessively deep.

It is possible to express a It is possible to express a multi-way selection multi-way selection structurestructure in a series of independent in a series of independent 2-way 2-way selection structuresselection structures equivalently: equivalently:

ifif Net_income <= 30000 Net_income <= 30000Progressive_Tax = Net_income Progressive_Tax = Net_income 2% 2%

end_ifend_if

Page 25: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 25

3.2.2 Nested Selection 3.2.2 Nested Selection Structure Structure (cont’d)(cont’d)

ifif (Net_income > 30000) (Net_income > 30000) andand (Net_income <= 60000) (Net_income <= 60000)

Progressive_Tax = 600 + (Net_income - 30000) x 8%Progressive_Tax = 600 + (Net_income - 30000) x 8%

end_ifend_if

ifif (Net_income > 60000) (Net_income > 60000) andand (Net_income <= 90000) (Net_income <= 90000)

Progressive_Tax = 3000 + (Net_income - 60000) x Progressive_Tax = 3000 + (Net_income - 60000) x 14%14%

end_ifend_if

ifif Net_income > 90000 Net_income > 90000

Progressive_Tax = 7200 + (Net_income - 90000) x Progressive_Tax = 7200 + (Net_income - 90000) x 20%20%

end_ifend_if

Page 26: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 26

3.2.3 The Repetition 3.2.3 The Repetition Control StructureControl Structure

The The RepetitionRepetition Control Structure specifies a block Control Structure specifies a block of one or more statements that are repeatedly of one or more statements that are repeatedly executed until a condition is satisfied.executed until a condition is satisfied.

Several forms of repetition control structures can Several forms of repetition control structures can be usedbe used

For the time being, we describe only one of them, For the time being, we describe only one of them, viz., the WHILE repetition structure, with the viz., the WHILE repetition structure, with the following format:following format:

whilewhile <condition> <condition>loop-statementsloop-statements

end_whileend_while

Page 27: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 27

3.2.3 The Repetition 3.2.3 The Repetition Control Structure (cont’d)Control Structure (cont’d)

Here the loop-statement(s) will be executed as Here the loop-statement(s) will be executed as long as the <condition> is TRUE.long as the <condition> is TRUE.

The repeated execution of loop-statement(s) The repeated execution of loop-statement(s) terminates when the <condition> becomes FALSE.terminates when the <condition> becomes FALSE.

Obviously, something inside the loop-statement(s) Obviously, something inside the loop-statement(s) must be able to change the <condition> to FALSEmust be able to change the <condition> to FALSE

Otherwise, we will have an infinite loop and the Otherwise, we will have an infinite loop and the algorithm will never terminatealgorithm will never terminate

To use our sample example to illustrate a ‘while’ To use our sample example to illustrate a ‘while’ repetition control structurerepetition control structure

Page 28: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 28

3.2.3 The Repetition 3.2.3 The Repetition Control Structure (cont’d)Control Structure (cont’d)

displaydisplay “Enter your annual income; should “Enter your annual income; should be a positive number”be a positive number”

readread Annual_Income Annual_Income

whilewhile Annual_Income <= 0 Annual_Income <= 0

displaydisplay “Invalid annual income; it “Invalid annual income; it should be a positive number: please should be a positive number: please enter again”enter again”

readread Annual_Income Annual_Income

end_whileend_while

Page 29: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 29

3.2.3 The Repetition 3.2.3 The Repetition Control Structure (cont’d)Control Structure (cont’d)

In this example, the first statement is a display In this example, the first statement is a display statement, which prompt the user for input valuestatement, which prompt the user for input value

The second statement reads that value and stores it The second statement reads that value and stores it in ‘Annual_Income’in ‘Annual_Income’

The condition becomes TRUE if Annual_Income is less The condition becomes TRUE if Annual_Income is less than or equal to 0, then the statements inside the than or equal to 0, then the statements inside the while- loop will be executed one after onewhile- loop will be executed one after one

If the value supplied for Annual_Income is positive, If the value supplied for Annual_Income is positive, the condition becomes FALSE and the algorithm the condition becomes FALSE and the algorithm control will drop down to the statement control will drop down to the statement after’end_while’after’end_while’

Otherwise, the while-loop will be executed once againOtherwise, the while-loop will be executed once again

Page 30: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 30

3.2.4 Pseudo-coding 3.2.4 Pseudo-coding ConventionsConventions

Each pseudo-code statement includes Each pseudo-code statement includes keywordskeywords that describe the operations and operandsthat describe the operations and operands

Input Output : Input Output : Read, Enter, Display, Print, …Read, Enter, Display, Print, … Change values : Change values : Set, Initialise, Add, SubtractSet, Initialise, Add, Subtract, …, , …,

or use or use == with a formulae with a formulae Do not use any unambiguous words such as Do not use any unambiguous words such as

‘handle’, ‘process’, … etc.‘handle’, ‘process’, … etc. Each statement should be written on a Each statement should be written on a separate separate

lineline. If a statement requires more than one line, . If a statement requires more than one line, the continuation lines should be indentedthe continuation lines should be indented

Page 31: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 31

3.3 Flowcharting3.3 Flowcharting

A flowchart is a A flowchart is a graphgraph consisting of geometric consisting of geometric shapesshapes that are that are connected by flow linesconnected by flow lines

The flow lines show the order in which the The flow lines show the order in which the statements are executedstatements are executed

Four geometric shapes are usedFour geometric shapes are used RectangleRectangle represents represents processprocess DiamondDiamond represents represents decisiondecision ParallelogramParallelogram represents represents input or outputinput or output OvalOval represent the represent the startstarting or ing or finishfinishing of the ing of the

algorithmalgorithm

Page 32: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 32

3.3 Flowcharting (cont’d)3.3 Flowcharting (cont’d)

Display Display Chargeable_TaxChargeable_Tax

Progressive_Tax <Progressive_Tax <Standard Tax ?Standard Tax ?

Read Read Annual_IncomeAnnual_Income StartStart

ProcessProcess DecisionDecision

Input or OutputInput or Output TerminalTerminal

Four common symbols used in flowchartsFour common symbols used in flowcharts

Page 33: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 33

3.3 Flowcharting (cont’d)3.3 Flowcharting (cont’d)

Statement 1Statement 1

Statement 2Statement 2

Statement 3Statement 3

SequenceSequence Structure Structure

Page 34: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 34

3.3 Flowcharting (cont’d)3.3 Flowcharting (cont’d)

SelectionSelection Structure Structure

then-then-statement(s) statement(s)

else-else-statement(s)statement(s)

ConditionConditionTrueTrueFalseFalse

Page 35: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 35

3.3 Flowcharting (cont’d)3.3 Flowcharting (cont’d)

RepetitionRepetition Structure Structure

Loop-Loop-statement(s) statement(s)

ConditionConditionTrueTrue

FalseFalse

Page 36: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 36

3.4 3.4 Pseudo-coding Vs Flow-Pseudo-coding Vs Flow-chartingcharting

Pseudo-coding Flow-charting

Nature Verbal Graphical

Vocabulary Unlimited Limited

Size Reasonable Typically Large

Preparation Effort

Reasonable Typically Heavy

Distinctive Feature

Detail of Operation

Flow of Control

Page 37: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 37

4. Implementation4. Implementation

Translate each step of the Translate each step of the AlgorithmAlgorithm into a statement in a programming into a statement in a programming language and end up with a language and end up with a Computer Computer ProgramProgram;;

Definition — a Computer Program is a Definition — a Computer Program is a sequence of statementssequence of statements expressed in a expressed in a programming language in a specific programming language in a specific order that, when executed, produce order that, when executed, produce the solution for a problem.the solution for a problem.

Page 38: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 38

4.1 Implementation — 4.1 Implementation — Programming ErrorsProgramming Errors

Three types of programming Three types of programming errorserrors:: Design errorsDesign errors — may occur because — may occur because

(i) an incorrect algorithm is chosen; or (i) an incorrect algorithm is chosen; or (ii) mistakes are made in translating an (ii) mistakes are made in translating an algorithm into a program; or algorithm into a program; or (iii) erroneous data is designed for the (iii) erroneous data is designed for the program. program.

Design errors can be removed by Design errors can be removed by careful review of problem analysis, careful review of problem analysis, program design, translation, and test program design, translation, and test data.data.

Page 39: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 39

4.2 Implementation — 4.2 Implementation — Programming Errors Programming Errors (cont’d)(cont’d)

Compilation errorsCompilation errors — occurred during — occurred during implementation phase and are detected implementation phase and are detected by the compiler; by the compiler;

Compilation errors are violations of Compilation errors are violations of syntax rules, hence a.k.a. syntax rules, hence a.k.a. Syntax errorsSyntax errors. .

Depending on how serious the violation Depending on how serious the violation is, the compiler issues diagnostic is, the compiler issues diagnostic message which may be eithermessage which may be either

(i) (i) WarningWarning messages or (ii) messages or (ii) ErrorError messages.messages.

Page 40: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 40

4.3 Implementation — 4.3 Implementation — Programming Errors Programming Errors (cont’d)(cont’d)

Run-time errorsRun-time errors — detected by the — detected by the computer while the program is being computer while the program is being executed. They are caused by program executed. They are caused by program statements that require the computer to statements that require the computer to do something illegal.do something illegal.

For example, attempting to For example, attempting to store store inappropriate datainappropriate data or or divide a number divide a number by zeroby zero..

Page 41: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 41

5. Testing5. Testing

Program TestingProgram Testing is the process of executing a is the process of executing a program to demonstrate its program to demonstrate its correctnesscorrectness

A program must be tested using a sufficiently A program must be tested using a sufficiently large sample of carefully designed large sample of carefully designed test data test data setssets such that every such that every logical pathlogical path in the in the program is traversed at least onceprogram is traversed at least once

In our example, we should test the algorithm In our example, we should test the algorithm with Net_Income = 0, 30000, 30001, 60000, with Net_Income = 0, 30000, 30001, 60000, 60001, 90000, and 90001.60001, 90000, and 90001.

Page 42: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 42

6. Documentation6. Documentation

Now we have a workable, fully tested program, Now we have a workable, fully tested program, but we still have to document it because:but we still have to document it because:

1. You may return to this program in the future 1. You may return to this program in the future to use the whole of a part of it again;to use the whole of a part of it again;

2. Other programmer of end-user will need 2. Other programmer of end-user will need some information about your program some information about your program for for referencereference or or maintenancemaintenance;;

3. You may someday have to 3. You may someday have to modifymodify the the program, or may discover some errors in program, or may discover some errors in your program.your program.

Page 43: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 43

6. Documentation (cont’d)6. Documentation (cont’d)

Program documentation consists of:-Program documentation consists of:- Concise Concise requirementrequirement specification; specification; Description of Description of Input/OutputInput/Output, ,

ConstraintsConstraints, Formula, etc.;, Formula, etc.; Pseudo-code or Flowchart of the Pseudo-code or Flowchart of the

algorithmalgorithm;; Source program listingSource program listing;; Hardcopy of Hardcopy of sample test runsample test run..

Page 44: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 44

Unit 2 Lecture : SummaryUnit 2 Lecture : Summary

The method used for Problem Solving with cThe method used for Problem Solving with computers is the Software Development Methomputers is the Software Development Method, which consists of:od, which consists of:

(1)(1) Requirement Specification; Requirement Specification; (2)(2) Analysis; Analysis; (3)(3) Algorithm Design; Algorithm Design; (4)(4) Implementation; Implementation; (5)(5) Testing; and Testing; and (6)(6) Documentation. Documentation. Now you are able to solve problems starting fNow you are able to solve problems starting f

rom specifying the requirement, analyse therom specifying the requirement, analyse them, and design algorithms using pseudocode m, and design algorithms using pseudocode and flowcharts.and flowcharts.

Page 45: Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation

Slide 45

Unit 2 Lecture : Summary Unit 2 Lecture : Summary (cont‘d)(cont‘d)

SoftwareSoftwareDevelopmentDevelopment

MethodMethod

RequirementRequirementSpecificationSpecification

AnalysisAnalysis

AlgorithmAlgorithmDesignDesign

ImplementationImplementation

TestingTesting

DocumentationDocumentation

Pseudo-Pseudo-codecode

Flow-chartFlow-chart