Software Engineering, CPSC-4360-01, CPSC-5360-01, Lecture 11
1 Chapter-01 Introduction to Software Engineering.
-
Upload
jeremy-sullivan -
Category
Documents
-
view
223 -
download
0
Transcript of 1 Chapter-01 Introduction to Software Engineering.
![Page 1: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/1.jpg)
1
Chapter-01
Introduction to Software Engineering
![Page 2: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/2.jpg)
2
Software Engineering
Procedural Design
![Page 3: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/3.jpg)
3
Problem Solving
• Does anyone carpet?
• Let’s solve this area problem:– Write a program that, given a length and width,
computes the area of a carpet.
![Page 4: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/4.jpg)
4
Behavior
A. Describe the desired behavior of the program:Our program should display a prompt for length and
width, read length and width from the keyboard, compute the corresponding area, and display the area, along with a descriptive label on the screen.
![Page 5: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/5.jpg)
5
Data
B. Identify the data in the behavioral description (other than program and user):Our program should display a prompt for length and
width on the screen, read length and width from the keyboard, compute the corresponding area, and display the area, along with a descriptive label on the screen.
These make up the data in our program.
![Page 6: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/6.jpg)
6
Operations: Functions or Procedures
C. Identify the verbs in the behavioral description:Our program should display a prompt for the length and
width on the screen, read the length and width from the keyboard, compute the corresponding area, and display the area, along with a descriptive label on the screen.
These make up the operations in our program.
![Page 7: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/7.jpg)
7
Algorithm
D. Organize data and operations into a sequenceof steps that solves the problem,called an algorithm.
1. Display a prompt for length and width on the screen.
Function call printf()
2. Read length and width from the keyboard.
Function call scanf()
3. Compute area from length and width .
4. Display area , plus an informative label on the screen.
Function call printf()
![Page 8: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/8.jpg)
8
Coding
Once we have designed an algorithm, the next step is to translate that algorithm into a high level language like C++.
This involves figuring out how to – represent our data, and– perform our operations,
in C++ (with the aid of a book...)
![Page 9: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/9.jpg)
9
Representing data
A. Determine a type and name for each data item:
![Page 10: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/10.jpg)
10
Performing Operations
B. Identify the C++ operator to perform a given operation, if there is one...
Operation Library? Name
Display a stringRead an intRead an intCompute areaDisplay an int
stdiostdiostdio--stdio
printf()scanf()scanf ()--printf()
To compute area, we need to find the area-length-width formula in a geometry book...
![Page 11: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/11.jpg)
11
Length and Width-to-Area
In a geometry book, we find that– area is the product of length and width
![Page 12: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/12.jpg)
12
Operations (Revised)
Operation Library? Name
Display a stringRead an intRead an intCompute pressure
Multiply two integers
Display an int
stdiostdiostdio--
built-in
stdio
printf()scanf()scanf()--*
printf()
![Page 13: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/13.jpg)
13
Documentation
Always begin a file with an opening comment:
/* area.cpp is a area calculating utility. * Author: Bazlur Rasheed * Date: 02 July 2000 * Purpose: Calculate area of a rectangle. */
![Page 14: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/14.jpg)
14
Coding: Program Stub
/* area.cpp is a area calculating utility. * ... */
#include <stdio.h> // printf(), scanf()
int main(){}
![Page 15: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/15.jpg)
15
Coding: Algorithm Steps 1
// ...int main(){printf(“\n Rectangular Area Calculator!!”);printf("\n Enter the length (meter) and ”); printf(“width (meter)”);printf("\n seperated by a space and “);printf(” followed by the enter key: ";);
}
![Page 16: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/16.jpg)
16
Coding: Algorithm Steps 2
// ...int main(){printf(“\n Rectangular Area Calculator!!”);printf("\n Enter the length (meter) and ”); printf(“width (meter)”);printf("\n seperated by a space and “);printf(” followed by the enter key: ";);int length, width;scanf(“%d %d”, &length, &width);
}
![Page 17: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/17.jpg)
17
Coding: Algorithm Step 3// ... printf(“\n Rectangular Area Calculator!!”);printf("\n Enter the length (meter) and ”); printf(“width (meter)”);printf("\n seperated by a space and “);printf(” followed by the enter key: ";);int length, width;scanf(“%d %d”, &length, &width);
int area = length * width;}
![Page 18: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/18.jpg)
18
Coding: Algorithm Step 4
// ... int area = length * width;
printf("\n The area is %d”, area);printf(” square meter. \n\n”);
}
![Page 19: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/19.jpg)
19
TestingRun your program using sample data
(whose correctness is easy to check):
Rectangular Area Calculator! Enter the length (meter) and width (meter) separated by a space and followed by the enter key: 10 20
The area is 200 square meter
![Page 20: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/20.jpg)
20
Summary of Procedural
Procedural is a methodology for designing programs:
1. Describe the desired behavior of the program.
2. Identify the data required.
3. Identify the operations (functions) required.
4. Organize data and operations into an algorithm, refining data and operation lists as necessary.
![Page 21: 1 Chapter-01 Introduction to Software Engineering.](https://reader036.fdocuments.us/reader036/viewer/2022062408/56649ef25503460f94c04393/html5/thumbnails/21.jpg)
21
Summary of Procedural Programming
Writing a program consists of these steps:1. Design an algorithm for your program.
2. Code your design.
3. Test your program.
4. Maintain/upgrade your program as necessary.