Software Engineering Object-Centered Design. Problem Solving Does anyone scuba dive? Let’s solve this scuba-diving problem: Write a program that, given.

Slides:



Advertisements
Similar presentations
The Software Lifecycle. Example Problem: Update a Checkbook Write a program that allows the user to enter a starting balance, a transaction type, D or.
Advertisements

LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
Problem Solving and Program Design Programming. COMP102 Prog Fundamentals I : Problem Solving and Program Design/Slide 2 Problem Solving Process l Define.
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.
1 Session-I & II CSIT-121 Spring 2006 Session Targets Introducing the VC++.NET Solving problems on computer Programming in C++ Writing and Running Programs.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
Computer Programming 1 Problem Solving and Software Engineering.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
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.
1 Lab-1 CSIT-121 Fall 2004 Lab Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming Exercise.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
CS 117 Section 2 + KNET Computer accounts – ed to KNET students –Change password Homework 1 Lab Tutors –In lab for next 2 weeks –Will help you with.
Basic Elements of C++ Chapter 2.
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.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
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.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Controlling Function Behavior Sequence, Selection and Repetition.
1 Chapter-01 Introduction to Software Engineering.
Beginning C++ Through Game Programming, Second Edition
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.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
Practice Building Classes Modeling Objects. Problem Write a program that computes the Dean’s List (full-time students whose GPA 3.0), using a student.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Vectors One-Dimensional Containers. Problem A file contains a sequence of names and scores: Ann92 Bob84 Chris89... Using OCD, design and implement a program.
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.
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.
Chapter Topics The Basics of a C++ Program Data Types
Engineering Problem Solving With C An Object Based Approach
Completing the Problem-Solving Process
Basic Elements of C++.
Writing Reuseable Formulas
solve the following problem...
Basic Elements of C++ Chapter 2.
Chapter 2 – Getting Started
Starting Out with C++: From Control Structures through Objects
Object-Centered Design
Presentation transcript:

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