26.The Software Development Process, case study

There is much more to programming than writing lines of code.Computer Engineers refer to the process of planning and organizing a program as Software Development. There are several approaches to software development.One version is known as the waterfall model.
The waterfall model consists of several phases:
1.Customer request:In this phase, the programmer receives a broad statement a problem to be solved. This is the user requirement specification phase.
2.Analysis: Determines what the program will do. This is viewed as the process of clarifying the specification for the problem.
3.Design: Determines how the program will do the task
4.Implementation: The programmers write the program. This step is also called coding phase.
5.Integration: Large programs have many parts.In the integration phase, these parts are brought together into a smoothly functioning system as a whole.
6. Maintenance:Programs usually have a long life, a span of 5-15 years is common.During this time, requirements change, errors are detected and minor or major modifications are made.

It is noted that in waterfall model, each phase flow down to the next.However a mistake detected in one phase often requires the developer to back up and redo some of the work in the previous phase.Modifications made during the maintenance phase also require backing up to earlier phases.Taken together these phases are also called software development life cycle.The following figure shows the waterfall model 




Although the diagram depicts distinct phases, this does not mean that developers must analyse and design a complete system before coding it.Modern software development is usually incremental and iterative.
The cost of developing software is not spread equally over the phases.Maintenance is the most expensive part of software development. The cost of maintenance can be reduced by careful analysis, design and implementation.

Remember the two key points
  • there is more to software development than writing codes
  • if you want to reduce the overall cost of software development, write programs that are easy to maintain. This requires thorough analysis, careful design and good coding style.
Case Study: Income Tax Calculator

This case study develops a program that calculates income tax.

Request:
The customer requests a program that computes a person's income tax.

Analysis:
Analysis often requires the programmer to learn something about the problem domain. In this case, the tax law.
  • All employers are charged a flat tax rate of 20%.
  • All taxpayers are allowed a $10,000 standard deduction.
  • For each dependent, a taxpayer is allowed an additional $30,000 deduction.
  • Gross Income must be entered to the nearest penny.
  • The income tax is expressed as a decimal number.
Another part of the analysis determines what information the user will have to provide. In this case, the user inputs are gross income and number of dependents. The program calculates the income tax based on the inputs and the tax law and then displays the income tax.
Eg:
Enter the gross income: 150000.00
Enter the number of dependents: 3
The income tax is $26200.00

Design
During analysis we specify what a program is going to do.In the design phase we describe how the program is going to do it.This usually involves writing an algorithm.Algorithms are written in pseudocode. Here is the pseudo code for our income tax program.

Input the gross income and number of dependents
Compute the taxable income using the formula
taxable income= gross income- 10000-(3000* number of dependents)
Compute the tax using the formula
tax= taxable income * 0.20
print the tax

Although there are no precise rules governing the syntax of pseudocode, in your pseudocode you should strive to describe the essential elements of the program in a clear and concise manner.

Implementation (Coding)
Given the preceding pseudocode, an experienced programmer now find it easy to write the corresponding Python program.
'''
Program:taxform.py
Author: Dr Binu V P
Cumpute a person's income tax.
1.Significant constants
    tax rate
    standard deduction
    deduction per dependent
2.The inputs are
    gross income
    number of dependents
3.Computations
    taxable income= gross income - the standard deduction - a deduction for each dependent
    income tax= is a fixed percentage of the taxable income
4.The output are
    the income tax
'''
#initialize the constants
TAX_RATE=0.20
STANDARD_DEDUCTION=10000.0
DEPENDENT_DEDUCTION=3000.0

#request the inputs
grossIncome=float(input("Enter the gross income"))
numDependents=int(input(Enter the number of dependents:"))

#compute the income tax
taxableIncome=grossIncome-STANDARD_DEDUCTION-DEPENDENT_DEDUCTION*numDependents
incomeTax=taxableIncome * TAX_RATE

#Display the income tax
print("The income tax is $",incomeTax)

Testing
If there are no syntax errors, we will be able to enter a set of inputs and view the results. However a single run without syntax errors and with correct outputs provides just a slight indication of a program's correctness.Only through testing can build confidence that a program is working correctly.

Testing is a deliberate process that requires some planning and discipline on the programmers part.The program must be tested for different kind of inputs.The real challenge is coming up with sets of inputs that can reveal an error.An error at this point is also called logic error or design error, is an unexpected output.A correct program produces the expected output for any legitimate input.Testing all of the possible combinations of inputs would be impractical.The challenge is to find a smaller set of inputs called a test suite, from which we can conclude that the program will likely to be correct for all inputs.
In the tax program we try number of dependents 0,1,2. The test input for the gross income are number equal standard deduction and a number twice that amount 10000 and 20000 respectively. These two values shows the cases of a minimum expected tax(0) and expected taxes that are less than or greater than 0. The program is run with each possible combination of the two inputs.
The following is the test suite for the tax calculator program

Number of dependents

Gross Income

Expected Tax

0

10000

0

1

10000

-600

2

10000

-1200

0

20000

2000

1

20000

1400

2

20000

800


Comments

Popular posts from this blog

Python For Machine Learning - CST 283 - KTU Minor Notes- Dr Binu V P

46.Classes and Objects in Python- Accessors and mutators

KTU Python for machine learning Sample Question Paper and Answer Key Dec 2020