Mastering the Art of Software Design: An Overture to Object-Oriented Design
Tags: softwaredesign, javascript, webdev, programming
Published: 2023-09-26 06:19:33

**We human think as we see the world around us so thinking software in visible world is easy.** _-Anks_ 

To achieve this we have the Object Oriented Design (OOD). OOD is a cornerstone of building robust and scalable applications. It is not a buzzword; It is a fundamental approach that revolutionised the way we think about software when first tossed in 1960 by Ole-Johan Dahl and Kristen Nygaard, who created the Simula programming language. Simula was known as one of the first programming languages to introduce the concepts of classes and objects, which are fundamental to OOD.

Much history let's jump into the science and the art behind the OODs.

## What is Object-Oriented Design?
_**As one liner**, Object-Oriented Design is a methodology which models software entities as "Object"._ These objects are like digital building blocks that encapsulate both data (attributes) and behaviours (methods). OOD allows developers to create software systems that mimic the real world, making it easier to understand and manage complex systems. 

eg. we have to keep record for students for their score, annual attendance so in simple way we can create a class Student which would be having data name, attendance, standard and methods isPresent, isPass.

Object-Oriented Design has four pillars, aka essential pillars of OOD as below

### 1. Encapsulation
Encapsulation is the idea of bundling data and methods together as an entity called "Object"s, where these methods operates on the data associated within the entity. This entity hides all details and exposes only what is necessary. You can consider it as a black box, which you don't need to know how it works internally; you just need to know how to use it.

### 2. Abstraction
Abstraction is all about simplifying complex systems by modelling the real world in a simplified manner. It involves focusing on the essential features of an object while ignoring the irrelevant details. For example, when designing a car class, you might abstract away the specifications of the engine's internal workings and focus on what's essential for driving like it's CC, no of gears etc. but not the length and width of pistons inside it.

### 3. Inheritance
Inheritance allows us to create new classes, child or derived from base or parent class. This mechanism promotes code reuse, as child classes inherit the properties and behaviours of their parent classes. For instance, you can have a base class called "Vehicle" and create child classes like "Car", "Truck" and "Motorcycle."

### 4. Polymorphism
The term "many shapes," or polymorphism, refers to the ability to treat objects from multiple classes as belonging to the same superclass. This idea makes code more versatile and easier to understand. For instance, you can have a generic "Shape" superclass with subclasses like "Circle" and "Rectangle." Every form can have a "calculateArea" method, but every subclass has a unique way of implementing it.

## Benefits of Object-Oriented Design
1. **Modularity**: It promotes code modularity, as Objects are self-contained and can be developed and tested independently.
2. **Reusability**: Reusing existing classes and creating new ones through inheritance leads to more efficient and maintainable code.
3. **Simplicity**: Abstraction and encapsulation simplify complex systems, making them easier to understand and modify.
4. **Flexibility**: Polymorphism and inheritance allow for adaptable and extensible code.
5. **Real-world Mapping**: OOD models real-world entities, making it intuitive for stakeholders to understand and for developers to work with [adding this for developers to feel happy although they can work with anything ;)].

Nothing is perfect so same applies for the OOD, just dropping the few things which can count as cons of this are complexity, learning curve, performance overheads, resource consumption.

_Rule of thumb_: Not to use for very small project as that will only add overheads.

Object-Oriented Design is a powerful paradigm that has influenced contemporary software development. By encapsulating data and behaviour into objects, abstracting complex systems, utilising inheritance, and enabling polymorphism, developers create software that's not just functional but also maintainable, scalable, and easier to work with.

Till the next time keep Learning-Coding-and-Growing.

**Previous Article**: [Mastering the Art of Software Design: Unveiling the Core Principles](https://dev.to/dr_anks/mastering-the-art-of-software-design-unveiling-the-core-principles-1ag3)