4. Agenda
• SOLID
• Design Principles
• What are design Patterns
• Who are Gang Of Four
• GoF Patterns
• Creational Pattern
• Example
5. Some House Rules
• Please mute your mic
• Keep adding questions in Zoom Q&A Window
• No question is too small
• Questions will be answered in last 15 mins
13. 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
Extension.
19. Question
AreaCalculator class calculates area and returns result of sum of area
of all Shapes.
How to add functionality if we want to get area result as JSON or HTML
?
21. Explanation
Its breaking Single Responsibility Principle. AreaCalculator should only
change if formula related to Area changes
22. 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.
23. 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.