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.
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.
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.
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.
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.
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.
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.
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.
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.
Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.