lecture32 OOP and Inheritance

lecture32 OOP and Inheritance - CMPT 128: Introduction to...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
1 © Janice Regan, CMPT 128, February. 2007 CMPT 128: Introduction to Computing Science for Engineering Students Object oriented design Objects How and Why? Inheritance
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Janice Regan, CMPT 128, February. 2007 2 Why have we been learning objects? We have been using two different approaches to solving a problem Process oriented Consider the whole problem Divide the problem into a series of processes Develop an algorithm, then a program to implement each process Combine the processes to solve the whole problem Object oriented Think in terms of a group of objects Think how each of the objects interacts with the other objects in the system Build each object then combine all the objects into the system
Background image of page 2
© Janice Regan, CMPT 128, February. 2007 3 Problem Solving Methodology: Process Oriented Problem Specification: State the problem clearly, determine inputs and outputs Analysis: How to go from input to output Design: Developing a step by step method Doing a sample by hand is a good way to start Test Plan: How do you test to determine your algorithm works Implementation or coding Testing Refinement
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Janice Regan, CMPT 128, February. 2007 4 Problem Solving Methodology: Object Oriented Determine what you are building: define requirements Analysis and Design: Identify objects in the system and how they interact. Develop interfaces between objects that enable the required interactions, Test Plan: How do you test your object Create and manipulate object using each of its methods Implementation or coding Testing Integration with other objects Working System
Background image of page 4
© Janice Regan, CMPT 128, February. 2007 5 Advantages of Objects An object 'encapsulates' or separates complexity from the rest of the system Implementation details are hidden from the other classes in the system. Other classes see only a simple interface to the object Complex actions that modify or determine properties of the object can be hidden from other classes in the system The complexity of the system is broken down into smaller easier to handle pieces Lets us think in terms of the objects in the system and how they interact. Intuitive!
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Janice Regan, CMPT 128, February. 2007 6 Encapsulation Hides implementation details of one module from other modules Hides complexity within each module from other modules. EXAMPLE The client of the ADT (abstract data type) only needs to know the ADT’s interface (see next slide)
Background image of page 6
© Janice Regan, CMPT 128, February. 2007 7 Abstract Data Type Example S T A C K POP() PUSH(item) ISEMPTY() Public Interface Accesses Implementation Option 1: Array 24 98 13 Implementation Option 2: Linked list 13 98 24 ADT or top top = 2 Accesses client
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Start with your requirements Lets see how we choose what objects are needed for a problem Start with your requirements: the description of what your system must do Sample problem:
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 34

lecture32 OOP and Inheritance - CMPT 128: Introduction to...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online