Advanced Object Modeling and System Design

Object-Oriented Modeling Goals and Phases

Object-oriented design involves object-oriented decomposition to identify system objects and their interactions. This strategy results in systems where incremental change is easy, reuse is supported, and the design remains closer to the problem domain. Modeling consists of three distinct phases:

  • Object modeling

  • Dynamic modeling

  • Function modeling

Aggregation and Composition

Aggregation represents the "has-a" or "part-of" relationship, acting as a tightly coupled form of association. It depicts complex objects as assemblies of component objects. In UML, a link is placed between the "whole" and "parts" classes with an open diamond head attached to the whole class. Tests by Grady Booch to identify aggregation include:

  • The use of the phrase "part of" to describe the relationship.

  • Operations on the whole automatically applying to parts.

  • Values of attributes propagating from the whole to the parts.

  • Existence of an intrinsic asymmetry where one class is subordinate to another.

Composition is a stronger form of aggregation implying exclusive ownership. In this relationship, parts may be created after the composite, but they are explicitly removed before the destruction of the composite. It is denoted in UML by a filled diamond.

Abstract Class Concepts

An abstract class specifies required behaviors through methods without providing an implementation body. These classes cannot be instantiated directly and must be subclassed to create concrete classes.

  • Abstract classes organize specific subclasses under a common superclass that has no concrete meaning independently.

  • Abstract methods must be overridden in a subclass; they cannot be called directly.

  • Concrete classes, which have actual object occurrences, must appear at the bottom of a class hierarchy.

Multiple Inheritance and Delegation

Multiple inheritance allows a class to inherit features from more than one parent class, allowing information to be mixed from multiple sources. While it provides greater modeling power, it can lead to complex and ambiguous situations. Because it is not supported in all languages, such as Smalltalk, restructuring techniques include:

  • Delegation: Forwarding an operation from one object to another.

  • Nested Generalization: Factoring one criterion first, then multiplying out combinations.

  • Rumbaugh et al. suggest that if one superclass dominates, multiple inheritance should be implemented via single inheritance and delegation.

Generalization and Specialization

Generalization and specialization are inverse activities. Generalization is a bottom-up activity that extracts common properties from a collection of classes to place them in a superclass. Specialization is a top-down activity that refines an abstract class into concrete subclasses by adding specific features.

  • Query operations are inherited by all subclasses.

  • Update operations are inherited across extensions.

  • Update operations on constrained attributes are blocked across a restriction.

  • Methods implementing an operation must maintain the same protocol.

Metadata, Keys, and Integrity Constraints

Metadata is defined as a set of data that describes other data, such as class descriptions used for object instantiation. Identification within these models requires specific keys:

  • Primary Key: An attribute or combination that uniquely identifies an object instance (e.g., customer number).

  • Candidate Keys: Possible primary keys not selected for final use.

  • Secondary Key: An attribute used to describe sets of instances sharing common characteristics.

Integrity constraints ensure the validity of the data model:

  • Referential Integrity: Constraints on associations to maintain database consistency.

  • Insert Rules: Classified as Dependent, Automatic, Nullify, Default, Customized, or No Effect.

  • Domain Integrity: Constraints on valid ranges and types, such as x≥21x ≥ 21 or 0<x<1000 < x < 100.

  • Triggering Operation Rules: Govern the validity of inserts, deletes, and updates based on specific conditions and actions.

Questions & Discussion

  • Check Your Progress 1:

  1. A class inherits its parent’s? Answer: (c) Attributes, operations, relationships.

  2. Which is not a characteristic of an object? Answer: (c) Action.

  3. Which is not a characteristic of an abstract class? Answer: (d) None of the above.

  4. When are abstract classes to be used in a system? Answer: To relate concepts common to multiple classes and model an abstract superclass to group classes associated with each other or aggregated together.

  • Check Your Progress 2:

  1. Polymorphism can be described as? Answer: (a) Hiding many different implementations behind one interface.

  2. What phrase best represents a generalization relationship? Answer: (b) is a kind of.

  3. All update operations in inheritance are updated? Answer: (a) across all extensions.

  4. Is generalization and specialization reverse of each other? Why? Answer: Yes. An object type hierarchy models general concepts at the top (parent) and specific types as children.

  • Check Your Progress 3:

  1. Explain if the UML class diagram in Figure 6.8 is correct. Answer: The diagram is incorrect. Classes are not allowed to have multiple associations unless defined by different roles.

  2. Model a computer built out of one or more CPUs, Sound Card, and Video. Answer: A class diagram where a Computer is associated with components showing multiplicities such as 1..∗1..* for Sound Card and Video Card.

  3. Draw the class diagram for WindowWithScrollbar as a subclass of Window. Answer: A diagram showing WindowWithScrollbar as a subtype of Window with a separate association to Scrollbar.