presented by prof. k regis. the software development process 1. problem analysis and specification...

96
Presented By Prof. K Regis

Upload: camron-mccormick

Post on 26-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Presented By Prof. K Regis

The Software Development Process1. Problem analysis and

Specification 2. Design3. Coding 4. Verification and Validation 5. Maintenance

The Software Life cycle is the process by which Software is developed for an enterprise. For example Toyota Automates Corolla Car Plant to improve car production and distribution.

Because the initial description of a problem maybe somewhat vague and imprecise :-

1.The first step in the development of a program is to analyze the Problem and formulate a precise specification for it.

2. This specification must include a specification of the problem’s input what information is given and which items are important in solving the problem – and its output - what information must be produced to solve the problem

Real World Scenario:-

In a real-world problem encountered by a professional programmer, the specification of the problem includes other items and considerable effort maybe required to formulate it completely.

Sam Shyster installs coaxial cable for LIME Cable Company . For each installation, there is a basic service charge of $25.00 and an additional charge of $2.00 for each foot of cable. During the months of January, Sam installed a total 263 yards of cable at 27 different locations. What was the total revenue that Sam generated for the month?

Step 1: Identify the input and out

Basuc Service Charge: $25.00 Revenue GeneratedUnit Cable Cost: $2.00Number of Installations: 27Yards of Cable: 263

Input Output

The revenue that Sam Shyster generated can be easily calculated by hand or still more easily by using a calculator and does not warrant developing a computer program for its solution.

Note well: A program written to solve this particular problem would probably used just once.

Now: If Sam installs cable at42 locations in February using 455 yards of cable or if the basic service charge or the unit of cable changes we would have a new problem requiring a program.

This is obviously a waste of effort, since it is clear that each such problem is a special case of the more general problem of finding the revenue generated for any number of installations , any amount of cable, any basic service charge, and any unit cost of cable.

Note Well:

A program that solves the general problem can be used in many situations and is consequently more useful than one designed to solve only original special problem One important aspect of problem analysis: -Is generalization

The effort involved in later phases of the problem-solving process demands that the program eventually developed be sufficiently flexible, that it solve not only the given specific problem but also any related problem of the same kind with little, if any, modification required.

In this example, the specification of the problem thus be better formulated in general terms:

Basuc Service Charge Revenue GeneratedUnit Cable CostNumber of InstallationsYards of Cable

Input Output

Obviously, we could generalize still more – allow several employees , other kinds of charges =, different kinds of cable, and so on – but we must stop somewhere

The level of air pollution in the city of Huntington is measured by a pollution index. Readings are made at 12:00pm at three locations: Crane Coal Plant, downtown at the corner of Hanes Avenue and Hicksville 5th Street, at a randomly selected location in a residential area.

The average of these three readings is the pollution index, and a value of 50 or greater for this index indicates a hazardous condition, whereas values less than 50 indicate a safe condition. Because this index must be calculated daily , the city of Huntington environmental statistician would like a program that calculates the pollution index and then determines the appropriate condition, safe or hazardous.

The relevant given information consists of three pollution readings and the cut-off value used to distinguish between safe and hazardous conditions .

A solution to the problem consists of the pollution index and a message indicating the condition. Generalizing so that any cutoff value, not just 50 can be used, we specify the problem as follows:

Three Pollution Readings Pollution index = the averagepollution readings

Cutoff Value todistinguish between Condition: safe or hazardoussafe and hazardous condition

Input Output

One important statistic that is used in measuring the reliability of a component in a circuit is the mean time to failure, which can be used to predict the circuit’s lifetime. 1. This is especially important in situations in which repair is difficult or even impossible, such a computer circuit in a space satellite. Suppose the engineering laboratory has been awarded a contract by NASA to evaluate the reliability of the particular component for a future space probe to Jupiter. As part of this evaluation, an engineer at this laboratory tested several of these circuits and recorded the time at which each failed. She now wishes to develop a program to process this data and determine the mean time to failure.

1. The input for this problem is obviously a collection of failure times for the component being tested and the output is clearly the average or a mean of these times.

2. To calculate this mean, we must know how many tests were conducted, but this information is not given in the statement of the problem.

3. We cannot therefore assume that it is part of the input and so the program will have to be flexible enough to process any number of measurements

A collection of numeric The number of valuesvalues (number unknown) The mean of the values

Input Output

Once the specification of a problem has been given, a design plan for developing or a system of programs that meets the specification must be formulated.

The Important Aspects of Design:

The two important aspects of design are:

1.Selecting appropriate structures to organize and store the data to be processed.

2.Designing procedures to process the data

Note Well:

For the remainder of our Programming classes, the data items will we stored and processed using variables much like those used in mathematics to name quantities in algebraic formulas and equations. More complex structures will be discussed later.

Because the computer is a machine possessing no inherent problem-solving capabilities , the procedures developed to solve a problem must be formulated as a detailed sequence of simple steps. Such procedures are called algorithms.

The steps that comprise an algorithm must be organized in a logical and clear manner so that the program that implements this algorithm will be similarly well structured.

Structured algorithms and programs are designed using three basic methods of control:

Sequential: Steps are performed in a strictly sequential manner, each step being executed exactly once.

Selection: One of a number of alternative actions is selected and executed.

Repetition: One or more steps are performed repeatedly.

These three structures are individually quite simple, but in fact they are sufficiently powerful that any algorithm can be constructed using them.

Please note:

Programs to implement algorithms must be written in a language that the computer can understand. It is natural, therefore, to describe the algorithm in a language that resembles that used to write computer programs that is a pseudo programming language or more commonly referred to as Pseudocode.

Unlike the definitions of high-level programming languages such as Pascal, there is no set of rules that precisely define Pseudocode.

Pseudocode varies from one programmer to another.

Pseudocode is a mixture of natural language and symbols , terms and other features commonly used in high-level languages.

1. The usual computer symbols are used for arithmetic operations: + for addition, - for subtraction, * for multiplication, and / for division.

2. Symbolic names (identifiers) are used to represent the quantities being processed by the algorithm.

3. Some provision is made for including comments, often by enclosing each comment between special symbols such as (* and *)

4. Certain key words that are common high-level languages may be used: for example, Read or Enter to indicate input operations and Display, Print or Write for output operations.

5. Indentation is used to indicate certain key blocks of instructions.

The structure of an algorithm may be displayed in a structure diagram that shows the various tasks that must be performed and their relation to one another.

These diagrams are especially useful in describing algorithms for more complex problems and will be described in greater detail later on:

Using out three problem examples we will illustrate the three basic control structures : Sequence Selection and Repetition and --- and how to present algorithms using Pseudocode.

Inputs for this Problem: Basic Service charge unit cable costnumber of installationsYards of cable used

Outputs: The amount of Revenue generated.

We then declare our variables: Using the variables

Service Charge, Unit Cost, Installations, YardsOfCable and Revenue to represent these quantities.

The First step in an algorithm for solving this problem is to obtain the values for the input items: - ServiceCharge, UnitCost, Installations and YardsOfCable.

Step 2: Determine the number of feet of cable used, by multiplying the number of yards of cable by 3. The revenue generated can then be obtained by multiplying the unit cable cost by the number of feet of cable and the number of installations by the basic service charge, and adding these two products.

Finally, the output value – revenue generated – must be displayed.

The Algorithm can be expressed in Pseudocode as follows:

Note well : NB

We have included the problem’s specifications and a brief description of the algorithm’s purpose as a comment at the beginning of the algorithm.

Such documentation is important and should always be included in the statement of an algorithm.

(* Input: A basic ServiceCharge, a UnitCost for cable , number of Installations, and YardsOfCable used. Purpose: This algorithm calculates the revenue generated by the Installation of a certain number of yards of cable at a number of locations. For each installations there is a fixed basic service charge and an additional charge for each foot of cable. Output: Revenue generated. *) 1.Enter ServiceCharge, UnitCost, Installations, and Yards OfCable. 2.Calculate FeetOfCable = 3* YardsOfCable . 3.Calculate

Revenue = Installations * ServiceCharge + UnitCost * FeetOfCable 4.Display Revenue

This algorithm only uses sequential control; the steps are executed in order, from beginning to end, with each step being performed exactly once. For other problems, however, the solutions may require that some of the steps be performed in some situations and bypassed in others.

This is illustrated in problem 2.

Recall that from Problem 2, the input consists of three pollution readings and a cutoff value that distinguishes between safe and hazardous conditions.

These will be represented by the variables: Level1, Level2, Level3 and Cutoff respectively.

The Output: To be produced consist of the pollution index, which is the average of the three readings and will be stored in a variable Index, and a message indicating the appropriate condition.

Step1: To solve this problem is to obtain values for the input items – Level1, Level2, Level3, and Cutoff.

Step 2: Calculate the pollution index by averaging the three readings

Step 3: One of the two possible actions must be selected. ( either a message indicating a safe condition or a message indicating a hazardous condition must be displayed.

Step 4: The appropriate action is selected by comparing the pollution index with the Cutoff value.

If Index < Cutoff then Display “Safe Condition” Else Display “Hazardous condition”

ALGORITHM FOR POLLUTION INDEX PROBLEM

(* Input: Three pollution Levels and a cutoff value. Purpose: This algorithm reads three pollution levels , Level1, Level2, Level3, and a Cutoff value. It then calculates the pollution Index. If the value of the Index is less than Cutoff, a message indicating a safe condition is displayed: otherwise, a message indicating a hazardous condition is displayed. Output: The pollution Index and a message indicating the air quality . *)

1.Enter Level1, Level2, Level3, and Cutoff. 2.Calculate

3.DisplayIndex. 4.If Index < Cutoff then Display “Safe Condition Else Display “Hazardous condition”

3

321 LevelLevelLevelIndex

________________________________________________________________________________________________________________________________________________

________________________________________________________________________________________________________________________________________________

In addition to the sequential processing and selection illustrated in Case2/example 2 above , the first 2 examples, the solution of other problems may require that a step or a collection of steps be repeated.

This is illustrated in Example 3

In problem 3 the output is a series of numbers, each representing the failure time of a component in a circuit. The output is the number of data values and their average , which is then the mean time to failure for this component.

In developing algorithms to solve problems like this, one useful method is to begin by considering how the problem could be solved without using a computer, perhaps instead using pencil and paper and or a calculator.

To solve this problem in this manner: We enter the values one at a time, counting each value as it is entered and adding it to the sum of the preceding values.

We see the procedure thus involves two quantities : 1.A counter that is incremented by 1 each time a value is entered. 2.A running sum of the data values.

Data Value Count Sum

0 0.0

3.4 1 3.4

4.2 2 7.6

6.0 3 13.6

5.5 4 19.1

- - -

- - -

- - -

The procedure begins with 0 as the value of the counter and 0.0 as the initial value of the sum. At each stage a data value is entered, the value of the counter is incremented by 1, and the data value is added to the sum, producing a new sum.

These steps are repeated until all the data values have been processed, and then the sum is divided by count to obtain the mean value.

When Solving this problem by Hand: It is clear when the last data value has been entered, but if this procedure is to be performed by a program, some method is needed to indicate that all of the data values have been processed.

A common technique is to signal this by entering an artificial value called a data flag or data sentinel, which is distinct from any possible valid data item. This value is not processed as a regular data value but serves only to terminate the repetition.

1. The first two steps of the program development process are extremely important, because the remaining phases will be much more difficult if the first two steps are skipped or are not done carefully.

2. On the other hand, if the problem has been carefully analyzed and specified and if an effective design plan has been developed, the third step of program coding is usually straightforward.

Coding is the process of implementing in some programming language the variables (and structures) used to store the data and the algorithms for solving the problem.

In the design plan, the variables and algorithms may be described in a natural language or Pseudocode, but

the program that implements that algorithm must be written in the vocabulary of a programming language and must conform to the syntax, or grammatical rules, of that language.

In the three examples in the preceding section, we used variables to store variousquantities. In the first example, the variables Service Charge, UnitCost, Installations, and YardsOfCable represented the basic service charge, the cost per foot ofcable, the number of installations, and the yards of cable used, respectively.

The output in this example was the revenue generated and was represented by the variable Revenue. In the second example, the variables Level1, Level2, Level3, Cutoff, and Index were used, and in the third example, the variables were FailTime, NumTimes, Sum, and MeanFailTime.

In Pascal, variable names must begin with a letter, which may be followedby any number of letters and digits. This allows us to choose names that suggest what the variable represents, for example, ServiceCharge, UnitCost, Installations, YardsOfCable, Revenue, Level1, FailTime, and Sum.

Meaningful variable names should always be used because they make a program easier to read and understand.

In the examples we have been considering, two types, of numbers are used. The values of YardsOfCable, FeetOfCable, and Installations in the first example. Level1, Level2, Level3, Cutoff, and Index in the second example, and NumTimes in the third example are integers, whereas the values of ServiceCharge, Unit Cost, and Revenue in the first example and FailTime , Sum, and MeanFailTime in the third example are real, that is they have fractional parts.

Pascal distinguishes between these two types of numeric data, and the types of the values that each variable may have must be specified. This is done by placing variable declarations of the form at the beginning of the program, where list1 is a list of variables names of integer type and List2 is a list of variables names of real type. Thus the types of Pascal variables in the example can be specified. Example 1

Example 2

Example 3

In these examples, VAR is one of the reserved words in Pascal.

Reserved words may not be used for any purpose other than those designated by the rules of the language. For example, reserved words may not be used as variable names.

In this text reserved words will always be written in uppercase to emphasize their special status

Addition and subtraction are denoted in Pascal by the usual + and - symbols.Multiplication is denoted by *, real division by /, and integer division by DIV. The“assignment operation is denoted by : = in Pascal programs. For example, the statement calculates the values of the product and assigns this variable to FeetOfCable

In the Pseudocode description of an algorithm in the preceding section we used thewords "enter" and "read" for input operations and "display," "print," and"write" for output operations. One Pascal statement that may be used for input isthe readln statement. A simple form of this statement is

where list is a list of variables for which values are to be read. For example, thestatement

reads values for the variables ServiceCharge, UnitCost, Installations, andYardsOfCable entered by the user from some input device.

A simple output statement in Pascal is the writeln statement of the form

Where list is a list of items to be displayed . For example the statement

Displays the label

Followed by the value of the variable Revenue

Comments can also be incorporated into Pascal programs. They are indicated byenclosing them within braces

Or with (* and *)

Program Composition1.Figure 2.1 shows a Pascal program for the algorithm to solve the revenue calculation problem considered earlier in this chapter. The program begins with the program heading

where Calculate Revenue is the name assigned to the program by the programmer, input indicates that information will be input to the program from an external source, and output indicates that the program will also produce some output. 2. This is followed by documentation in the form of a

comment that describes the program. It specifies what is input to the program, what the purpose of the program is and what output it produces.

Steps in Program Composition

3. The next part of the program consists of the variable declarations that specify the types of all the variables used in the program and comments to explain them.

Steps in the Algorithm

The first step in the algorithm is an input instruction to enter values for the variables ServiceCharge, UnitCost, Installations, and YardsOfCable:

1. Enter ServiceCharge, UnitCost, Installations, and YardsOfCable

This translates to the following statements in the program:

The two writeln statements are used to prompt the user that values are to be entered. The readln statement actually assigns the four values entered by the user to the four variables ServiceCharge, UnitCost, Installations, and YardsOfCable. Thus, in the sample run shown, when the user enters

The value 25.00 is assigned to ServiceCharge, 2.00 to UnitCost, 27 to Installations, and 263 to YardsOfCable.

The next two steps in the algorithm:

2.- Calculate FeetOfCable = 3 * Yards Of Cable.3. Calculate

Translated into Pascal Assignment Statements

The Output Instruction

4. Display Revenue

Is translated into the Pascal Assignment Statement

The format descriptor: 7 : 2 appended to the variable name Revenue indicates that this a real value to be displayed in an output zone of size seven and is to berounded to two decimal places.The end of the program is indicated by the Pascal reserved word END followedBy a period. Note that the statements in the program are separated by semicolons.

Errors may occur in any of the phases of the program development process. For example, the specifications may not accurately reflect information given in the problem; the algorithms may contain logical errors; and the program may not be coded correctly. The detection and correction of errors is an important part of software development and is known as validation and verification.

Validation is concerned with checking that the algorithms and the program meet the problem's specification. Validation is sometimes described as answering the question "Are we solving the correct problem?”

Verification refers to checking that they are correct and complete. and verification indicates if we are answering the question "Are we solving the problem correctly?”

One important part of verification and validation is executing the program with various sets of test data. The procedure for submitting a program to a computer and executing varies from one system to another; the details regarding your particular system can be obtained from your instructor, computer center personnel, or user manuals supplied by the manufacturer.

First you must obtain access to the computer system. In the case of a personal computer, this may only mean turning on the machine and inserting the appropriate diskette in the disk drive/ USB/Flash Drive. For a larger system, some login procedure may be required to establish contact between a remote terminal and the computer. When you have gained access, you must enter the program, often by using an editor provided as part of the system software.Once a program like that in Figure 2.1 has been entered, it is compiled and executed giving appropriate system commands. If no errors are detected during the systems compilation, the resulting object program can be executed, and output like the following will appear on the screen:

A message prompting the user for four input values is displayed by the program, after these values are entered, the desired output value is calculated and displayed.

In this example, we illustrated the interactive mode of processing, in which the user enters data values 25.00, 2.00, 27, and 263 during program execution ( from the keyboard), and the output produced by the program is displayed directly to the user (usually on a video screen).

Another mode of operation is batch processing, in which the user must prepare a file containing the program, the data, and perhaps certain command lines and submit it to the system. Execution then pro- without any user interaction.

In this example, the program was entered, compiled, and executed without error. Usually, however, a programmer makes some errors when designing theprogram or when attempting to enter and execute it. Errors may be detected at various stages of program processing and may cause the processing to be terminated.

For example, an incorrect system command is detected early in the processing and usually prevents compilation and execution of the program. Errors in the program's syntax, such as incorrect punctuation or misspelled key words, are detected during compilation. (On some systems, syntax errors may be detected while the program is being entered.) Such errors are called syntax errors or compile-timeerrors and usually make it impossible to complete the compilation and execution of the program. For example, if the first writeln statement that prompts the user to enter values is mistakenly entered as

with the right parenthesis missing, an attempt to compile the program may result in a message like the following, signaling a "fatal" error:

Less severe errors may generate "warning" messages, but the compiler will fix the error so that compilation can continue, and execution of the resulting object program may be attempted.

Other errors, such as an attempt to divide by zero in an arithmetic expression, may not be detected until execution of the program has begun. Such errors are called run-time errors.

Explanations of the error messages displayed by your particular system can be found in the user manuals supplied by the manufacturer. In any case, the errors must be corrected by replacing the erroneous statements with correct ones,' and the modified program must be recompiled and re-executed.

Errors that are detected by the computer system are relatively easy to identify and correct. There are, however, other errors that are more subtle and difficult to identify. These are logical errors that arise in the design of the algorithm or in the coding of the program that implements the algorithm. For example, if the statement

In the program of Figure 2.1 we mistakenly entered as

with the multiplication symbol (*) replaced by the symbol for addition (+), the program would still be syntactically correct. No error would occur during its compilation or execution. But the output produced by the program would not be correct because an incorrect formula was used to calculate FeetOfCable. Thus, if the values 25.00, 2.00, 27, and 263 were entered for the variables ServiceCharge, UnitCost, Installations, and YardsOfCable, respectively, the output produced by the program would be

Instead of the correct output

Since it may not be obvious whether the results produced by a program are correct, it is important that the user run a program several times with input data for which the correct results are known in advance. For the preceding example, it is easy to calculate by hand the correct answer for values such as 1.00, 2.00, 3, and 4, for ServiceCharge, UnitCost, Installations, and YardsOfCable, respectively, to check the output produced by the program.

This process of program testing is extremely important, as a program cannot be considered to be correctuntil it has been checked with several sets of test data. The test data should be carefully selected so that each part of the program is tested.

Programming and problem solving is an art in that it requires a good deal of imagination, ingenuity, and creativity. But it is also a science in that certain techniques and methodologies are commonly used. The term software engineering has come to be applied to the study and use of these techniques.

As we noted in the introduction to this chapter, the life cycle of softwareconsists of five basic phases:1. Problem analysis and specification.2. Design.3. Coding.4. Verification and validation.5. Maintenance.

In the preceding sections we described the first four phases and illustrated them with some examples. We deliberately kept these examples simple, however, so that we could emphasize the main ideas without getting lost in a maze of details, but in real-world applications and in problems later in this text, these phases may be considerably more complex.

In this section we reexamine each of these phases and describe some of the additional questions and complications that professional programmers face, together with some of the software engineering techniques used in dealing with them.

Like the exercises and problems in most programming texts, the examples we have considered thus far were quite simple and, we hope, clearly stated. Analyzing these problems to identify the input and output is, therefore, quite easy. This is not the case, however, with most real-world problems, which are often stated vaguely and imprecisely because the person posing the problem does not fully understand it.

For example, the president of a land development company might ask a programmer to "computerize the payroll system for the Cawker City Construction Company."

In these situations, many questions must be answered in order to complete theproblem's specifications. Some of these answers are required to describe more completely the problem's input and output. What information is available for each employee? How is the program to access this data? Has this information been validated, or must the program provide error checking? In what format should the output be displayed? Are paychecks being printed? Must additional reports be generated for company executives and/or government agencies?

Other questions deal more directly with the required processing. Are employees paid on an hourly or a salary basis, or are there some of each? What premium, if any, is paid for overtime? What items must be withheld-for federal, state, andcity income taxes, retirement plans, insurance, and the like-and how are they to be computed?

Many other questions must be answered before the specification of the problem is complete and the design of the algorithms and programs can begin. Will the users be technically sophisticated, or will they be novices so that the software must be made extra user friendly and robust? How often will the software be used? What are the response time requirements? How critical is the application in which thesoftware is being used? If fault-free performance is required, must a proof of correctness accompany the software? As the specification of the problem is being formulated, decisions must be made regarding the feasibility of a computer solution.

Is it possible to design programs to carry out the required processing? If so, is it economically feasible? What hardware and software are available? Could the problem be solved better manually? How soon must the software be ready? What is its expected lifetime; that is, how long will it be used, and what changes can be expected in the future?

Although this list is by no means exhaustive, it does indicate the wide range of information that must be obtained in analyzing and specifying the problem. In some situations this is done by a systems analyst~ but in others it is part of the programmer's responsibility.

The statement of the specifications developed in this phase becomes the formal statement of the problem's requirements. This problem specification document serves as the major reference document that guides the development of the software, and it is the standard or benchmark used in validating the final system to determine whether it does in fact solve the problem. For this reason, a number of formal methods have been developed for formulating specifications. These methods are usually studied in more advanced software engineering courses, and in this text we will state the problem specifications somewhat less formally.

Once the specification of a problem has been given, we can begin designing a solution for the problem. As we noted in Section 2.2, two important parts of the design plan are the selection of structures to organize and store the data and the design of algorithms to process the data.

For example, in the payroll problem we are considering, a file of employee records containing names, social security numbers, number of dependents, and so on contains permanent information that must be stored in some structure so that this information can be accessed and processed.

Other information such as hours worked will be entered during program execution and can perhaps be stored in simple variables, as in the examples we considered in previous sections.

A real-world problem may be so complex that it is difficult to visualize or anticipate at the outset all the details of a complete solution to the problem. To solve such problems, a divide-and-conquer strategy is used, in which the original problem is partitioned into simpler subproblems, each of which can be considered independently. We begin by identifying the major tasks to be performed to solve the problem and arranging them in the order in which they are to be carried out.These tasks and their relation to one another can be displayed in a structure. For example, a first structure diagram for the problem might be

Usually one or more of these first-level tasks is still quite complex and must be into subtasks. For example, we noted that for the payroll system, some of the put information is permanent, whereas other information will be entered during program execution. Consequently, the task "Obtain input data" can be subdivided into two subtasks:

1.Obtain permanent employee information.2.Obtain current information.

Similarly the task “Perform Calculations” may be split into three subtasks: 1.Calculate gross pay.2.Calculate withholding.3.Calculate net pay.

Finally, the third task, "Display results," may be subdivided into1.Print paychecks.2.Print summary reports.In a structure diagram, these subtasks are placed on a second level below thecorresponding main task, as pictured in Figure 2.2. These subtasks may requireFurther subdivision into still smaller subtasks, resulting in additional levels, as illustrated in Figure 2.3. This successive refinement continues until each subtask is simple that the design of an algorithm for that subtask is straightforward

This top-down approach to software development allows the programmer to design and test an algorithm and the corresponding program module for each problem independently of the others. For very large projects a team approach be used in which the low-level subtasks are assigned to different programmers. The individual program modules they develop are eventually combined into one complete program that solves the original problem.

Coding is the process of implementing data structures and algorithms in some programming language. If the design plan has been developed carefully and completely, this translation process is nearly automatic. As we noted, large softwaresystems are developed in a top-down manner in which a problem is partitionedinto a number of subproblems and individual modules are developed to solve thesubproblems. Integration is the process of combining these program units into a complete program or system of programs. Such integration is usually done incrementally by adding the units one at a time. If an error occurs when a new module is added to the system, the developer can be reasonably confident that it was caused by this module and not by one added earlier.

The first decision that must be made when translating an algorithm into a program is what programming language to use. This obviously depends on the languages available to the programmer and those that he or she is able to use, but other factors also influence the decision. The problem may have characteristics that make one language more appropriate than another. For example, if the problem requires scientific computing with extended precision and/or complex numbers, FORTRAN may be the most suitable language.

Problems that involve a large amount of file input/output and report generation can perhaps best be handled in COBOL. Applications in artificial intelligence that require making logical inferences might best be solved using PROLOG. Structured algorithms, especially those developed as a collection of sub-algorithms in a top-down manner, can best be implemented in a structured language such as Pascal, Modula-2, Ada, C, or C++.

Regardless of which language is used, certain programming practices contributeto the development of correct, readable, and understandable programs. Oneprinciple is that programs should be well structured. Two helpful guidelines in thisregard are to

• Use a top-down approach when developing a program/or a complex problem.Divide the problem into simpler and simpler subproblems, and writeindividual subprograms to solve these subproblems.

•Strive for simplicity and clarity. Avoid clever programming tricks intendedonly to demonstrate the programmer's ingenuity or to produce code thatexecutes only slightly more efficiently.

A second principle is that each program unit should be documented. In particular:

Each program unit should include opening documentation. Comments should be included at the beginning of each program (procedure, function) to explain what it does, how it works, any special algorithms it uses, a summary of the problem's specification, assumptions, and so on, and they may also include other items of information such as the name of the programmer, the date the program was written and when it was last modified, and references to books and manuals that give additional information about the program. In addition, it is a good practice to explain the variables that are being used in the program.

• Comments should also be used to explain key program segments and/orsegments whose purpose or design is not obvious. However, too many detailedor unnecessary comments clutter the program and only make it moredifficult to read and understand. . .• Meaningful identifiers should be used. For example, the statement

Don't use' 'skimpy" abbreviations just to save a few keystrokes when entering the program. Also, follow what has been called the' 'Shirley Temple principle" and avoid "cute" identifiers~ as in

A third principle has to do with a program's appearance. A program should beaesthetically pleasing; it should be formatted in a style that enhances its readability. The following are some guidelines for good program style:• Use spaces between the items in a statement to make it more readable, for example, before and after each operator (+, -, <, : =, etc.).• Insert a blank line between sections of a program and wherever appropriate in a sequence of statements to set off blocks of statements.• Adhere rigorously to alignment and indentation guidelines to emphasize therelationship between various parts of the program. For example, indent those statements that make up the body of a loop.

Obviously the most important characteristic of any program is that it be correct. No matter how well structured, how well documented, or how nice the program looks, if it does not produce correct results, it is worthless. But as we have seen, the fact that a program executes without producing any error messages is no guarantee that it is correct.

The results produced may be wrong because of logical errors that the computer system cannot detect. It is the responsibility of the programmer to test each program in order to ensure that it is correct.

Since errors may occur at each phase of the development process, different kinds of tests are required to detect them: unit tests in which each program unit is tested individually; integration tests that check that these units have been combined correctly, and system tests that test to see whether the overall system functions correctly. These correspond to the various phases of the software life cycle, as indicated by the diagram of the "V" Life Cycle Model in Figure 2.4. I

System testing measures the correctness and performance of the final system against the problem's specification. Integration tests are considered in Section 5.7, where we illustrate top-down design. Unit testing is probably the most time consuming and is surely the most fundamental kind of testing, since incorrectness of any part of the system implies incorrectness of the system as a whole.

The specification document for the original problem serves as a standard for validating the entire system. Similarly, specifications of the subproblems obtained in a top-down design are needed as standards against which the individual modules are tested.

Each of these specifications should include at least a description of1. The purpose of the module.2. Items input to the module (from input devices).3. Items accepted from other modules4.Items output by the module (to output devices).5.Items returned to other modules.

When a correctness proof of the module is required, the specifications must also include preconditions and postconditions that describe the state of processing before and after the module is executed. When it is appropriate in the examples of this text, we will include informal informal descriptions of pre- and postconditions in the descriptions of the module's input/accepted items and output/returned items respectively.

The Life cycle of a program written by a student programmer normally ends with the fourth phase; that is, once the program has been written, executed, and tested, the assignment is complete. Programs in real-world applications, however, are used for several years and are likely to require some modification. Software systems especially large ones developed for complex projects, often have obscure bugs that were not detected during testing and that surface after the software has in use. One important aspect of software maintenance is fixing such flaws in software.

It may be necessary to modify software to improve its performance, to addNew features and so on. Other modifications may be required owing to changes in The computer hardware and/or the system software such as the operating system. External factors may also force program modification; for example, changes in the tax laws may mean revising part of a payroll program. These changes are easier to make in systems that are developed in a modular manner with well-structured modules than in poorly designed ones, because the changes can often made by modifying only a few of he modules or by adding new modules.

Software maintenance is a major component of the life cycle of software. Studies have shown that in recent years more than 50 percent of computer center budgets and more than 50 percent of programmer time have been devoted to software maintenance and that worldwide, billions and perhaps trillions of dollars have been spent on software maintenance.

A major factor that has contributed to this high cost in money and time is that many of the original programs and systems had poor structure, documentation, and style. This problem is complicated by the factthat maintenance must often be done by someone not involved in the original design.

Thus it is mandatory that programmers do their utmost to design programs and systems of programs that are readable, well documented, and well structuredso that they are easy to understand and modify and are thus easier to maintain than is much of the software developed in the past.

As the diversity of applications continues to grow, computing will affect more and more individuals, groups, and institutions. As a result, the influence exerted by computer professionals, either wittingly or unwittingly, will continue to increase, as will the importance of responsible and ethical conduct.

Like all technology, computer technology is inherently neither good nor evil. It is the responsibility of computer professionals to ensure that it is used for the benefit, and not to the detriment, of society.

Some of the ethical concerns that are raised by the growth of computer technology are:

• Privacy. Computing technology has made possible the construction of largedatabases of information about individuals and institutions. Although thepurpose for which this information was collected may be legitimate (creditratings, crime networks, medical records, and government records), there isalways the potential for the misuse of sensitive information by unauthorizedindividuals?

Indeed, such misuse has become so prevalent in recent yearsthat state and federal governments have enacted statues such as the ElectronicCommunication Privacy Act of 1986 to combat such invasions ofprivacy. Computer professionals and computer scientists perhaps more thanothers have the knowledge and ability to access private information. Therefore,they have a special responsibility to respect the rights of others by notaccessing these databases without authorization and, in applications thatrequire access to these databases, using this information only for the purposefor which it was‘ intended.

Those who design these databases and/or software to process them also have a responsibility to maintain the integrity and security of that information. In particular, this most assuredly means that they have no right to develop programs like computer viruses that damage, destroy, or interfere in any way with other people's computer systems or the data stored in these systems.

The worm program injected into the Internet in November 1988 by Robert T. Morris, a computer science graduate student at Cornell University, and the more recent Michelangelo virus are but two of many examples of malicious programs that attacked computers around the world, shutting down thousands of them and/or destroying data files. Such irresponsible behavior obviously is not appropriate to those who call themselves, or who aspire to be, computer professionals

Intellectual Property. Computer hardware and software are the property of the individuals or companies that developed them. Those who wish to use these products should obtain them through legal channels and abide by the conditions that govern their use. It has been estimated, however, that 60 to 80 percent of all software used today has been pirated and that the resultingloss to the software industry exceeds several billion dollars per year. It is important that all computer professionals have respect for their fellow professionals and do not create, use, or disseminate illegal copies of software.

This applies not only to copyrighted software but also to shareware that is distributed with the understanding that those who use it will register their copy with the developer and pay the nominal fee for its use.

Truth in Software. Computer professionals are responsible for ensuring that the software or hardware they are developing functions in the manner claimed. This means that these products should be thoroughly tested andmade as error free as possible before they are delivered to the customer. It also means that potential users be made fully aware of the hardware and software needed to use the product and that errors found and difficultiesencountered after the product is released are remedied promptly.

Themes and codes used in Ethical Coding By Professional Societies for Software Engineering

1. Dignity and worth of other people.2. Personal integrity and honesty.3. Responsibility for work.4. Confidentiality of information .5. Public safety, health, and welfare.6. Participation in professional societies

to improve standards of the profession.7. The notion that knowledge and access

to technology is equivalent to social power.