Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Design patterns 101


Published on

This presentation provide introduction to design pattern in software development and design principles behind it.

Example source code is available at

Published in: Software
  • Be the first to comment

Design patterns 101

  1. 1. Design Patterns 101
  2. 2. $ whoami Ritesh Agrawal Software Engineer at Cyware Labs
  3. 3. Considerations during Software Design ● Changing requirement/Feature Extension ● Technology changes ● Reusability ● Reduce Impact of code change
  4. 4. What is Design Pattern? ● Solution for the common software design problem ● It is a concept not implementation ● Technology independent
  5. 5. How?
  6. 6. Basics of OOP ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism
  7. 7. Design Principles
  8. 8. Do Not Repeat Yourself (DRY) ● Aimed at reducing repetition of code ● Use of helper classes and utilities
  9. 9. Single Responsibility Principle ● Class, module or function should have single responsibility ● High Cohesiveness ● Single Reason of change
  10. 10. 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
  11. 11. 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
  12. 12. 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
  13. 13. Design Patterns
  14. 14. 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
  15. 15. Adapter ● Joins functionality of incompatible interface ● Generalize interface of other functionality which can be helpful to change it in future ● Using different product, libraries
  16. 16. Factory ● Abstracts process of creational of new objects ● Reduces code coupling by abstracting details of concrete classes
  17. 17. Singleton ● Restricts creation of one object per class ● Helpful in creating db connection objects
  18. 18. Question/Feedback ?
  19. 19. Thanks