oops-principles

[object Object]
Inheritance in Object Oriented Programming (OOPS)

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.

[object Object]
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.

[object Object]
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.

[object Object]
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.

[object Object]
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.

[object Object]
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.

[object Object]
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.

[object Object]
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.

[object Object]
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.

Our weekly newsletter

Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.

© 2022 Code Algorithms Pvt. Ltd.

All rights reserved.