1 / 45

Software Development

Software Development. 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation. 1. Requirement Specification. The first, but the most important step in the process of problem solving We have to understand exactly what the problem is:-

damara
Download Presentation

Software Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 1. Requirement Specification • The first, but the most important step in the process of problem solving • We have to understand exactly what the problem is:- • What is needed to solve it ? • What the solution should provide ? • Whether there is any constraints or special conditions ?

  3. 1. Requirement Specification (cont‘d) • How precisely we can define a problem depends on our degree of familiarity with the problem domain • If we are not familiar with the problem domain, acquire the knowledge the soonest • Example : your friend want you to develop a program to calculate his salary tax ...

  4. 1. Requirement Specification (cont‘d) • Having acquired the information from the web site of HK government, you know that for the fiscal Year 2004/2005, the tax of a person is calculated on the basis of both (a) and (b):- (www.ird.gov.hk) • (a) Progressive Tax rate NET Income/Cumulative Rate Tax/Cumulative First 30,000 2% 600 Next 30,000 8% 2,400 Next 30,000 14% 4,200 Remainder 20% 7,200

  5. 1. Requirement Specification (cont‘d) • (b) Standard Tax rate which is simple formulae Tax = Income × 16% • Tax charged by the HK government is thus equal to either (a) or (b), WHICHEVER LOWER • where Net income = Income - Sum of all entitled allowances

  6. 1. Requirement Specification (cont‘d) • where the allowances are as follows: (i) Basic Personal Allowance 100,000 (ii) Dependent (Grand)/Parent Allowance 30,000 per Head • It should be noted that (i) is always entitled; whereas (ii) is determined by the total no. of Dependent (Grand)/Parents of the taxpayer • As a simple example, we assume a constraint on the problem domain: this program is for single taxpayers only

  7. 1. Requirement Specification (cont‘d) • Then we come up with the following requirement specification for our problem: (1) A single taxpayer can determine his salary tax by calculating his income and all entitled allowances; (2) After that, his tax is calculated on the basis of (a) Progressive Tax Rate and (b) Standard Tax Rate; (3) Then the chargeable tax will be either (a) or (b), whichever lower.

  8. 1. Requirement Specification (cont‘d) We have to develop a program to do the following: 1. Prompt the user to interactively enter his (annual) income * 2. Prompt the user to interactively enter the no. of his Dependent (Grand)/Parents * 3. Calculate the chargeable tax as above mentioned 4. Output the result including his Income, Net Income, Progressive Tax, Standard Tax, and Chargeable Tax *subject to validation

  9. 2. Analysis In the analysis phase we should identify the following: 1. Inputs to the problem, their form and the input media; 2. Outputs from the problem, their form and the input media; 3. Any special constraints or conditions; 4. Formulas or equations to be used.

  10. 2. Analysis (cont’d) For the sample problem, we have the following: 1. Input -- consists of the income and no. of dependent (grand)/parents. All inputs will be interactively captured through the keyboard 2. Output -- four output items are expected : Net Income, Progressive Tax, Standard Tax, and Chargeable Tax 3. Constraints -- The program should not accept any input data with values beyond the reasonable range. Generally speaking, the upper limit for income and no. of Dependent (Grand)/Parents should be10,000,000 and 6. For both input data, their lower limits are 0. 4. Formulae -- given in the requirements specification

  11. 3. Algorithm Design 1. An Algorithm is a sequence of a finite number of steps arranged in a specific logical order, which, when executed, produce the solution for a problem 2. Alternatively, an algorithm is a procedure that takes a set of input values and TRANSFORMs them into a set of output values

  12. 3. Algorithm Design (cont’d) An algorithm must satisfy some criteria: 1. Unambiguousness -- Computer cannot cope with unambiguousness. Every step in an algorithm must be clear as to what it is supposed to do 2. Generality -- Take inch-to-cm conversion as example; a procedure that can only prints “1 inch is 2.54 cm” is no algorithm at all ! 3. Correctness -- it must solve correctly the problem for which it is designed 4. Finiteness -- a never-ending algorithm is unacceptable

  13. 3. Algorithm Design (cont’d) 1. For a given problem, we have to design an algorithm and verify its correctness 2. An algorithm design must be done on paper, not just visualise in our minds 3. Therefore, we should be able to represent and document our algorithms using an appropriate representation tool 4. Any natural language, is no good for representing algorithms due to their ambiguousness 5. Pseudo-code and Flow-chart are appropriate tools for representing algorithms

  14. 3.1 Representation of Algorithms On top of designing algorithms, Pseudo-code and Flow-chart can be used for 1. Communicating algorithms to computer laymen, e.g. users 2. Implementing algorithms as programs 3. Debugging logic errors in program 4. Documenting programs for future maintenance and/or expansion

  15. 3.2 Pseudo-coding • A Pseudo-code language is a semiformal, English-like language with a limited vocabulary that can be used to design and describe algorithms • Regardless of their complexity, all algorithms can be described using only three type of basic control constructs: • (1) sequence, (2) selection, & (3) repetition

  16. 3.2.1 Sequence Control Structure The Sequence Control Structure is a series of steps that are executed in the order in which they are written in an algorithm, e.g., in our sample example • Read_Annual_Income • Read_No_of_Parents • Calculate_Net_Income • Calculate_Progressive_Tax • Calculate_Standard_Tax • Print_Chargeable_Tax

  17. 3.2 .1 Sequence Control 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_Income Begin Parent_Allowance = No_of_Parents×30000 Net_Income = Annual_Income - Parent_Allowance End

  18. 3.2.2 The Selection Control Structure • The Selection Control Structure defines two courses of action, depending on the outcome of a condition. A condition is an expression that, when evaluated, computes to either TRUE or FALSE. • The Selection structure requires the use of the keywords ‘if’, ‘else’ and ‘end_if’ as in the following format: if <condition> then-statements 1,2,3,… else else-statements 5,6,7,… end_if

  19. 3.2.2 The Selection Control Structure (cont’d) ifProgressive_Tax <= Standard_Tax begin Tax_Payable = Progressive_Tax Display Tax _Payable end else begin Tax _Payable = Standard_Tax Display Tax _Payable end

  20. 3.2.2 The Selection Control Structure (cont’d) • Indentation helps to visually differentiate the then-statements and else-statements from those that follow the end_if. • In certain decision-making situations, the else-statements may be missing. The format of the selection structure becomes: if <condition> then-statements end_if

  21. 3.2.2 The Selection Control Structure (cont’d) • This structure means that if the condition is FALSE, NO ACTION will be taken at all. • The program execution will continue with the statement that follows ‘end_if’. • How about more than 2 different possibilities ?

  22. 3.2.2 Nested Selection Structure • The if-else selection structure is useful for 2-way decision-making. When we have more than 2 courses of action, we can use nested selection structures. • Consider the calculation of Progressive Tax in our sample example. It can be expressed as pseudo-code which defines 4 separate courses of actions by nesting the if-else structures to 4 levels:

  23. 3.2.2 Nested Selection Structure (cont’d) if Net_income <= 30000 Progressive_Tax = Net_income x 2% else if Net_income <= 60000 Progressive_Tax = 600 + (Net_income - 30000) x 8% else if Net_income <= 90000 Progressive_Tax = 3000 + (Net_income - 60000) x 14% else Progressive_Tax = 7200 + (Net_income - 90000) x 20% end_if

  24. 3.2.2 Nested Selection Structure (cont’d) • Nested Selection Structure can be confusing if the nesting is excessively deep. • It is possible to express a multi-way selection structure in a series of independent 2-way selection structures equivalently: if Net_income <= 30000 Progressive_Tax = Net_income  2% end_if

  25. 3.2.2 Nested Selection Structure (cont’d) if (Net_income > 30000) and (Net_income <= 60000) Progressive_Tax = 600 + (Net_income - 30000) x 8% end_if if (Net_income > 60000) and (Net_income <= 90000) Progressive_Tax = 3000 + (Net_income - 60000) x 14% end_if if Net_income > 90000 Progressive_Tax = 7200 + (Net_income - 90000) x 20% end_if

  26. 3.2.3 The Repetition Control Structure • The Repetition Control Structure specifies a block of one or more statements that are repeatedly executed until a condition is satisfied. • Several forms of repetition control structures can be used • For the time being, we describe only one of them, viz., the WHILE repetition structure, with the following format: while <condition> loop-statements end_while

  27. 3.2.3 The Repetition Control Structure (cont’d) • Here the loop-statement(s) will be executed as long as the <condition> is TRUE. • The repeated execution of loop-statement(s) terminates when the <condition> becomes FALSE. • Obviously, something inside the loop-statement(s) must be able to change the <condition> to FALSE • Otherwise, we will have an infinite loop and the algorithm will never terminate • To use our sample example to illustrate a ‘while’ repetition control structure

  28. 3.2.3 The Repetition Control Structure (cont’d) display “Enter your annual income; should be a positive number” read Annual_Income while Annual_Income <= 0 display “Invalid annual income; it should be a positive number: please enter again” read Annual_Income end_while

  29. 3.2.3 The Repetition Control Structure (cont’d) • In this example, the first statement is a display statement, which prompt the user for input value • The second statement reads that value and stores it in ‘Annual_Income’ • The condition becomes TRUE if Annual_Income is less than or equal to 0, then the statements inside the while- loop will be executed one after one • If the value supplied for Annual_Income is positive, the condition becomes FALSE and the algorithm control will drop down to the statement after’end_while’ • Otherwise, the while-loop will be executed once again

  30. 3.2.4 Pseudo-coding Conventions • Each pseudo-code statement includes keywords that describe the operations and operands • Input Output : Read, Enter, Display, Print, … • Change values : Set, Initialise, Add, Subtract, …, or use = with a formulae • Do not use any unambiguous words such as ‘handle’, ‘process’, … etc. • Each statement should be written on a separate line. If a statement requires more than one line, the continuation lines should be indented

  31. 3.3 Flowcharting • A flowchart is a graph consisting of geometric shapes that are connected by flow lines • The flow lines show the order in which the statements are executed • Four geometric shapes are used • Rectangle represents process • Diamond represents decision • Parallelogram represents input or output • Oval represent the starting or finishing of the algorithm

  32. 3.3 Flowcharting (cont’d) Display Chargeable_Tax Progressive_Tax < Standard Tax ? Process Decision Read Annual_Income Start Input or Output Terminal Four common symbols used in flowcharts

  33. 3.3 Flowcharting (cont’d) Sequence Structure Statement 1 Statement 2 Statement 3

  34. 3.3 Flowcharting (cont’d) Selection Structure Condition False True else- statement(s) then- statement(s)

  35. 3.3 Flowcharting (cont’d) Repetition Structure Condition Loop- statement(s) True False

  36. 3.4 Pseudo-coding Vs Flow-charting

  37. 4. Implementation • Translate each step of the Algorithm into a statement in a programming language and end up with a Computer Program; • Definition — a Computer Program is a sequence of statements expressed in a programming language in a specific order that, when executed, produce the solution for a problem.

  38. 4.1 Implementation — Programming Errors • Three types of programming errors: • Design errors — may occur because (i) an incorrect algorithm is chosen; or (ii) mistakes are made in translating an algorithm into a program; or (iii) erroneous data is designed for the program. • Design errors can be removed by careful review of problem analysis, program design, translation, and test data.

  39. 4.2 Implementation — Programming Errors (cont’d) • Compilation errors — occurred during implementation phase and are detected by the compiler; • Compilation errors are violations of syntax rules, hence a.k.a. Syntax errors. • Depending on how serious the violation is, the compiler issues diagnostic message which may be either • (i) Warning messages or (ii) Error messages.

  40. 4.3 Implementation — Programming Errors (cont’d) • Run-time errors — detected by the computer while the program is being executed. They are caused by program statements that require the computer to do something illegal. • For example, attempting to store inappropriate data or divide a number by zero.

  41. 5. Testing • Program Testing is the process of executing a program to demonstrate its correctness • A program must be tested using a sufficiently large sample of carefully designed test data sets such that every logical path in the program is traversed at least once • In our example, we should test the algorithm with Net_Income = 0, 30000, 30001, 60000, 60001, 90000, and 90001.

  42. 6. Documentation Now we have a workable, fully tested program, but we still have to document it because: 1. You may return to this program in the future to use the whole of a part of it again; 2. Other programmer of end-user will need some information about your program for reference or maintenance; 3. You may someday have to modify the program, or may discover some errors in your program.

  43. 6. Documentation (cont’d) Program documentation consists of:- • Concise requirement specification; • Description of Input/Output, Constraints, Formula, etc.; • Pseudo-code or Flowchart of the algorithm; • Source program listing; • Hardcopy of sample test run.

  44. Unit 2 Lecture : Summary • The method used for Problem Solving with computers is the Software Development Method, which consists of: • (1) Requirement Specification; (2) Analysis; • (3) Algorithm Design; (4) Implementation; • (5) Testing; and (6) Documentation. • Now you are able to solve problems starting from specifying the requirement, analyse them, and design algorithms using pseudocode and flowcharts.

  45. Unit 2 Lecture : Summary (cont‘d) Requirement Specification Pseudo- code Analysis Software Development Method Algorithm Design Flow-chart Implementation Testing Documentation

More Related