Software Engineering 1 (Chap. 1) Object-Centered Design.

Slides:



Advertisements
Similar presentations
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Advertisements

LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Problem Solving and Program Design Programming. COMP104 Lecture 3 / Slide 2 Problem Solving Process l Define and analyze the problem. l Develop a solution.
Problem Solving and Program Design. COMP104 Problem Solving / Slide 2 Our First Program // a simple program #include using namespace std; int main() {
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.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
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.
Programming is instructing a computer to perform a task for you with the help of a programming language.
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.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
COMPUTER SCIENCE I C++ INTRODUCTION
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.
Introduction to Algorithm Design and Documentation CSIS 1595: Fundamentals of Programming and Problem Solving 1.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics.
Software Life Cycle Requirements and problem analysis. –What exactly is this system supposed to do? Design –How will the system solve the problem? Coding.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
Introduction to Computers (L02) * Hardware * Software * Programming Languages * Three Phase of Program Development * Development and Design Steps * Algorithms.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Controlling Function Behavior Sequence, Selection and Repetition.
1 Chapter-01 Introduction to Software Engineering.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
C++ Loop Statements Repetition Revisited. Problem Using OCD, design and implement a function that, given a menu, its first valid choice, and its last.
Fundamental Programming: Fundamental Programming Introduction to C++
Libraries 1 Making Functions Globally Reusable (§ 4.6)
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*
1 An Example. Problem Using OCD, design and implement a program that computes the area and circumference of an Australian Rules Football field, which.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
1 Chapter-01 Introduction to Software Engineering.
COSC1557: Introduction to Computing Haibin Zhu, PhD. Professor Department of Computer Science Nipissing University (C) 2014.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
1 Original Source : and Problem and Problem Solving.ppt.
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!
Lecture 4 Function example. Example1 int max (int a, int b) { int c; if (a > b) c = a; else c = b; return (c); } void main ( ) {int x, y; cin>>x>>y; cout.
Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:
Simple Functions Writing Reuseable Formulas. Problem Using OCD, design and implement a program that computes the area and circumference of an Australian.
The Hashemite University Computer Engineering Department
1 CS 1430: Programming in C++. 2 Input: Input ends with -1 Sentinel-Controlled Loop Input: Input begins with.
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.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
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.
Introduction to Computers and C++ Programming
Engineering Problem Solving With C An Object Based Approach
Completing the Problem-Solving Process
Chapter 2 Assignment and Interactive Input
Writing Reuseable Formulas
solve the following problem...
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Life is Full of Alternatives
Object-Centered Design
Presentation transcript:

Software Engineering 1 (Chap. 1) Object-Centered Design

Problem Solving Let’s solve this temperature-conversion problem: Write a program that, given a temperature in Celsius, displays that temperature in Fahrenheit. 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance OCD (Object-Centered Design)

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

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

Operations These make up the ______________ in our program. 5 B. Identify the verbs in the behavioral description: Our program should display a prompt for the Celsius temperature on the screen, read that temperature from the keyboard, compute the corresponding Fahrenheit temperature, and display that temperature, along with a descriptive label on the screen.

Algorithm D. Organize the objects and operations into a sequence of steps that solves the problem, called an _________________. 1. Display a prompt for the Celsius temperature on the screen. 2. Read the temperature from the keyboard. 3. Compute the Fahrenheit temperature from the Celsius temperature. 4. Display the Fahrenheit temperature, plus an informative label on the screen. 6

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

Representing Objects A. Determine a ________________________ for each object: 8

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

Celsius to Fahrenheit In a reference book, we find that fahrenheit = 1.8  celsius + 32 Converting the temperature thus adds new objects and operations to our problem...

Objects (Revised) 11 Objects (Revised)

Operations (Revised) 12

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } The Code 13

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } Documentation Always begin a program with an opening comment. 14

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } Libraries This loads the C++ library that we need. 15

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } main() All C++ programs have a main function. 16

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } Step 1: Print introductory message. 17

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } Step 2: Read the Celsius temperature. 18

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } Step 3: Calculate the Fahrenheit temperature. 19

/* temperature.cpp converts Celsius * temperatures to Fahrenheit. * * Larry Nyhoff CPSC 155X Feb. 5, 2001 * * Input: A Celsius temperature * Output: Corresponding Fahrenheit temperature */ #include // cin, cout, > using namespace std; int main() { cout << "Temperature Converter!!" << endl << "Please enter the temperature in Celsius: "; double celsius; cin >> celsius; double fahrenheit = 1.8 * celsius + 32; cout << endl << celsius << " degrees Celsius is " << fahrenheit << " degrees Fahrenheit." << endl; } Step 4: Display the results. 20

Testing (i) Run your program using sample data (whose correctness is easy to check): Temperature Converter!! Please enter the temperature in Celsius: 0 0 degrees Celsius is 32 degrees Fahrenheit. 21

Testing (ii) Do many tests on “interesting” data points. Temperature Converter!! Please enter the temperature in Celsius: degrees Celsius is degrees Fahrenheit. 22

Summary Writing a program consists of these steps: 1. __________ your program (using ______). 2. __________ your design. 3. __________ your program. 4. _____________________ your program as necessary. 23

Summary (ii) OCD is a methodology for designing programs: 1. Describe the desired _________ of the program. 2. Identify the _________ required. 3. Identify the _________ required. 4. Organize objects and operations into an ____________, refining object and operation lists as necessary. 24