2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer
Chapter © Prentice Hall, 2004 Chapter Objectives Af ter studying this chapter you should be able to: – Define an object. – Understand the terms class, attribute, and operations. – Explain generalization, polymorphism, and inheritance. – Define association. – Describe modeling and the Unified Modeling Language.
Chapter © Prentice Hall, 2004 Unified Modeling Language (UML) A standard notation for representing object- oriented systems Boxes represent classes, components, packages, objects – Containing attributes and operations – Provide interfaces to external entities Lines represent generalization and other relationships
Chapter © Prentice Hall, 2004 Sample UML Diagram
Chapter © Prentice Hall, 2004 What Is an Object? An entity that encapsulates data and behavior - Objects are categorized into classes - Each individual object is an instance of a class
Chapter © Prentice Hall, 2004 What Is Encapsulation? The characteristic of object-orientation in which data and behavior are bundled into a class and hidden from the outside world Access to the data and behavior is provided and controlled through an object’s interface
Chapter © Prentice Hall, 2004 What Is a Class? A category of objects that share the same attributes, operations, relationships, and semantics All objects are instances of classes
Chapter © Prentice Hall, 2004 Name Attributes Operations
Chapter © Prentice Hall, 2004 What Is an Attribute? Attribute- a named property of a class that describes a range of values that instances of the attribute might hold Attributes are the way classes encapsulate data
Chapter © Prentice Hall, 2004 Attributes are properties containing values Minus sign indicates these are private (hidden)
Chapter © Prentice Hall, 2004 What Is an Operation? A behavior of an object Implemented in classes are methods Methods are identified and invoked by their signatures, including name, parameters, and return type
Chapter © Prentice Hall, 2004 Signature identifies and invokes the behavior Method implements the behavior
Chapter © Prentice Hall, 2004 Method signatures Plus sign indicates these are public (accessible)
Chapter © Prentice Hall, 2004 What Is Generalization? A relationship between a more general (or parent) class and a more specific (or child) class The more specific class has additional attributes and operations
Chapter © Prentice Hall, 2004 What Is Inheritance? The mechanism by which the more specific class in a generalization relationship includes the attributes and operations of the more general class
Chapter © Prentice Hall, 2004 Generalization represented by arrows from subclass to superclass Subclasses inherit all attributes and operations of superclasses
Chapter © Prentice Hall, 2004 What Is Polymorphism? The ability for different classes of objects to respond to identical messages in different ways Polymorphism = “having many forms” Different behaviors for the same message
Chapter © Prentice Hall, 2004 Here, each type of vehicle has its own version of calcPrice()
Chapter © Prentice Hall, 2004 What Is a Component? A replaceable part of a system providing a clearly defined function through a set of interfaces Group of classes working together toward a common end; a subsystem
Chapter © Prentice Hall, 2004 What Is an Interface? The mechanism by which users of a component invoke its behaviors and manipulate its properties The interface is implemented by method signatures
Chapter © Prentice Hall, 2004 Interfaces are represented as small rectangles
Chapter © Prentice Hall, 2004 What Is a Package? A general-purpose mechanism for organizing elements into groups Group of classes sharing similar characteristics or purposes
Chapter © Prentice Hall, 2004
Chapter © Prentice Hall, 2004 What Is an Association? A relationship or link between instances of one, two, or more classes Three types: – Simple associations: no ownership – Aggregations: part-whole relationships where the part can exist independently of the whole – Compositions: part-whole relationships where the part and the whole are fully dependent on each other
Chapter © Prentice Hall, 2004 This is a binary association, showing roles and multiplicities
Chapter © Prentice Hall, 2004 Recap Af ter studying this chapter we learned to: – Define an object. – Understand the terms class, attribute, and operations. – Explain generalization, polymorphism, and inheritance. – Define association. – Describe modeling and the Unified Modeling Language.