Object-Oriented Modeling
Phases of object-oriented systems development cycle
Object Object: An entity that has state, behavior, and identity. Tangible: Person, place or thing. Concept or Event: Department, performance, marriage, registration. Artifact of the Design Process: User interface, controller, scheduler.
State, Behavior, Identity State: Attribute types and values. Behavior: How an object acts and reacts. Behavior is expressed through operations that can be performed on it. Identity: Every object has a unique identity, even if all of its attribute values are the same.
Objects and Operations Object Class: Set of objects that share a common structure and a common behavior. Class Diagram: Fig. 5-2a. Object or Instance Diagram: Fig. 5-2b. Operation: A function or service that is provided by all the instances of a class. Encapsulation: Hiding an object’s implementation details.
UML class and object diagrams (a) Class diagram showing two classes
(b) Object diagram with two instances
Operations Types of Operations: Constructor: Creates a new instance of a class. Query: Accesses the state of an object but does not alter its state. Update: Alters the state of an object.
Associations Association: Relationship among object classes (Fig. 5-3). Association Role: Role of an object in an association (e.g. Manager in the Manages association of Fig. 5-3a.) Multiplicity: How many objects participate in an association. Lower-bound..Upper bound. Examples: Figs 5-4,5.
Examples of binary association relationships (a) University example
(b) Customer service example
Association Class Association Class: An association which has attributes or operations of its own or which participates in relationships with other classes. (Fig. 5-6,7)
Object diagram for customer order example
Association class and link object (a) Class diagram showing association classes
(b) Object diagram showing link objects
Ternary relationship with association class
Derived attribute, association, and role
Generalization Common attributes, relationships, AND operations. Subclass, superclass. (Fig. 5-9a) Abstract Class: No direct instances Concrete Class: Direct instances (Fig. 5-9b)
Examples of generalization, inheritance, and constraints (a) Employee superclass with three subclasses
Constraints Overlapping (Fig. 5-10) Disjoint Complete (“total specialization”) - all subclasses specified. Incomplete (“partial specialization”) - some subclasses specified.
Example of overlapping constraint
Class-Level Attribute Class-Level Attribute: Specifies a value common to an entire class, rather than a specific value for an instance. (Fig. 5-11) “=“ is initial, default value.
Polymorphism Abstract Operation: Defines the form or protocol of the operation, but not its implementation. (calc-tuition in Fig 5-11) Method: The implementation of an operation. Polymorphism: Modifications in an operation to apply to different classes.
Overriding Inheritance Overriding: The process of replacing a method inherited from a superclass by a more specific implementation of that method in a subclass. For Extension: add code. For Restriction: limit the method. (Fig. 5-12) For Optimization: improve code by exploiting restrictions imposed by the subclass.
Overriding inheritance
Multiple Inheritance Multiple Classification: An object is an instance of more than one class. Multiple Inheritance: A class inherits features from more than one superclass. (Fig. 5-13)
Aggregation Aggregation: A part-of relationship between a component object and an aggregate object. (Fig. 5-14) Composition: A stronger form of aggregation in which a part object belongs to only one whole object and exists only as part of the whole object. (solid diamond in Fig. 5-15) Recursive Aggregation: Fig. 5-16.
Additional Concepts Abstract Data Type (ADT): Define a new data type and a set of operations that can act upon it. Example: matrix.
Class diagram for Pine Valley Furniture Company