oops-principles

SOLID Principle Part 2: Open Closed Principle (OCP)
SOLID Principle Part 2: Open Closed Principle (OCP)

In object oriented programming, open closed principle states that: software entities (classes, modules, etc.) should be open for extension but closed for modification i.e. such an entity can extend its behavior without modifying its source code. This principle allows us to use the power of abstraction and inheritance to create such systems.

SOLID Principle Part 1: Single Responsibility Principle (SRP)
SOLID Principle Part 1: Single Responsibility Principle (SRP)

The single responsibility principle is one of the popular SOLID principles in software engineering that determines how we should modularize code in object-oriented programming. The idea for this principle is relatively simple: it makes our software easier to implement and prevents unexpected side effects of future changes.

Inheritance in OOPS: An Idea of Code Reusability
Inheritance in Object Oriented Programming (Java)

Inheritance is one of the core principles of object oriented programming (OOP), which helps us derive a class from another class or a hierarchy of classes that share a set of attributes and methods. It is a relationship between a superclass (parent class) and a subclass (child class), where subclass inherits data and behavior from superclass.

Interface in OOPS (Java)
Interface in OOPS (Java)

The word interface means a medium or means of communication between two entities. Similarly, in object oriented programming, interfaces are used to ease the communication between classes and objects. An interface in java looks similar to class and contains only constants, method signatures, default methods, and static methods.

SOLID Principle Part 5: Dependency Inversion Principle (DIP)
Dependency Inversion Principle (DIP)

The Dependency Inversion Principle (DIP) in software engineering states that high-level modules should not depend on low-level modules. In other words, both should depend on abstractions. This abstraction removes the direct dependency on the details, decouples them and allows for easier reuse of the important functionality in the policy.

SOLID Principle Part 4: Interface Segregation Principle (ISP)
Interface Segregation Principle (ISP)

The Interface Segregation Principle states that clients should never be forced to depend on methods they do not use. We achieve this by making small and focused interfaces. It would be best to split large interfaces into specific ones focused on a particular set of functionalities so that clients can choose to depend only on functionalities they need.

Builder Design Pattern
Builder Design Pattern

The Builder is a creational design pattern that allows us to follow a step-by-step process to construct a complex object. Builder design pattern separates the construction of the complex object from its representation by which the same process can create different representations (types) of the complex object.

SOLID Principle Part 3: Liskov Substitution Principle (LSP)
Liskov Substitution Principle (LSP)

According to the Liskov Substitution principle, an object of a parent/base class must be interchangeable with an object of a child/derived class without changing the program. So the subclass objects should behave in the same way as the superclass objects. In simple words, LSP is all about well-designed inheritance.

Popular Principles of Software Engineering
Popular Software Engineering Principles

Principle of software engineering are recommendations for developers to follow during software development. They are good practices for writing extensible, modular, reusable, and maintainable code. Some popular principles of software engineering are Separation of Concerns, Law of Demeter, KISS principle, YAGNI Principle, SOLID Principles, etc.

EnjoyAlgorithms Newsletter

Subscribe to get well designed content on data structure and algorithms, machine learning, system design, object orientd programming and math.

Follow us on

©2023 Code Algorithms Pvt. Ltd.

All rights reserved.