DEV Community

Muhammad Salem
Muhammad Salem

Posted on

Object Oriented Approach

In the object-oriented approach, the focus is on capturing the structure and behavior of information systems into small modules that combines both data and process. The main aim of Object-Oriented Design (OOD) is to improve the quality and productivity of system analysis and design by making it more usable.

In analysis phase, OO models are used to fill the gap between problem and solution. It performs well in situation where systems are undergoing continuous design, adaption, and maintenance. It identifies the objects in problem domain, classifying them in terms of data and behavior.

The OO model is beneficial in the following ways −

It facilitates changes in the system at low cost.

It promotes the reuse of components.

It simplifies the problem of integrating components to configure large system.

It simplifies the design of distributed systems.

Elements of Object-Oriented System

Let us go through the characteristics of OO System −

Objects − An object is something that is exists within problem domain and can be identified by data (attribute) or behavior. All tangible entities (student, patient) and some intangible entities (bank account) are modeled as object.

Attributes − They describe information about the object.

Behavior − It specifies what the object can do. It defines the operation performed on objects.

Class − A class encapsulates the data and its behavior. Objects with similar meaning and purpose grouped together as class.

Methods − Methods determine the behavior of a class. They are nothing more than an action that an object can perform.

Message − A message is a function or procedure call from one object to another. They are information sent to objects to trigger methods. Essentially, a message is a function or procedure call from one object to another.

Features of Object-Oriented System
An object-oriented system comes with several great features which are discussed below.

Encapsulation
Encapsulation is a process of information hiding. It is simply the combination of process and data into a single entity. Data of an object is hidden from the rest of the system and available only through the services of the class. It allows improvement or modification of methods used by objects without affecting other parts of a system.

Abstraction
It is a process of taking or selecting necessary method and attributes to specify the object. It focuses on essential characteristics of an object relative to perspective of user.

Relationships
All the classes in the system are related with each other. The objects do not exist in isolation, they exist in relationship with other objects.

There are three types of object relationships −

Aggregation − It indicates relationship between a whole and its parts.

Association − In this, two classes are related or connected in some way such as one class works with another to perform a task or one class acts upon other class.

Generalization − The child class is based on parent class. It indicates that two classes are similar but have some differences.

Inheritance
Inheritance is a great feature that allows to create sub-classes from an existing class by inheriting the attributes and/or operations of existing classes.

Polymorphism and Dynamic Binding
Polymorphism is the ability to take on many different forms. It applies to both objects and operations. A polymorphic object is one who true type hides within a super or parent class.

In polymorphic operation, the operation may be carried out differently by different classes of objects. It allows us to manipulate objects of different classes by knowing only their common properties.

Object Oriented Systems Development Activities

Object-oriented systems development includes the following stages −

Object-oriented analysis

Object-oriented design

Prototyping

Implementation

Incremental testing

Object-Oriented Analysis

This phase concerns with determining the system requirements and to understand the system requirements build a use-case model. A use-case is a scenario to describe the interaction between user and computer system. This model represents the user needs or user view of system.

It also includes identifying the classes and their relationships to the other classes in the problem domain, that make up an application.

Object-Oriented Design

The objective of this phase is to design and refine the classes, attributes, methods, and structures that are identified during the analysis phase, user interface, and data access. This phase also identifies and defines the additional classes or objects that support implementation of the requirement.

I'll provide examples to illustrate the difference between Methods and Messages, and then discuss domain modeling techniques.

Let's start with Methods and Messages:

Methods are functions defined within a class that describe the behavior of objects of that class. Messages, on the other hand, are the actual invocations of these methods, typically from one object to another.

Here's a simple example in Java to illustrate this:

class Car {
    private int speed = 0;

    // This is a method
    public void accelerate(int increment) {
        speed += increment;
        System.out.println("Car speed is now: " + speed);
    }
}

class Driver {
    public void drive(Car car) {
        // This is sending a message
        car.accelerate(20);
    }
}

public class Main {
    public static void main(String[] args) {
        Car myCar = new Car();
        Driver driver = new Driver();
        driver.drive(myCar);
    }
}
Enter fullscreen mode Exit fullscreen mode

In this example:

  • The accelerate function in the Car class is a method. It defines behavior that a Car object can perform.
  • In the Driver class, car.accelerate(20) is a message. It's the actual invocation of the accelerate method on a Car object.

The key difference is that methods define behavior, while messages are the actual communication between objects, invoking those behaviors.

Now, let's discuss domain modeling:

Domain modeling is the process of creating a conceptual model of a specific problem domain. It's a crucial step in software development that helps in understanding the problem space and designing effective solutions.

Techniques used by professional software engineers for domain modeling include:

  1. Entity-Relationship Diagrams (ERD):

    • Used to model the relationships between entities in a system.
    • Helpful for database design and understanding data structures.
  2. Class Diagrams:

    • Part of UML (Unified Modeling Language).
    • Show classes, their attributes, methods, and relationships with other classes.
  3. Use Case Diagrams:

    • Also part of UML.
    • Illustrate the interactions between users (actors) and the system.
  4. Domain-Driven Design (DDD):

    • A comprehensive approach that focuses on the core domain and domain logic.
    • Emphasizes collaboration between technical and domain experts.
  5. Event Storming:

    • A workshop-based method to quickly explore complex business domains.
    • Involves mapping out domain events, commands, aggregates, and more.
  6. Behavior-Driven Development (BDD):

    • Uses specific language patterns to describe the behavior of the system.
    • Often involves writing scenarios in a "Given-When-Then" format.
  7. Conceptual Mapping:

    • Creating visual representations of concepts and their relationships.
    • Can include mind maps, concept maps, or other visual diagrams.
  8. Object-Role Modeling (ORM):

    • A method for modeling and querying information systems at the conceptual level.

The choice of technique often depends on the specific needs of the project, the complexity of the domain, and the preferences of the team. Many professionals use a combination of these techniques to get a comprehensive understanding of the domain.

In practice, domain modeling often involves:

  1. Identifying key entities and their attributes
  2. Defining relationships between entities
  3. Mapping out processes and workflows
  4. Capturing business rules and constraints
  5. Iterating and refining the model based on feedback and new insights

Remember, domain modeling is an iterative process. As you learn more about the domain, you continually refine and improve your model.

Top comments (0)