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.

[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master at Axon Active Vietnam

371 views

Published on

This is an extension of “Refactoring – code optimization” – a topic shared in DevDay 2015. This year, the presentation will focus on a more advanced topic but it is shown simply to help you optimize, restructure code, refactore better system thereby ensure easy software expanded, management and maintenance. That is the standard design in software programming. Maybe you’ve heard it with the word “Design Pattern”.

Join us to learn and share.

———

Speaker: Tuan Do – Scrum Master at Axon Active Vietnam

Published in: Software
  • Be the first to comment

  • Be the first to like this

[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master at Axon Active Vietnam

  1. 1. Welcome to DEVDAY Da Nang 2016
  2. 2. I’m Tuan • Live in Da Nang. • Working in Axon Active Vietnam. • 6 years in development • Scrum Master, Team Leader, Software Engineer. • Java, Javascript, Code Generator. tuan.do@axonactive.com
  3. 3. Questions • Who joined Devday Da Nang 2015 ? • Who knows about refactoring ? • Who knows about clean code ?
  4. 4. Design Pattern 
 at a glance –Do Minh Tuan
  5. 5. What is a design pattern ? “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice” - Christopher Wolfgang Alexander (1936)
  6. 6. Elements of Pattern The pattern name The problem The consequences The solution PATTERN
  7. 7. Advantages of Pattern • Enhances code readability. • Robust, Scalable. • Enhances software development. • Well-structured system. • Well-tested system.
  8. 8. Ready for change
  9. 9. Gift Question
  10. 10. Organize the catalog
  11. 11. Design pattern relationship
  12. 12. How to select a design pattern
  13. 13. How design patterns solve design problems • Finding appropriate objects. • Determining Object Granularity. • Specifying Object Interfaces. • Specifying Object Implementations.
  14. 14. How to use a design pattern (1 of 2) • Read the pattern. • Study the structure, participants and collaborations sections. • Sample code of pattern • Choose names for pattern participants that are meaningful in the application context.
  15. 15. How to use a design pattern (2 of 2) • Define the classes. • Define application-specific names for operations in the pattern. • Implement the operations to carry out the responsibillities and collaborations in the pattern.
  16. 16. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  17. 17. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  18. 18. Abstract Factory “Provide an interface for creating families of related or dependent objects without specifying their concrete classes.”
  19. 19. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  20. 20. Factory Method “Define an interface for creating an object, but let subclasses decide which class to instantance. Factory Method lets a class defer instantiation to subclasses.”
  21. 21. Demo
  22. 22. Abstract Factory • It isolates concrete classes. • It makes exchanging product famillies easy. • It promotes consistency among products. • Supporting new kinds of products is difficult.
  23. 23. Factory Method • Provides hooks for subclasses. • Connects parallel class hierarchies.
  24. 24. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  25. 25. Adapter “Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.”
  26. 26. Demo
  27. 27. Adapter • How much adapting does Adapter do ? • Pluggable adapters. • Using two-way adapters to provide transparent.
  28. 28. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  29. 29. Composite “Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.”
  30. 30. Demo
  31. 31. Composite • Defines class hierarchies consisting of primitive objects and composite objects. • Make the client simple. • Make it easier to add new kinds of components. • Can make your design overly general.
  32. 32. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral Pattern • Observer • Strategy • Template Method
  33. 33. Decorator “Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.”
  34. 34. Demo
  35. 35. Decorator • More flexibility than static inheritance. • Avoids feature-laden classes high up in the hierarchy. • A decorator and it’s component aren’t critical. • Lost of little objects.
  36. 36. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  37. 37. Observer “Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.”
  38. 38. Demo
  39. 39. Observer • Abstract coupling between Subject and Observer. • Support for broadcast communication. • Unexpected updates. • Lost of little objects.
  40. 40. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  41. 41. Strategy “Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.”
  42. 42. Demo
  43. 43. Strategy • Families of related algorithms. • An alternative to subclassing. • Strategies eliminates conditional statements. • Clients must be aware of different Strategies. • Communication overhead between Strategy and Context. • Increased number of objects.
  44. 44. “Famous” Patterns • Creational • Abstract Factory • Factory Method • Structural • Adapter • Composite • Decorator • Behavioral • Observer • Strategy • Template Method
  45. 45. Template Method “Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.”
  46. 46. Demo
  47. 47. Question and Answer
  48. 48. Conclusion
  49. 49. The gang of Four(GoF)
 Raph Johnson, Erich Gamma, Richard Helm, John Vlissides
  50. 50. tuan.do@axonactive.com https://vn.linkedin.com/in/dominhtuan Thank you !

×