SOLID is a set of principles that are used as guidelines for creating a clean and maintainable application that is also less buggy and error-prone.
Today, we will take a deep dive into the third principle of SOLID: the Liskov Substitution Principle. We will try to understand how this principle can help us to create a better and cleaner React application.
In simple terms, this principle says:
“Subclasses should be substitutable for their superclasses.”
That means subclasses of a particular class should be able to replace the superclass without breaking any functionality.
If PlasticDuck
is a subclass of Duck
, then we should be able to replace instances of Duck
with PlasticDuck
without any surprises.
Source: Maksim Ivanov
That means PlasticDuck
should fulfill all the expectations set by the Duck
class.
#software-development #react #programming #javascript #web-development