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

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

Chapter 2: Problem Solving
Chapter 2: Problem Solving
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
INTRODUCTION TO PROGRAMMING
ITEC113 Algorithms and Programming Techniques
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Programming Fundamentals (750113) Ch1. Problem Solving
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Pseudocode.
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
PRE-PROGRAMMING PHASE
1 L07SoftwareDevelopmentMethod.pptCMSC 104, Version 8/06 Software Development Method Topics l Software Development Life Cycle Reading l Section 1.4 – 1.5.
Chapter 2: Problem Solving
CSEB114: PRINCIPLE OF PROGRAMMING Chapter 2: Problem Solving.
Chapter 2: Problem Solving
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CMSC 1041 Algorithms II Software Development Life-Cycle.
Module 4 Part 1 Introduction To Software Development : Systems Analysis & Design Introduction To Software Development : Systems Analysis & Design.
กระบวนการแก้ปัญหาด้วย คอมพิวเตอร์ 3 พฤษภาคม :00-17:00.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
PROGRAMMING PAPER 2 AS Algorithms.
ITEC113 Algorithms and Programming Techniques
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
Principles of Programming - NI July Chapter 2: Problem Solving In this chapter you will learn about: Introduction to Problem Solving Software development.
1 Program Planning and Design Important stages before actual program is written.
 In this chapter you will learn about:  Introduction to Problem Solving  Software development method (SDM)  Specification of needs  Problem analysis.
CSEB114: Principle of programming
The Hashemite University Computer Engineering Department
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Programming Fundamentals Introduction to Problem Solving  Programming is a problem solving activity. When you write a program, you are actually writing.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
ALGORITHMS AND FLOWCHARTS
Algorithms II Software Development Life-Cycle.
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
ALGORITHMS AND FLOWCHARTS
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Algorithms and Flowcharts
Lecture 2 Introduction to Programming
Programming Problem steps must be able to be fully & unambiguously described Problem types; Can be clearly described Cannot be clearly described (e.g.
Introduction to Computer Programming
Programming Fundamentals
2008/09/24: Lecture 6b CMSC 104, Section 0101 John Y. Park
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Problem Solving Techniques
Structured Program
Programming Fundamentals (750113) Ch1. Problem Solving
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Understanding Problems and how to Solve them by using Computers
Programming Fundamentals (750113) Ch1. Problem Solving
Boolean Expressions to Make Comparisons
Programming Fundamentals (750113) Ch1. Problem Solving
Basic Concepts of Algorithm
CHAPTER 6 Testing and Debugging.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

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

Slide 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 ?

Slide 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...

Slide 4 1. Requirement Specification (cont‘d) b 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):- ( b (a) Progressive Tax rate NET Income/Cumulative Rate Tax/Cumulative NET Income/Cumulative Rate Tax/Cumulative First 30,000 2% 600 First 30,000 2% 600 Next 30,000 8% 2,400 Next 30,000 8% 2,400 Next 30,000 14% 4,200 Next 30,000 14% 4,200 Remainder 20% 7,200 Remainder 20% 7,200

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

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

Slide 7 1. Requirement Specification (cont‘d) b Then we come up with the following 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 income and all entitled allowances; calculating his income and all entitled allowances; (2) After that, his tax is calculated on the basis of (a) (2) After that, his tax is calculated on the basis of (a) Progressive Tax Rate and (b) Standard Tax Rate; Progressive Tax Rate and (b) Standard Tax Rate; (3) Then the chargeable tax will be either (a) or (b), (3) Then the chargeable tax will be either (a) or (b), whichever lower. whichever lower.

Slide 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 * 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 Progressive Tax, Standard Tax, and Chargeable Tax *subject to validation

Slide 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.

Slide 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 Formulae -- given in the requirements specification

Slide 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

Slide 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

Slide 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

Slide 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

Slide 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

Slide 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 1. Read_Annual_Income 2. Read_No_of_Parents 3. Calculate_Net_Income 4. Calculate_Progressive_Tax 5. Calculate_Standard_Tax 6. Print_Chargeable_Tax

Slide Sequence Control Structure (cont’d) b b It is useful to mark the beginning and end of a block of statement using ‘begin’ and ‘end’. b b 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

Slide The Selection Control Structure b 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 if then-statements 1,2,3,… else else-statements 5,6,7,… end_if

Slide The Selection Control Structure (cont’d) if Progressive_Tax <= Standard_Tax begin Tax_Payable = Progressive_Tax Display Tax _Payable endelsebegin Tax _Payable = Standard_Tax Display Tax _Payable end

Slide 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 then-statements end_if

Slide The Selection Control Structure (cont’d) b 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’. b How about more than 2 different possibilities ?

Slide Nested Selection Structure b 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. b 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:

Slide Nested Selection Structure (cont’d) if Net_income <= Progressive_Tax = Net_income x 2% else if Net_income <= Progressive_Tax = (Net_income ) x 8% else if Net_income <= Progressive_Tax = (Net_income ) x 14% else Progressive_Tax = (Net_income ) x 20% end_if

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

Slide Nested Selection Structure (cont’d) if (Net_income > 30000) and (Net_income 30000) and (Net_income <= 60000) Progressive_Tax = (Net_income ) x 8% end_if if (Net_income > 60000) and (Net_income 60000) and (Net_income <= 90000) Progressive_Tax = (Net_income ) x 14% end_if if Net_income > Progressive_Tax = (Net_income ) x 20% end_if

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

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

Slide 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

Slide The Repetition Control Structure (cont’d) b In this example, the first statement is a display statement, which prompt the user for input value b The second statement reads that value and stores it in ‘Annual_Income’ b 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 b 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’ b Otherwise, the while-loop will be executed once again

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

Slide Flowcharting b A flowchart is a graph consisting of geometric shapes that are connected by flow lines b The flow lines show the order in which the statements are executed b 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

Slide Flowcharting (cont’d) DisplayChargeable_Tax Progressive_Tax < Standard Tax ? ReadAnnual_Income Start ProcessDecision Input or Output Terminal Four common symbols used in flowcharts

Slide Flowcharting (cont’d) Statement 1 Statement 2 Statement 3 Sequence Structure

Slide Flowcharting (cont’d) Selection Structure then-statement(s)else-statement(s) Condition TrueFalse

Slide Flowcharting (cont’d) Repetition Structure Loop-statement(s) Condition True False

Slide Pseudo-coding Vs Flow-charting

Slide Implementation b Translate each step of the Algorithm into a statement in a programming language and end up with a Computer Program; b 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.

Slide Implementation — Programming Errors b 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.

Slide 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.

Slide Implementation — Programming Errors (cont’d) b 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. b For example, attempting to store inappropriate data or divide a number by zero.

Slide 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

Slide 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.

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

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

Slide 45 Unit 2 Lecture : Summary (cont‘d) SoftwareDevelopmentMethod RequirementSpecification Analysis AlgorithmDesign Implementation Testing Documentation Pseudo-code Flow-chart