The Liskov Substitution Principle, introduced by Barbara Liskov, represents the “L” in SOLID. It states that every implementation of a class should be replaceable with an implementation of any class that extends it. In other words, every instance of a parent class should be replaceable by any instance of its child classes so that the application continues to work.
Category: Good practices
The Open/Closed Principle represents the “O” in SOLID. In the words of Bertrand Meyer (who originated the term), it states that “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification“. What it means is that one should be able to extend the behavior of an entity without modifying its code.
The Single Responsibility Principle represents the “S” in SOLID. It means that a software module should only have one responsibility – in other words, there should never be more than one reason to modify that module (excluding, of course, refactoring and bug fixes). The responsibility of a module should be entirely encapsulated within that module and all services within it should be narrowly aligned with it.
The Builder pattern helps us create complex objects that can have different representations, simplifying the process and (optionally) preserving immutability – encapsulating the code responsible for assembling an object in a separate Builder class.
In simpler terms, it delegates the responsibility of creating a complex object to its Builder, whose job it is to make sure that the object is never created in an invalid state.
In the simplest terms, a factory method is a method which creates objects and lets a class defer instantiation to its subclasses.
It may either be implemented directly in a class (and optionally overriden in its children) or specified in an interface (and implemented by classes which use it).
The abstract factory pattern provides an interface for creating related objects, while hiding the choice of their concrete classes in implementations of that interface.