Object-Oriented Modeling

Introduction

An object-oriented approach to the whole software development process is now commonly used, particularly for interactive system development. This means expressing the system requirements using an object model, designing using objects, and developing the system in an object-oriented programming language such as Java, C++, Smalltalk, or Ada.

Object models that are developed during requirements analysis may be used to represent both system data and its processing. Therefore, they combine some of the uses of dataflow and semantic data models. They are also useful for showing how entities in the system may be classified and composed of other entities.

Developing object models during requirement analysis usually simplifies the transition to object-oriented design and programming.

Earlier, many methods of object-oriented analysis were proposed, and these methods had a great deal in common. A standard for object modeling was used—Unified Modelling Language (UML).

UML Object Class Structure

UML has an object class with the following three sections:

  • Top Section – Name of the object class

  • Middle Section – Class attributes

  • Lower Section – Operations associated with the object class

The following figure illustrates an object class in UML containing the above three sections.

Types of Object Models

1. Inheritance Model

Definition:
“Inheritance model describes the process of inheriting or acquiring properties and behavior from one class to another class.”

  • Inheritance plays a major role in any object-oriented programming concept.

  • It reflects the property of deriving one class property in another class.

  • The class being derived is referred to as the parent class, and the class acquiring these properties is the child class.

  • Consider a simple diagram depicting the animal kingdom to represent this.

2. Object Aggregation

Sometimes, we may encounter certain situations where a single object may have multiple objects associated with it. To model such situations, we usually resort to object aggregation.

Definition:
“Object embedded within another object is called object aggregation.”

  • Some objects are groupings of other objects. An object is an aggregate of a set of other objects.

  • Apart from acquiring attributes and services through an inheritance relationship with other objects, the classes representing these objects may be modeled using an object aggregation model.

  • UML notation for aggregation is to represent the composition by including a diamond shape on the source of the link.

Example: A computer system may be modeled as an aggregation of CPU, RAM, and storage components.

3. Object Behavior Modeling

The object behavior model indicates the behavior of individual objects and the overall behavior of the object-oriented system.

  • The behavior of an object is defined by its states and services.

  • It explains how an object reacts in terms of state changes when it is acted upon, and how it reacts to other objects by requesting services and operations.

  • The object behavior model shows how the operations provided by the object are used.

  • For object behavioral modeling, we usually use sequence diagrams provided by UML.

Example:
Consider an example of narrating different consequences observed during an ATM withdrawal using a sequence diagram.

  • Operations are indicated by labeled arrows, and the sequence of operations is demonstrated from top to bottom.

  • Objects are shown on the top of the diagram, such as Client, ATM, and Database.