Blog Details
Sarfaraz Muhammad Sajib
03 Oct 2024
5 min read
Object Oriented Analysis, in short OOA, is an important activity in the software development process because it pinpoints key objects from the requirements of a system. The highlighted objects further transform into classes that bind data and behaviors together. OOA aligns software with real-world entities for more maintainability, scalability, and flexibility.
At Mediusware, this helps us model systems efficiently by identifying core objects from the problem domain.
Key Steps in OOA:
1. Understanding Requirements:
It involves analyzing the system's requirements of what need to be extracted as main objects. Objects can be anything that really exists; the system must model people, projects, events, or anything.
2. Identifying Main Objects (Classes):
Once these are clearly known, define main objects or classes. These objects represent logical units in the system, both with attributes or data and methods or behaviors.
At Mediusware, the following objects could be central, for example:
3. Relationship among Objects:
OOA identifies not only objects alone but also how they are coupled to each other. The common relationships existing among elements are:
4. Declaration of Attributes and Methods:
Each class should encapsulate its own attributes and methods. For instance, the Employee class could have attributes such as name and position, and methods including calculateWorkHours().
The Project class would likely have methods like generateReport() and attributes like deadline.
Benefit of OOA
In Object-Oriented Design, we model software systems by creating objects representing real-world entities or abstract concepts. These will contain data in the form of attributes and methods for the manipulation of this data. The goal of OOD is to build systems that are modular, maintainable, and scalable by organizing the software in a way intuitive to how people understand and interact with the world.
What We Do in OOD:
Identify Objects: We start by identifying the key objects in the problem domain that will be represented as objects. For example, objects could include books, members, and staff in a library management system.
Define Classes: After we find the objects, we then define the classes. A class is a blueprint or template from which objects can be created; it describes what attributes and methods the objects will have.
Define Relationships: We define how objects would interact with each other. Objects may communicate via methods or by inheritance from other objects, or be in hierarchical relationships.
Apply Core Principles: We will actually apply most of the OOD principles here, during the identification process: encapsulation, abstraction, and so on, to keep the system flexible and maintainable.
Core principles of OOD:
Benefit of OOD
Object-Oriented Programming is a paradigm where a program centers on objects. Objects are actual instantiations of classes, whereby a class acts like a blueprint or a template that defines the attributes, denoting data, and methods, denoting behaviors, of an object. This approach of OOP helps in organizing complex systems by grouping related data and functions together.
Key Concepts in OOP:
Encapsulation:
Encapsulation is the process of packaging data and methods operating on that data in a single unit, called the class. This principle protects the internal state of an object from outside interference; it facilitates data integrity and allows access to data only through its public methods, the so-called Getter and Setter.
Abstraction:
Abstraction simplifies complex reality by modeling classes based on essential characteristics and behaviors. It enables developers to focus on high-level functionality by hiding the details of the implementation. This decreases the complexity, making the code more readable.
Inheritance:
It is the process in which a new class, called a subclass, is derived from an already existing class, the superclass. In this way, the new class inherits the properties and methods of the superclass. This allows for code reusability and provides a hierarchical relationship between classes, hence keeping the code more organized and permitting further extension.
Polymorphism:
With polymorphism, objects could be treated as if they were of their parent class, and a single interface would be used to represent various data types. This flexibility extends the capability of methods to process the objects of different classes by means of method overriding and overloading.
Benefit of OOP
Let's see an example of OOP in C# Language, in the context of running a software company.
using System;
class Employee
{
public string Name { get; }
public string Position { get; }
public Employee(string name, string position) => (Name, Position) = (name, position);
public void Work() => Console.WriteLine($"{Name} is working as a {Position}.");
}
class Client
{
public string Name { get; }
public string Company { get; }
public Client(string name, string company) => (Name, Company) = (name, company);
public void RequestProject() => Console.WriteLine($"{Name} from {Company} requested a new project.");
}
class Project
{
public string ProjectName { get; }
public Employee Manager { get; }
public Client Client { get; }
public Project(string projectName, Employee manager, Client client) =>
(ProjectName, Manager, Client) = (projectName, manager, client);
public void StartProject() => Console.WriteLine($"{ProjectName} is managed by {Manager.Name} for {Client.Company}.");
}
class Program
{
static void Main()
{
// Create Employee (Project Manager)
var manager = new Employee("Seikh Jashim Uddin", "Project Manager");
// Create Client
var client = new Client("Danny Huffman", "Clevere AI");
// Create Project
var project = new Project("AI Application", manager, client);
// Simulate Work
manager.Work();
client.RequestProject();
project.StartProject();
}
}
Don’t worry, we don’t spam!