Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter-01 Introduction to Software Engineering.

Similar presentations


Presentation on theme: "1 Chapter-01 Introduction to Software Engineering."— Presentation transcript:

1 1 Chapter-01 Introduction to Software Engineering

2 2 Software Engineering Object-Centered Design

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

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

5 5 Objects B. Identify the nouns 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 objects in our program.

6 6 Operations 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.

7 7 Algorithm D. Organize the objects and operations into a sequence of steps that solves the problem, called an algorithm. 1. Display a prompt for length and width on the screen. 2. Read length and width from the keyboard. 3. Compute area from length and width. 4. Display area, plus an informative label on the screen.

8 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 objects, and –perform our operations, in C++ (with the aid of a book...)

9 9 Representing Objects A. Determine a type and name for each object:

10 10 Performing Operations B. Identify the C++ operator to perform a given operation, if there is one... To compute area, we need to find the area-length- width formula in a geometry book...

11 11 Length and Width-to-Area In a geometry book, we find that –area is the product of length and width

12 12 Operations (Revised)

13 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. */

14 14 Coding: Program Stub /* area.cpp is a area calculating utility. *... */ #include // cin, cout, > using namespace std; int main() { }

15 15 Coding: Algorithm Steps 1 //... int main() { cout << “\n Rectangular Area Calculator!!” << "\n Enter the length (meter) and ” << “width (meter)” << "\n seperated by a space and “ << “followed by the enter key: "; }

16 16 Coding: Algorithm Steps 2 //... int main() { cout << “\n Rectangular Area Calculator!” << "\n Enter the length (meter) and” << “ width (meter)” << "\n seperated by a space and“ << “ followed by the enter key: "; int length, width; cin >> length >> width; }

17 17 Coding: Algorithm Step 3 //... cout << “\n Rectangular Area Calculator!” << "\n Enter the length (meter) and ” << “width (meter)” << "\n seperated by a space and “ << “followed by the enter key: "; int length, width; cin >> length >> width; int area = length * width; }

18 18 Coding: Algorithm Step 4 //... int area = length * width; cout << "\n The length of " << length << " meter and the width of " << width << " meter \n makes an area of " << area << "sq meter. \n\n"; }

19 19 Testing Run 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 sq. meter

20 20 Summary of OCD OCD is a methodology for designing programs: 1. Describe the desired behavior of the program. 2. Identify the objects required. 3. Identify the operations required. 4. Organize objects and operations into an algorithm, refining object and operation lists as necessary.

21 21 Summary of 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.


Download ppt "1 Chapter-01 Introduction to Software Engineering."

Similar presentations


Ads by Google