How I Learned To Apply Design Patterns

13,123 views

Published on

A presentation on how I learned to apply design patterns in software development and the additional principles/guidelines that helped along the way.

1 Comment
9 Likes
Statistics
Notes
No Downloads
Views
Total views
13,123
On SlideShare
0
From Embeds
0
Number of Embeds
22
Actions
Shares
0
Downloads
325
Comments
1
Likes
9
Embeds 0
No embeds

No notes for slide

How I Learned To Apply Design Patterns

  1. 1. How I Learned To Apply Design Patterns<br />Andy Maleh<br />Obtiva Corp.<br />
  2. 2. Outline<br />What Are Design Patterns?<br />Gang of Four Design Patterns<br />GRASP Patterns<br />Learning Process<br />Example<br />
  3. 3. What Are Design Patterns?<br />Reusable solutions to common problems encountered at the software design level of abstraction.<br />A pattern usually consists of:<br />Name<br />Problem<br />Solution<br />Consequences<br />
  4. 4. Gang of Four Design Patterns<br />Strategy<br />State<br />Decorator<br />Proxy<br />Abstract Factory<br />Factory Method<br />Chain of Responsibility<br />Visitor???<br />
  5. 5. GRASP Patterns<br />General Responsibility Assignment Software Patterns<br />Appeared in the book "Applying UML and Patterns" by Craig Larman<br />Provide the underpinnings of Object Oriented Design<br />Help explain the benefits of most Gang of Four design patterns as well as how they were arrived to <br />Contemplated collectively instead of one at a time<br />
  6. 6. GRASP Patterns<br />Creator<br />Information Expert<br />Controller<br />Low Coupling<br />High Cohesion<br />Polymorphism<br />Pure Fabrication<br />Indirection<br />Protected Variations<br />
  7. 7. Learning Process<br />Study design patterns with genuine interest to deeply understand them and recognize when applying them would reap benefits in real-world scenarios.<br />Look for every opportunity to apply them to slowly develop a sense of smell for when patterns can be applied.<br />Learn to recognize when a design pattern is absolutely necessary and helpful and when it is just over-engineering.<br />
  8. 8. Example – Order Submission<br />Requirements:<br />When an order is first created, it is not ready for on-line submission as it is missing required information.<br />An order becomes ready for submission once filled in with required information. <br />A pending order is an order that was interrupted amidst on-line submission.<br />Once an order is submitted, it cannot be edited and resubmitted.<br />
  9. 9. Example – Order Submission<br />Order State Diagram:<br />
  10. 10. Example – Order Submission<br />Applications:<br />Each order state is represented with a state object<br />Not Ready<br />Ready<br />Pending<br />Submitted<br />View observes order to update edit and submit button enablements<br />
  11. 11. Example – Order Submission<br />Design Patterns:<br />State<br />Observer<br />
  12. 12. Example – Order Submission<br />GRASP Patterns:<br />Polymorphism <br />Order States handling behaviorpolymorphically<br />Indirection<br />Observers provide indirect coupling to order state<br />Protected Variations <br />Order is protected from state variations<br />Low Coupling<br />Order has low coupling to behavior variation per state<br />View has low coupling to Order via observers<br />
  13. 13. Example – Order Submission<br />Benefits:<br />Order behaviorvariation across states is clarified<br />Order behavior is easily maintainablein different classes<br />No complicated if/else conditionals<br />
  14. 14. Review<br />What Are Design Patterns?<br />Gang of Four Design Patterns<br />GRASP Patterns<br />Learning Process<br />Example<br />
  15. 15. ???<br />
  16. 16. References<br />Design Patterns: Elements of Reusable Object-Oriented Software<br />Authors: Gang of Four<br />ISBN-13: 978-0201633610<br />Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development<br />Author: Craig Larman<br />ISBN-13: 978-0131489066<br />Recommended Chapters (17, 25, 26)<br />Object Design: Roles, Responsibilities, and Collaborations<br />Author: Rebecca Wirfs-Brock<br />ISBN-13: 978-0201379433<br />
  17. 17. Contact<br />Presenter: Andy Maleh<br />Email: andy at obtiva dot com<br />Twitter: AndyMaleh<br />Blog: http://andymaleh.blogspot.com<br />

×