210 likes | 375 Views
Object-Oriented Design. A technique for developing a program in which the solution is expressed in terms of objects -- self- contained entities composed of data and operations on that data. istream cin; // Input stream variables : type istream
E N D
Object-Oriented Design • A technique for developing a program in which the solution is expressed in terms of objects -- self- contained entities composed of data and operations on that data. • istream cin; // Input stream variables: type istream • ostream cout; // Output stream variables: type ostream cin cout << >> setf get Private data Private data . . . . . . ignore setw 1 expanded by J. Goetz, 2004
OBJECT FUNCTION Operations Data FUNCTION OBJECT OBJECT Operations Data FUNCTION Operations Data Two Programming Methodologies Functional Object-Oriented Decomposition Design expanded by J. Goetz, 2004
What is an object? OBJECT set of functions internal state Operations Data expanded by J. Goetz, 2004
An object contains data and operations checkingAccount OpenAccount Private data: accoutNumber balance WriteCheck MakeDeposit IsOverdrawn GetBalance expanded by J. Goetz, 2004
myprog.cpp myprog.obj myprog.exe SOURCE OBJECT EXECUTABLE written in C++ written in machine language written in machine language via compiler via linker other code from libraries, etc. Three C++ Program Stages C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
SEQUENCE . . . Statement Statement Statement C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
SELECTION (branch) IF Condition THEN Statement1 ELSE Statement2 True Statement1 Statement Condition . . . Statement2 False C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
Statement LOOP (repetition) WHILE Condition DO Statement1 False . . . Condition True C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
SUBPROGRAM (function) . . . SUBPROGRAM1 SUBPROGRAM1 a meaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
Input Device Output Device Computer Components Peripherals Central Processing Unit ( CPU ) Control Unit Arithmetic Logic Unit Auxiliary Storage Device Memory Unit ( RAM & Registers ) C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
Program With Several Functions main function square function cube function C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
Output Statements cout << Expression << Expression . . . ; SYNTAX It converts (appends) the right-hand operand to a sequence of characters (to an output stream – an endless sequence of characters) which goes to the standard output device. These examples yield the same output: cout << “The answer is “ ; cout << 3 * 4 ; cout << “The answer is “ << 3 * 4 ; C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
Output Statements cout << Expression << Expression . . . ; SYNTAX It converts (appends) the right-hand operand to a sequence of characters (to an output stream – an endless sequence of characters) which goes to the standard output device. These examples yield the same output: cout << “The answer is “ ; cout << 3 * 4 ; cout << “The answer is “ << 3 * 4 ; C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
Keyboard Screen executing program No I/O is built into C++ • instead, a library provides input stream and output stream istream ostream 14 expanded by J. Goetz, 2004
Input Statements SYNTAX These examples yield the same result. cin >> length ; cin >> width ; cin >> length >> width ; cin >> Variable >> Variable .. . ; 15 expanded by J. Goetz, 2004
No I/O is built into C++ • Instead, a library provides an output stream Screen executing program ostream 16 expanded by J. Goetz, 2004
floating address float double long double pointer reference C++ Data Types simple structured integral enum array struct union class char short int long bool C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
simple types integral floating char short int long bool enum float double long double unsigned C++ Simple Data Types C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004
Integration Testing Approaches TOP-DOWN Assumption: the lower levels work correctly BOTTOM-UP Ensures individual modules work together correctly, beginning with the lowest level. Ensures correct overall design logic and the interfaces between modules are correct. USES: placeholder USES: a test driver to call module “stubs” to test the functions being tested. the order of calls. A stub may consist a single/Effective in a group programming group trace/debug output statements environment where each programmer has tested already own modules/functions. expanded by J. Goetz, 2004