Object-Centered Design

Slides:



Advertisements
Similar presentations
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
Advertisements

Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Problem Solving and Program Design. COMP104 Problem Solving / Slide 2 Our First Program // a simple program #include using namespace std; int main() {
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Lab-1 CSIT-121 Spring 2005 Lab Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming Exercise.
Computer Programming 1 Problem Solving and Software Engineering.
Problem Solving and Software Engineering Chapter 1.
Computer Science 1620 Programming & Problem Solving.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Software Engineering 1 (Chap. 1) Object-Centered Design.
The switch Statement Selection Revisited. Problem Using OCD, design and implement a program that allows the user to perform an arbitrary temperature conversion.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
1 Programming and Problem Solving — Software Engineering (Read Chap. 2)
Programming and Problem Solving — Software Engineering (Read Chap. 2) 1.
Problem Solving and Software Engineering Chapter 1.
1 C++ Loop Statements Repetition Revisited. 2 Problem Using OCD, design and implement a function that, given a menu, its first valid choice, and its last.
Operations Making Things Happen. Our Scuba Program #include // cin, cout, > using namespace std; int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM.
Controlling Function Behavior Sequence, Selection and Repetition.
1 Chapter-01 Introduction to Software Engineering.
File I/O ifstreams and ofstreams Sections 11.1 &
C++ Loop Statements Repetition Revisited. Problem Using OCD, design and implement a function that, given a menu, its first valid choice, and its last.
1 Simple Functions Writing Reuseable Formulas. In Math Suppose f (x) = 2 x 2 +5Suppose f (x) = 2 x 2 +5 f(5)=?f(5)=? f(5) = 2* =55f(5) = 2*
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
1 Chapter-01 Introduction to Software Engineering.
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
COSC1557: Introduction to Computing Haibin Zhu, PhD. Professor Department of Computer Science Nipissing University (C) 2014.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
Software Engineering Object-Centered Design. Problem Solving Does anyone scuba dive? Let’s solve this scuba-diving problem: Write a program that, given.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Simple Functions Writing Reuseable Formulas. Problem Using OCD, design and implement a program that computes the area and circumference of an Australian.
Libraries Making Functions Reuseable. Review Last time, we wrote a program to compute the area and circumference of an ellipse. a a bb.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
1 Chapter-01 Introduction to Software Engineering.
Objects Variables and Constants. Our Scuba Problem #include // cin, cout, > using namespace std; int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM.
Software Engineering (Chap. 1) Object-Centered Design When we prepare a program, the experience can be just like composing poetry or music … My claim is.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Software Engineering Algorithms, Compilers, & Lifecycle.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output Samples.
Problem Solving and Program Design. Problem Solving Process Define and analyze the problem. Develop a solution. Write down the solution steps in detail.
Operations Making Things Happen.
ifstreams and ofstreams
Chapter Topics The Basics of a C++ Program Data Types
Engineering Problem Solving With C An Object Based Approach
What Actions Do We Have Part 1
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Completing the Problem-Solving Process
Basic Elements of C++.
Chapter 2 Assignment and Interactive Input
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Writing Reuseable Formulas
solve the following problem...
Basic Elements of C++ Chapter 2.
Chapter 2 – Getting Started
Chapter 2 Elementary Programming
Programming Funamental slides
Starting Out with C++: From Control Structures through Objects
Programming Funamental slides
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
CS150 Introduction to Computer Science 1
Mr. Dave Clausen La Cañada High School
Engineering Problem Solving with C++ An Object Based Approach
Life is Full of Alternatives
Chapter 1 Problem Solving with C++
What Actions Do We Have Part 1
ifstreams and ofstreams
Presentation transcript:

Object-Centered Design Software Engineering Object-Centered Design

Problem Solving Does anyone scuba dive? Let’s solve this scuba-diving problem: Write a program that, given a depth under water, computes the pressure at that depth.

Behavior A. Describe the desired behavior of the program: Our program should display a prompt for the depth on the screen, read the depth from the keyboard, compute the corresponding pressure, and display the pressure, along with a descriptive label on the screen.

Objects B. Identify the nouns in the behavioral description (other than program and user): Our program should display a prompt for the depth on the screen, read the depth from the keyboard, compute the corresponding pressure, and display the pressure, along with a descriptive label on the screen. These make up the objects in our program.

Operations C. Identify the verbs in the behavioral description: Our program should display a prompt for the depth on the screen, read the depth from the keyboard, compute the corresponding pressure, and display the pressure, along with a descriptive label on the screen. These make up the operations in our program.

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

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, if necessary...)

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

Performing Operations B. Identify the C++ operator to perform a given operation, if there is one... To compute pressure, we need to find the pressure-depth formula in a reference book...

Depth-to-Pressure In a reference book, we find that pressure is 0 atmospheres at depth 0 pressure increases 1 atmosphere every 33 feet. 1 atmosphere of pressure = 14.7 lbs./sq.in. Computing the pressure thus adds new objects and operations to our problem...

Objects (Revised)

Operations (Revised)

Documentation Always begin a file with an opening comment: /* pressure.cpp is a scuba-diving utility. * Author: J. Adams * Date: 1/1/98 * Purpose: Find pressure at a given depth. */

Coding: Program Stub /* pressure.cpp is a scuba-diving utility. * ... */ #include <iostream> // cin, cout, <<, >> using namespace std; int main() { }

Coding: Declaring Constants // ... int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM = 14.7; }

Coding: Algorithm Steps 0, 1 // ... int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM = 14.7; cout << “\nScuba Pressure Calculator!!” << “\n Enter the depth (feet): “; double depth; cin >> depth; }

Coding: Algorithm Step 2 // ... cout << “\nScuba pressure calculator!!” << “\n Enter the depth (feet): “; double depth; cin >> depth; double pressure = ((depth / FEET_PER_ATM) + 1) * LBS_PER_SQ_IN_PER_ATM; }

Coding: Algorithm Step 3 // ... double pressure = ((depth / FEET_PER_ATM) + 1) * LBS_PER_SQ_IN_PER_ATM; cout << “\nThe pressure at “ << depth << “ feet is “ << pressure << “lbs/sq.in.” << endl; }

Testing Run your program using sample data (whose correctness is easy to check): Scuba Pressure Calculator!! Enter the depth (feet): 33 The pressure at 33 feet is 29.4 lbs/sq.in.

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

Summary (ii) 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.