DOC PREVIEW
SJSU CMPE 133 - Object-Oriented Concepts

This preview shows page 1-2-20-21 out of 21 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Software System EngineeringSlide 2Slide 3ObjectsClassesAttributesObject Behavior (1)Object Behavior (2)Message (1)Message (2)Methods vs. MessagesEncapsulationClass HierarchyInheritanceDynamic InheritanceMultiple InheritancePolymorphismAssociationsConsumer-Producer AssociationAggregationsDiscussion Questions© M.E. Fayad 2000 -- 2006SJSU -- CMPESoftware System EngineeringDr. M.E. Fayad, ProfessorComputer Engineering Department, Room #283I College of EngineeringSan José State UniversityOne Washington SquareSan José, CA 95192-0180 http://www.engr.sjsu.edu/~fayad© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S2 OO Concepts2Lesson 5:Object-Oriented Concepts© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S3 OO Concepts Lesson ObjectivesObjectives3 Understand OO concepts Explore OO modelsObjectsClassesMethodsAssociationsetc…© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S4 OO Concepts4 ObjectsWhen developing OO application, two basic questions:–What objects does the application need?–What are the characteristics of these objects–What functionality should these objects have?© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S5 OO Concepts5 ClassesObjects are grouped in classesClasses are used to distinguish one type of object from anotherA class is a set of objects that share some common structures and behaviors–Each object is an instance of a classIn an OO system, behavior of an object is defined by its class© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S6 OO Concepts6 AttributesAttributes are properties of an object–E.g., color, cost, make, and model of a car objectProperties represent the state of an object© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S7 OO Concepts7 Object Behavior (1)Object behavior is described in procedures, interfaces or methodsA method is defined for a class and can access the internal state of an object of that class to perform some operation© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S8 OO Concepts8 Object Behavior (2)Behavior denotes the collection of methods that abstractly describes what an object is capable of doing –Each method defines and describes a particular behavior of an objectObjects take responsibility of their own behavior–E.g., an employee object knows how to compute its salary© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S9 OO Concepts9 Message (1)Objects perform operations in response to messagesMessage is different from a subroutine call–Different objects can respond to the same message in different ways•e.g., cars, motorcycles, and bicycles will all respond to a stop message -- but differentlyA message has a name© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S10 OO Concepts10 Message (2)An object understands a message when it can match the message to a method that has the same name as the messageMessage differs from function–Function says how to do something–Message says what to do© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S11 OO Concepts11 Methods vs. MessagesMessage is the instructionMethod is the implementationE.g., making French onion soup–Telling someone to make a Greek Salad is the message–The way the Greek Salad is prepared is the method–The Greek Salad is the object© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S12 OO Concepts12 EncapsulationEncapsulation is a form of information hidingAn object encapsulates the data and methods–User cannot see the inside of the object “capsule,” but can use the object by calling the object’s methods–No object can operate directly on another object’s data -- Important Point.© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S13 OO Concepts13 Class HierarchyAn object-oriented system organizes classes into a subclass-superclass hierarchy–superclass = base class or ABC class–subclass = derived class or concrete classAt the top of the class hierarchy are the most general classes and at the bottom are the most specific© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S14 OO Concepts14 InheritanceInheritance allows classes to share and reuse behaviors and attributesA subclass inherits all of the properties and methods defined in its superclass© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S15 OO Concepts15 Dynamic InheritanceAllows objects to change and evolve over timeSuperclasses (or base classes) provide properties and attributes for objects–Changing superclasses changes the properties and attributes of a classAbility to add, delete, or change parents from objects (or classes) at run time© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S16 OO Concepts16 Multiple InheritanceA class can inherit its state (attributes) and behaviors from more than one superclassExample: a utility vehicle inherits attributes from both the Car and Truck classes© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S17 OO Concepts17 PolymorphismThe same operation may behave differently on different classesExample: in a payroll system, manager, office worker, and production worker are objects that respond to the compute payroll message -- but differently© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S18 OO Concepts18 AssociationsAssociation represents the relationship between objects and classesAssociations are bidirectional.Associations have cardinality.–How many instances of one class may relate to a single instance of an associated class© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S19 OO Concepts19 Consumer-Producer AssociationSpecial form of association–Also known as client-server association or a use relationshipViewed as a one-way interaction–One object requests the service of another object© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S20 OO Concepts20 AggregationsAll objects, except the most basic ones, are composed of and may contain other objectsE.g., a car object is an aggregation of engine, seat, wheels, and other objects© M.E. Fayad 2000 -- 2006SJSU -- CmpE M.E. Fayad L3-1-S21 OO Concepts21 Discussion QuestionsWhat are the differences between inheritance and aggregation?T/F–Use relationship is an aggregation.–Aggregation is a special form of


View Full Document

SJSU CMPE 133 - Object-Oriented Concepts

Download Object-Oriented Concepts
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Object-Oriented Concepts and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Object-Oriented Concepts 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?