Algorithms II Software Development LifeCycle CMSC 104 Peter
























- Slides: 24
Algorithms II Software Development Life-Cycle CMSC 104: Peter Olsen, Fall 99 Lecture 8: 1
Problem Solving • Problem solving is the process of transforming the description of a problem into the solution of that problem by using our knowledge of the problem domain and by relying on our ability to select and use appropriate problemsolving strategies, techniques, and tools. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 2
Problem Solving Environment Problem CMSC 104: Peter Olsen, Fall 99 Problem Solving Procedure Solution Lecture 8: 3
Problem Solving Input Solution Output A solution is anything that connects the input to the output. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 4
Why Use Computers • Use a computer to solve a problem if: – It has extensive input. – It has extensive output. – Its method of solution is too complicated to implement manually. – If done manually, it takes an excessively long time to solve. – We expect to use the same method often. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 5
Software Development Life Cycle • • Requirements specification Analysis Design Implementation Testing and verification Documentation Maintenance and Enhancement CMSC 104: Peter Olsen, Fall 99 Lecture 8: 6
Sample Problem: Quik. Tax Customer: Quik. Tax, a local tax preparation service. l Task: “Develop a program to calculate Federal Tax from the Federal Tax Schedules for the 1999 tax year. ” l CMSC 104: Peter Olsen, Fall 99 Lecture 8: 7
Requirements Specifications “If you don’t know where you’re going, then any road will take you there. l Critical Questions: l o What is the current situation? o What is the desired situation? o What constraints limit possible solutions? o What special conditions must be met? l Goal: complete understanding of problem space and solution space. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 8
Quik. Tax Requirements l Inputs: o Taxpayer income (wages, interest, etc) o Schedule data. l Output: o Tax payment (on form? backup data? ) Constraints: ? l Special Conditions: l o April 15? o Refunds? o Earned Income Credit? CMSC 104: Peter Olsen, Fall 99 Lecture 8: 9
Analysis • In this phase we identify: – Specific inputs and their forms – Specific outputs expected from and their forms – Special Constraints – Assumptions – Formulas CMSC 104: Peter Olsen, Fall 99 Lecture 8: 10
Inputs • What items must be provided to be able to get a solution? – Taxable income $0. 00 to $1, 000, 000. 00 (+? ) – Filing status: S/M, Head of household – Number of dependents: 1 - 99? – Dividends, interest, capital gains? – Deductions, adjustments, … ? CMSC 104: Peter Olsen, Fall 99 Lecture 8: 11
Output • Intermediate results • All calculations? • Final results • Completed forms: • 1040 • Schedules A, B, C, . . ? • Estimated Tax • Working papers and justification? CMSC 104: Peter Olsen, Fall 99 Lecture 8: 12
Constraints • What are the limits on the data? – Income can not be negative. – Number of dependents usually one or more (may be zero). Is there a maximum? – Filing status must be one of a set of values CMSC 104: Peter Olsen, Fall 99 Lecture 8: 13
Assumptions Problem deals in $US l What’s implied by the Requirements? l CMSC 104: Peter Olsen, Fall 99 Lecture 8: 14
Formulas • For income tax, it is the tax tables and accessory formulas. • For determining the area, it is length x width • For grades, it is: >90. 0% A 80. 0% - 89. 99% B 70. 0% - 79. 99% C 60. 0% - 69. 99% D >60. 0% F CMSC 104: Peter Olsen, Fall 99 Lecture 8: 15
Design • Develop a series of steps with a logical order which, when applied to the input would produce the specified output. (does this sound like an ALGORITHM? ) • This phase is when you think about how to solve the problem!! • This phase can take forty per cent of the effort. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 16
Design for Maintenance and Enhancement l Identify and separate critical data: o Use names: RATE = 0. 18 � use TAX = net_income * RATE � not TAX = net_income * 0. 18 l Functional Decomposition: Identify and group critical functions o o Taxpayer ID functions Dependent and deduction calculations Special Forms Final Tax obligation Many valid alternative decompositions. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 17
Implementation • This is the phase where the design is transformed into code. • This is the only portion of the process that is computer and compiler specific. • This should be approximately ten per cent of the effort. “Design at the Keyboard” is not design. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 18
Implementation Errors • Design errors • Design can’t be implemented • Matrices too large, not enough precision, … • Syntax errors • Incorrect language forms • Run-time errors • Arithmetic errors • Unanticipated input CMSC 104: Peter Olsen, Fall 99 Lecture 8: 19
Testing and Verification • Once the code is developed: – Demonstrate the program produces correct results. – Demonstrate that the program that was built solves the problem that was described in the requirements specification. • Manually solve the problem with a data set, then compare that to the program’s output • Construct an alternate computer solution for special easy-to-implement cases. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 20
Documentation • Consists of – A concise requirements specification – Description of inputs, outputs, constraints, and formulas used – Pseudocode or flowchart of the algorithm – Source code listing – Hard copy of a sample of data and the output – User’s guide explaining how to use the program Documentation should be a complete explanation of code as implemented. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 21
Maintenance and Enhancement • Environments change, so programs must be changed – Tax tables change – Name of organization changes • Users want (or need) the program to do more – New tax credits – Elimination of old tax credits. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 22
Design for Maintenance and Enhancement l Identify and separate critical data: o Use names: RATE = 0. 18 � use TAX = net_income * RATE � not TAX = net_income * 0. 18 l Changes are easier/Less chance of error o Data is in one place/one changes all l Easier to understand. o RATE -vs- 0. 18 CMSC 104: Peter Olsen, Fall 99 Lecture 8: 23
Design for Maintenance and Enhancement l Functional Decomposition: Identify and group critical functions o o l l Taxpayer ID functions Dependent and deduction calculations Special Forms Final Tax obligation Easier to find and identify code to change. Effects limited to local area. CMSC 104: Peter Olsen, Fall 99 Lecture 8: 24