1 / 19

Object-Oriented Design

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

arvid
Download Presentation

Object-Oriented Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. What is an object? OBJECT set of functions internal state Operations Data expanded by J. Goetz, 2004

  4. An object contains data and operations checkingAccount OpenAccount Private data: accoutNumber balance WriteCheck MakeDeposit IsOverdrawn GetBalance expanded by J. Goetz, 2004

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

  6. SEQUENCE . . . Statement Statement Statement C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004

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

  8. Statement LOOP (repetition) WHILE Condition DO Statement1 False . . . Condition True C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004

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

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

  11. Program With Several Functions main function square function cube function C++ Programming: Program Design Including Data Structures, Second Edition expanded by J. Goetz, 2004

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

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

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

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

  16. No I/O is built into C++ • Instead, a library provides an output stream Screen executing program ostream 16 expanded by J. Goetz, 2004

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

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

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

More Related