Change in Requirement
Add Support for Rectangle Also. What
would you do ?
Add one more If else? That would be
breaking Open Closed Principle. Class should
be closed to modification but open to
Add Interface so that all Shape
should follow that interface, new
Class will become
Single Responsibility Principle
A class should have one and only one reason to change that means
only one job.
Its breaking Single Responsibility Principle. AreaCalculator should only
change if formula related to Area changes
Liskov Substitution Principle
If class B is a child of class A, then A can be replaced by B, without
changing anything in a program. In other words, the LSP principle
states that you should not encounter unexpected results if child
(derived) classes are used instead of parent classes.
Interface Segregation Principle
This states that do not force a child class to depend on a method that is
not used for them. This principle suggests that you break interfaces
into smaller ones so that a client can only implement an interface that
is of interest.