Design Patterns 101
$ whoami
Ritesh Agrawal
udr.ritesh@gmail.com
Software Engineer at Cyware Labs
https://www.linkedin.com/in/riteshagrawal18/
Considerations during Software Design
● Changing requirement/Feature Extension
● Technology changes
● Reusability
● Reduce Impact of code change
What is Design Pattern?
● Solution for the common software design problem
● It is a concept not implementation
● Technology independent
How?
Basics of OOP
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
Design Principles
Do Not Repeat Yourself (DRY)
● Aimed at reducing repetition of code
● Use of helper classes and utilities
Single Responsibility Principle
● Class, module or function should have single responsibility
● High Cohesiveness
● Single Reason of change
Open-Close Principle
● Software entities (classes, modules, functions, etc.) should be open for
extension, but closed for modification.
● Classes allow to subclass and alter the behaviour but not allowed to change
the existing code
Program to Interfaces, not Implementations
● Focus on what to be done rather than how
● Interact at more abstract level
● Helps in changing the details without affecting the client or caller
Encapsulate What Varies
● Change is the only constant
● Isolate the implementation details which changes frequently
● Can be business logic, library, interface, etc.
● Legacy code handling
Design Patterns
Strategic Pattern
● This pattern allows usage of different strategies by encapsulating the
algorithm
● Algorithm can vary independent of the client
● Client knows about the interface but not implementation
Adapter
● Joins functionality of incompatible interface
● Generalize interface of other functionality which can be helpful to change it in
future
● Using different product, libraries
Factory
● Abstracts process of creational of new objects
● Reduces code coupling by abstracting details of concrete classes
Singleton
● Restricts creation of one object per class
● Helpful in creating db connection objects
Question/Feedback ?
Thanks

Design patterns 101