SlideShare une entreprise Scribd logo
1  sur  18
How I Learned To Apply Design Patterns Andy Maleh Obtiva Corp.
Outline What Are Design Patterns? Gang of Four Design Patterns GRASP Patterns Learning Process Example
What Are Design Patterns? Reusable solutions to common problems encountered at the software design level of abstraction. A pattern usually consists of: Name Problem Solution Consequences
Gang of Four Design Patterns Strategy State Decorator Proxy Abstract Factory Factory Method Chain of Responsibility Visitor???
GRASP Patterns General Responsibility Assignment Software Patterns Appeared in the book "Applying UML and Patterns" by Craig Larman Provide the underpinnings of Object Oriented Design Help explain the benefits of most Gang of Four design patterns as well as how they were arrived to  Contemplated collectively instead of one at a time
GRASP Patterns Creator Information Expert Controller Low Coupling High Cohesion Polymorphism Pure Fabrication Indirection Protected Variations
Responsibility Driven Design Break requirements into use-cases Come up with scenarios for use-cases Figure out responsibilities for each step in a scenario Assign responsibilities to objects based on Object Oriented Design principles NOTE: the methodology is applied vertically in thin slices when following an Agile process
Learning Process Study design patterns with genuine interest to deeply understand them and recognize when applying them would reap benefits in real-world scenarios. Look for every opportunity to apply them to slowly develop a sense of smell for when patterns can be applied. Learn to recognize when a design pattern is absolutely necessary and helpful and when it is just over-engineering.
Example – Order Submission Requirements: When an order is first created, it is not ready for on-line submission as it is missing required information. An order becomes ready for submission once filled in with required information.  A pending order is an order that was interrupted amidst on-line submission. Once an order is submitted, it cannot be edited and resubmitted.
Example – Order Submission Order State Diagram:
Example – Order Submission Design: Each order state is represented with a state object Not Ready Ready Pending Submitted View observes order to update edit and submit button enablements
Example – Order Submission Design Patterns: State Observer
Example – Order Submission GRASP Patterns: Polymorphism  Order States handling behavior polymorphically Indirection Observers provide indirect coupling to order state Protected Variations  Order is protected from state variations Low Coupling Order has low coupling to behavior variation per state View has low coupling to Order via observers
Example – Order Submission Benefits: Order behavior variation across states is clarified Order behavior is easily maintainable in different classes No complicated if/else conditionals
Review What Are Design Patterns? Gang of Four Design Patterns GRASP Patterns Learning Process Example
???
References Design Patterns: Elements of Reusable Object-Oriented Software Authors: Gang of Four ISBN-13: 978-0201633610 Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development Author: Craig Larman ISBN-13: 978-0131489066 Recommended Chapters (17, 25, 26) Object Design: Roles, Responsibilities, and Collaborations Author: Rebecca Wirfs-Brock ISBN-13: 978-0201379433 Elephant Carpaccio Author: Alistair Cockburn URL: http://alistair.cockburn.us/Elephant+carpaccio#discussion
Contact Presenter: Andy Maleh Email: andy at obtiva dot com Twitter: AndyMaleh Blog: http://andymaleh.blogspot.com

Contenu connexe

Tendances

Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
Aman Jain
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
soms_1
 

Tendances (20)

GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with java
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Lecture 5 Software Engineering and Design Design Patterns
Lecture 5 Software Engineering and Design Design PatternsLecture 5 Software Engineering and Design Design Patterns
Lecture 5 Software Engineering and Design Design Patterns
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Python
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Design pattern
Design patternDesign pattern
Design pattern
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design pattern
Design patternDesign pattern
Design pattern
 
Sda 8
Sda   8Sda   8
Sda 8
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02
 
Design patterns difference between interview questions
Design patterns   difference between interview questionsDesign patterns   difference between interview questions
Design patterns difference between interview questions
 
Design patterns
Design patternsDesign patterns
Design patterns
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 

Similaire à How I Learned To Apply Design Patterns

12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
CSEC5
 
Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07
Steve Feldman
 
Design Patterns .Net
Design Patterns .NetDesign Patterns .Net
Design Patterns .Net
Hariom Shah
 
B2 2006 sizing_benchmarking (1)
B2 2006 sizing_benchmarking (1)B2 2006 sizing_benchmarking (1)
B2 2006 sizing_benchmarking (1)
Steve Feldman
 
B2 2006 sizing_benchmarking
B2 2006 sizing_benchmarkingB2 2006 sizing_benchmarking
B2 2006 sizing_benchmarking
Steve Feldman
 

Similaire à How I Learned To Apply Design Patterns (20)

L03 Design Patterns
L03 Design PatternsL03 Design Patterns
L03 Design Patterns
 
12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
 
Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07
 
Getting Unstuck: Working with Legacy Code and Data
Getting Unstuck: Working with Legacy Code and DataGetting Unstuck: Working with Legacy Code and Data
Getting Unstuck: Working with Legacy Code and Data
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Slides chapter 3
Slides chapter 3Slides chapter 3
Slides chapter 3
 
Slides chapter 3
Slides chapter 3Slides chapter 3
Slides chapter 3
 
L12 GRASP
L12 GRASPL12 GRASP
L12 GRASP
 
The Nature Of Patterns
The Nature Of PatternsThe Nature Of Patterns
The Nature Of Patterns
 
Design Patterns .Net
Design Patterns .NetDesign Patterns .Net
Design Patterns .Net
 
Modeling Requirements Narrated2
Modeling Requirements Narrated2Modeling Requirements Narrated2
Modeling Requirements Narrated2
 
Modeling Requirements with SysML
Modeling Requirements with SysML Modeling Requirements with SysML
Modeling Requirements with SysML
 
B2 2006 sizing_benchmarking (1)
B2 2006 sizing_benchmarking (1)B2 2006 sizing_benchmarking (1)
B2 2006 sizing_benchmarking (1)
 
B2 2006 sizing_benchmarking
B2 2006 sizing_benchmarkingB2 2006 sizing_benchmarking
B2 2006 sizing_benchmarking
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Object Oriented Analysis and Design with UML2 part2
Object Oriented Analysis and Design with UML2 part2Object Oriented Analysis and Design with UML2 part2
Object Oriented Analysis and Design with UML2 part2
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP Principles
 

Plus de Andy Maleh

Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Andy Maleh
 
Software Craftsmanship VS Software Engineering
Software Craftsmanship VS Software EngineeringSoftware Craftsmanship VS Software Engineering
Software Craftsmanship VS Software Engineering
Andy Maleh
 
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for RubyistsSoftware Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Andy Maleh
 
The Rails Engine That Could - In Motion
The Rails Engine That Could - In MotionThe Rails Engine That Could - In Motion
The Rails Engine That Could - In Motion
Andy Maleh
 

Plus de Andy Maleh (17)

Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - Opal
 
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby MeetupBecoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
 
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ... Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 
How I Built My Code Editor in Ruby
How I Built My Code Editor in RubyHow I Built My Code Editor in Ruby
How I Built My Code Editor in Ruby
 
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
 
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy MalehRailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
 
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rbUltra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
 
Software Craftsmanship VS Software Engineering
Software Craftsmanship VS Software EngineeringSoftware Craftsmanship VS Software Engineering
Software Craftsmanship VS Software Engineering
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine Patterns
 
Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)
 
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
 
Software Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for RubyistsSoftware Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for Rubyists
 
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for RubyistsSoftware Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
 
The Rails Engine That Could - In Motion
The Rails Engine That Could - In MotionThe Rails Engine That Could - In Motion
The Rails Engine That Could - In Motion
 
The Rails Engine That Could
The Rails Engine That CouldThe Rails Engine That Could
The Rails Engine That Could
 
Simplifying Desktop Development With Glimmer
Simplifying Desktop Development With GlimmerSimplifying Desktop Development With Glimmer
Simplifying Desktop Development With Glimmer
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

How I Learned To Apply Design Patterns

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