L14 - OO Basics - Object Oriented Design Basics Why didn't...

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

View Full Document Right Arrow Icon
Object Oriented Design Basics Why didn’t we start with this? We needed more depth of knowledge and more comfort with C++ – Needed to know about basic control structures – Needed to be aware of structured programming strategies and techniques – Needed to know more about functions and templates – Needed to know something about data structuring (e.g. arrays and strings) and pointers Key concepts: – Object orientation encapsulates data and functions: The data aspects of an object represent its attributes The function aspects of an object implement its behaviors –A class is the definition of an object type Lot of objects of the same type can be created (or instantiated ) from one class definition
Background image of page 1

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

View Full DocumentRight Arrow Icon
Object Oriented Design Basics (cont.) The idea is that a class defines the “template” for a type of object, including: – Its attributes (the data aspects) – Its methods (the behavioral aspects) The principle of information hiding is critical – Objects can communicate with one another across well defined interfaces, but – One object does not know how others are implemented This means that as long as the interfaces are well defined, the programmer can change the implementations without affecting applications – For example, if one were to define an object called cylinder with: Attributes: radius, height Methods: circumference(), volume() – From the outside, anyone using a cylinder does not need to know how radius and height are represented or how the circumference and volume are calculated
Background image of page 2
Procedural vs. Object-Oriented Programming Procedural Object Oriented Programs are: action oriented object oriented Unit of Programming: function: performs an action object: with behavior and attributes A program is: grouping of functions grouping of objects Role of data: data is secondary – exists to support functions data and behavior are equally important data members + methods Program specification: verbs in the req doc determine functions nouns in the req doc determine classes Instance variable is an instance of a built-in type Object is an instance of a user-defined type Programmer- defined type: structure (struct) object
Background image of page 3

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

View Full DocumentRight Arrow Icon
How Did C++ Classes Evolve? In C, programmers could define their own aggregate data types called structures using the struct keyword Structures in C: – A collection of elements – Elements not required to be of the same type – All elements are data (no functions) – Defined using the keyword struct Example: struct weather { int maxtemp; int mintemp; }; Keyword struct introduces the structure definition The structure tag names the the structure definition used to declare variables of the structure type Data members: used to declare variables of the structure type
Background image of page 4
More on C Struct’s • Data members can be of any known type – They cannot be an instance of this structure’s type – But they can be a pointer to another structure of the same type • Data members of the same structure have to
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/08/2008 for the course EE 361 taught by Professor Conry during the Spring '08 term at Clarkson University .

Page1 / 20

L14 - OO Basics - Object Oriented Design Basics Why didn't...

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

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