Low level design

Ashutosh Kumar Singh
2 min readApr 11, 2024

--

What is object-oriented design?

Object-oriented design (OOD) uses the object-oriented methodology to design a computational problem and its solution. It allows the application of a solution, based on the concepts of objects and models.
It is nothing but that which allows the writing of programs with the help of certain classes and real-time objects.

Principles of OOP

The following are the four principles of object-oriented programming:

  • Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism

Data hiding:

Components of data hiding

Data hiding can be divided into two primary components:

  • Encapsulation
  • Abstraction

Encapsulation:

Encapsulation is a fundamental programming technique used to achieve data hiding in OOP. Encapsulation in OOP refers to binding data and the methods to manipulate that data together in a single unit — class.
We declare all variables of a class private. This will restrict direct access by the code outside that class.

One has to implement public methods to let the outside world communicate with this class. These methods are called getters and setters. We can also implement other custom methods.

For the sake of explanation, we’ll start off by creating a simple Employee class, which contains the following three data members (attributes):

  • name
  • salary
  • designation
class Employee {
// Data members
private String name;
private double salary;
private String designation;

// Default constructor
public Employee() {
name = "";
salary = -1;
designation = "";
}

// Parameterized constructor
public Employee(String t, double y, String g) {
name = t;
salary = y;
designation = g;
}
}

Advantages of encapsulation

  • Classes are simpler to modify and maintain.
  • Which data member we wish to keep hidden or accessible can be specified.
  • We choose which variables are read-only and write-only (increases flexibility).

Abstraction:

Abstraction is a technique used in object-oriented programming that simplifies the program’s structure. It shows only essential functionality to the user. It can be achievable through Interface and Abstract classes.

--

--

Ashutosh Kumar Singh
Ashutosh Kumar Singh

No responses yet