SlideShare a Scribd company logo
Choosing a
Design Pattern
Michael Heron
Introduction
 Knowing what the patterns are and what
they are for is part of the battle.
 Knowing when and where they should be
applied is the other.
 In this lecture we are going to discuss the
ways in which you can determine the
usefulness of a pattern.
 And where they are not useful
Key Points
 Design patterns are generalized.
 They must be adapted to context
 Design patterns are a codified form of
developer experience.
 They represent good solutions, not necessarily
the best solutions.
 Design patterns are not always appropriate to
be applied to a given problem.
 It’s as important to know when not to use a
pattern.
Analyzing a Problem
 Given a particular scenario, how can you
tell if a pattern is called for?
 Consider your three families of patterns.
 Creational
 Behavioural
 Structural.
 Analyse the scenario for the existence of
terms relating to any of these three.
Analyzing A Problem
 The biggest skill in analyzing a scenario is
appreciation of implications.
 Put yourself in the shoes of someone writing the
program.
 What problems are you going to run into?
 This requires not only an understanding of the
scenario, but also of the nature of program
design.
 You need to know your stuff, you can’t fake this.
Analyzing A Problem
 Experience is the greatest predictor of future
problems.
 Call on your own experience in writing programs
to effectively analyze a scenario.
 The only way to really learn is to make mistakes –
that’s not new age mumbo jumbo, it’s the truth.
 Safe to work on the assumption that unless
great care is taken with a design, it will have
problems.
 All designs do – programming is an eternal
trade-off between competing goals.
Analyzing A Problem
 There is also no shortcut for working out
the implications.
 You just need to think your way through it.
 Every scenario is unique, but programming
is all about recognizing patterns.
 Compile a list of the features you know of.
 Follow them through to the logical
conclusions.
 Identify possible implications from those.
Example Scenario - 1
 Mega Games Corp are creating an
online role playing game. The game
consists of twenty character races, and a
selection of twenty classes for each.
Players can select the combination of the
two, and choose between three hundred
weapons, five hundred magic spells, and
six hundred pieces of armour.
 What’s the focus here?
 What are the implications?
Example Scenario - 2
 Picture Perfect Software Inc are
developing a new graphics package
based on the principle of potato shapes.
Users can select from a range of
preconfigured shapes and ‘stamp’ them
in paint before stamping them on the
document. Users then get to move and
recolour the pictures as needed.
 What’s the focus here?
 What are the implications?
From Implications To Strategy
 Knowing what the implications are allows you to map
the scenario to your available patterns.
 All patterns are designed to fill a certain role.
 Consider the patterns you have been presented.
 What is their role? What process are they designed to
manage?
 Does the analysis of the program implications
suggest that a specific pattern will be relevant.
 Note, relevant – don’t worry about whether or not it’s a
good idea yet.
 Do this for each pattern you know.
 If you don’t understand the pattern, make the effort to
do so.
Candidate Patterns
 Going through the patterns will give you a list
of relevant patterns to assess.
 They’re not all going to be winners.
 Consider what the impact would be of
applying a pattern.
 What are the consequences of each pattern?
 Will it improve maintainability?
 Does it improve efficiency?
 Does it open up new functionality?
 Importantly, does it solve any problems you
have identified?
Identify Variability
 Every program has parts of the program
that are static and parts that will change
according to circumstances.
 Identifying that variability is a key to unlock
which patterns are genuinely useful.
 Which of the moving parts in the program
are going to cause an issue?
 Inappropriate handling of variability leads
to design issues down the line.
Cost of Implementation
 There is a cost to implementing any given
design pattern.
 Often leads to additional complexity.
 Often leads to over-engineering
 Most patterns based on a trade-off
 Consider what the impact will be if you
implement a pattern.
 The cost of implementation may outweigh
any benefits.
Finally
 Having identified which design patterns are
suitable:
 Relevant
 Beneficial
 Net gain in application
 You then take this smaller pool and work out
which of these are going to be implemented.
 If any.
 Does the implementation of one design
pattern open up new implications for the
implementation of another?
This Is Hard…
 This is hard to do from a specification.
 If it wasn’t, people wouldn’t make so many
mistakes when designing systems!
 It’s a hugely important skill though.
 One you can practice.
 It sits between ‘knowing’ and ‘doing’.
 You need to be able to reasonably do both
to effectively analyze.
Refactoring
 The biggest impact well selected patterns
have is on the reduction in the need for
refactoring.
 It’s an unavoidable need, but can be
managed.
 Refactoring is the process whereby we rewrite
code the way we would have written it
before, if we weren’t operating under limits.
 Time Constraints
 Benefit of Hindsight
Design Patterns and
Refactoring
 Design patterns are what emerge from
successive refactoring.
 They converge on a general and almost
universally applicable solution to a given
problem.
 Adopting a design pattern early saves
you from having to adopt it later.
 Consciously or not.
 After a while, experience tends to teach you
to code in this way anyway.
Deep Smarts
 Some things you just can’t teach.
 They are learned only as a result of the crushing
grind of life.
 Swap and Leonard (who coined the term) put the
time needed at at least ten years.
 Some writers have termed this experience based
knowledge as deep smarts.
 A big goal of knowledge management is
cataloguing and translating as much of these
deep smarts as possible.
 Design patterns, for software engineering,
represent a library of deep smarts.
Where Next?
 Even though we’ve done five lectures on this topic,
we’ve only scratched the surface.
 Design patterns are rich and supported by an extensive
literature.
 The seminal book on the topic is called Design
Patterns and is authored by the ‘Gang of Four’
 Erich Gamma
 Richard Helm
 Ralph Johnson
 John Vlissides
 Students are heartily recommended to check it out.
 It covers these patterns (and more) in much more depth.
Summary
 Picking a design pattern is a complex task.
 Involving a mixture of skills.
 There is a process you can follow to help in
this.
 But it doesn’t do it for you.
 Thinking through the implications of scenarios
that are presented is something that comes
easier with practice and experience.
 As you build your deep smarts.

More Related Content

Viewers also liked

How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design Patterns
Andy Maleh
 
Software Design Patterns - Selecting the right design pattern
Software Design Patterns - Selecting the right design patternSoftware Design Patterns - Selecting the right design pattern
Software Design Patterns - Selecting the right design pattern
Joao Pereira
 
Factory design pattern
Factory design patternFactory design pattern
Factory design patternFarhad Safarov
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
Mudasir Qazi
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
Mudasir Qazi
 
Floor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye angaFloor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye anga
Sotonye anga
 
Design pattern
Design patternDesign pattern
Design pattern
Thibaut De Broca
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
Anton Keks
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
Chetan Gole
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
Sanae BEKKAR
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
Saurabh Moody
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
Design patterns
Design patternsDesign patterns
Design patterns
abhisheksagi
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
Guillermo Daniel Salazar
 
Software design patterns ppt
Software design patterns pptSoftware design patterns ppt
Software design patterns ppt
mkruthika
 
Functional Programming and Java8
Functional Programming and Java8Functional Programming and Java8
Functional Programming and Java8
Ender Aydin Orak
 
Design Patterns & JDK Examples
Design Patterns & JDK ExamplesDesign Patterns & JDK Examples
Design Patterns & JDK Examples
Ender Aydin Orak
 
Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 

Viewers also liked (20)

How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design Patterns
 
Software Design Patterns - Selecting the right design pattern
Software Design Patterns - Selecting the right design patternSoftware Design Patterns - Selecting the right design pattern
Software Design Patterns - Selecting the right design pattern
 
Factory design pattern
Factory design patternFactory design pattern
Factory design pattern
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Floor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye angaFloor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye anga
 
Design pattern
Design patternDesign pattern
Design pattern
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
 
Software design patterns ppt
Software design patterns pptSoftware design patterns ppt
Software design patterns ppt
 
Functional Programming and Java8
Functional Programming and Java8Functional Programming and Java8
Functional Programming and Java8
 
Design Patterns & JDK Examples
Design Patterns & JDK ExamplesDesign Patterns & JDK Examples
Design Patterns & JDK Examples
 
Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
 

Similar to PATTERNS05 - Guidelines for Choosing a Design Pattern

Software engineering
Software engineeringSoftware engineering
Software engineering
sweetysweety8
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwellnikrao
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwellguestf59d1c4
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
Steven Smith
 
The passionate programmer
The passionate programmerThe passionate programmer
The passionate programmer
Mahmoud Tolba
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
Ankit Dubey
 
Applying design patterns
Applying design patternsApplying design patterns
Applying design patterns
YogeshwaranT
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
Michael Heron
 
Unit iii design patterns 9
Unit iii design patterns 9Unit iii design patterns 9
Unit iii design patterns 9
kiruthikamurugesan2628
 
Design Process | Tool 02: Scenario - Tool 03: Wireframe
Design Process | Tool 02: Scenario - Tool 03: WireframeDesign Process | Tool 02: Scenario - Tool 03: Wireframe
Design Process | Tool 02: Scenario - Tool 03: Wireframe
Gessica Puri
 
Unit No 6 Design Patterns.pptx
Unit No 6 Design Patterns.pptxUnit No 6 Design Patterns.pptx
Unit No 6 Design Patterns.pptx
DrYogeshDeshmukh1
 
UXBC #26: Lean UX
UXBC #26: Lean UXUXBC #26: Lean UX
UXBC #26: Lean UX
Marcin Kinderman
 
Back To Basics Hyper Free Principles For Software Developers
Back To Basics Hyper Free Principles For Software DevelopersBack To Basics Hyper Free Principles For Software Developers
Back To Basics Hyper Free Principles For Software Developers
Adrian Treacy
 
Anti-Patterns
Anti-PatternsAnti-Patterns
Anti-Patterns
CleanestCode
 
Humane assessment on cards
Humane assessment on cardsHumane assessment on cards
Humane assessment on cards
Tudor Girba
 
Best pratice
Best praticeBest pratice
Best pratice
Eugenio Romano
 
The CMLC 1.0.pdf
The CMLC 1.0.pdfThe CMLC 1.0.pdf
The CMLC 1.0.pdf
FilipRomeling1
 
QA is Broken, Fix it!
QA is Broken, Fix it!QA is Broken, Fix it!
QA is Broken, Fix it!
Ffrees Family Finance
 
Designers are from Venus - Presentationas Given to CD2
Designers are from Venus - Presentationas Given to CD2Designers are from Venus - Presentationas Given to CD2
Designers are from Venus - Presentationas Given to CD2Chad Udell
 

Similar to PATTERNS05 - Guidelines for Choosing a Design Pattern (20)

Software engineering
Software engineeringSoftware engineering
Software engineering
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwell
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwell
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
 
The passionate programmer
The passionate programmerThe passionate programmer
The passionate programmer
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
Applying design patterns
Applying design patternsApplying design patterns
Applying design patterns
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
 
Unit iii design patterns 9
Unit iii design patterns 9Unit iii design patterns 9
Unit iii design patterns 9
 
Design Process | Tool 02: Scenario - Tool 03: Wireframe
Design Process | Tool 02: Scenario - Tool 03: WireframeDesign Process | Tool 02: Scenario - Tool 03: Wireframe
Design Process | Tool 02: Scenario - Tool 03: Wireframe
 
Unit No 6 Design Patterns.pptx
Unit No 6 Design Patterns.pptxUnit No 6 Design Patterns.pptx
Unit No 6 Design Patterns.pptx
 
UXBC #26: Lean UX
UXBC #26: Lean UXUXBC #26: Lean UX
UXBC #26: Lean UX
 
Back To Basics Hyper Free Principles For Software Developers
Back To Basics Hyper Free Principles For Software DevelopersBack To Basics Hyper Free Principles For Software Developers
Back To Basics Hyper Free Principles For Software Developers
 
Anti-Patterns
Anti-PatternsAnti-Patterns
Anti-Patterns
 
Humane assessment on cards
Humane assessment on cardsHumane assessment on cards
Humane assessment on cards
 
Best pratice
Best praticeBest pratice
Best pratice
 
AntiPatterns
AntiPatternsAntiPatterns
AntiPatterns
 
The CMLC 1.0.pdf
The CMLC 1.0.pdfThe CMLC 1.0.pdf
The CMLC 1.0.pdf
 
QA is Broken, Fix it!
QA is Broken, Fix it!QA is Broken, Fix it!
QA is Broken, Fix it!
 
Designers are from Venus - Presentationas Given to CD2
Designers are from Venus - Presentationas Given to CD2Designers are from Venus - Presentationas Given to CD2
Designers are from Venus - Presentationas Given to CD2
 

More from Michael Heron

Meeple centred design - Board Game Accessibility
Meeple centred design - Board Game AccessibilityMeeple centred design - Board Game Accessibility
Meeple centred design - Board Game Accessibility
Michael Heron
 
Musings on misconduct
Musings on misconductMusings on misconduct
Musings on misconduct
Michael Heron
 
Accessibility Support with the ACCESS Framework
Accessibility Support with the ACCESS FrameworkAccessibility Support with the ACCESS Framework
Accessibility Support with the ACCESS Framework
Michael Heron
 
ACCESS: A Technical Framework for Adaptive Accessibility Support
ACCESS:  A Technical Framework for Adaptive Accessibility SupportACCESS:  A Technical Framework for Adaptive Accessibility Support
ACCESS: A Technical Framework for Adaptive Accessibility Support
Michael Heron
 
Authorship and Autership
Authorship and AutershipAuthorship and Autership
Authorship and Autership
Michael Heron
 
Text parser based interaction
Text parser based interactionText parser based interaction
Text parser based interaction
Michael Heron
 
SAD04 - Inheritance
SAD04 - InheritanceSAD04 - Inheritance
SAD04 - Inheritance
Michael Heron
 
GRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and RadiosityGRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and Radiosity
Michael Heron
 
GRPHICS07 - Textures
GRPHICS07 - TexturesGRPHICS07 - Textures
GRPHICS07 - Textures
Michael Heron
 
GRPHICS06 - Shading
GRPHICS06 - ShadingGRPHICS06 - Shading
GRPHICS06 - Shading
Michael Heron
 
GRPHICS05 - Rendering (2)
GRPHICS05 - Rendering (2)GRPHICS05 - Rendering (2)
GRPHICS05 - Rendering (2)
Michael Heron
 
GRPHICS04 - Rendering (1)
GRPHICS04 - Rendering (1)GRPHICS04 - Rendering (1)
GRPHICS04 - Rendering (1)
Michael Heron
 
GRPHICS03 - Graphical Representation
GRPHICS03 - Graphical RepresentationGRPHICS03 - Graphical Representation
GRPHICS03 - Graphical Representation
Michael Heron
 
GRPHICS02 - Creating 3D Graphics
GRPHICS02 - Creating 3D GraphicsGRPHICS02 - Creating 3D Graphics
GRPHICS02 - Creating 3D Graphics
Michael Heron
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D Graphics
Michael Heron
 
GRPHICS09 - Art Appreciation
GRPHICS09 - Art AppreciationGRPHICS09 - Art Appreciation
GRPHICS09 - Art Appreciation
Michael Heron
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
Michael Heron
 
2CPP17 - File IO
2CPP17 - File IO2CPP17 - File IO
2CPP17 - File IO
Michael Heron
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
Michael Heron
 
2CPP15 - Templates
2CPP15 - Templates2CPP15 - Templates
2CPP15 - Templates
Michael Heron
 

More from Michael Heron (20)

Meeple centred design - Board Game Accessibility
Meeple centred design - Board Game AccessibilityMeeple centred design - Board Game Accessibility
Meeple centred design - Board Game Accessibility
 
Musings on misconduct
Musings on misconductMusings on misconduct
Musings on misconduct
 
Accessibility Support with the ACCESS Framework
Accessibility Support with the ACCESS FrameworkAccessibility Support with the ACCESS Framework
Accessibility Support with the ACCESS Framework
 
ACCESS: A Technical Framework for Adaptive Accessibility Support
ACCESS:  A Technical Framework for Adaptive Accessibility SupportACCESS:  A Technical Framework for Adaptive Accessibility Support
ACCESS: A Technical Framework for Adaptive Accessibility Support
 
Authorship and Autership
Authorship and AutershipAuthorship and Autership
Authorship and Autership
 
Text parser based interaction
Text parser based interactionText parser based interaction
Text parser based interaction
 
SAD04 - Inheritance
SAD04 - InheritanceSAD04 - Inheritance
SAD04 - Inheritance
 
GRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and RadiosityGRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and Radiosity
 
GRPHICS07 - Textures
GRPHICS07 - TexturesGRPHICS07 - Textures
GRPHICS07 - Textures
 
GRPHICS06 - Shading
GRPHICS06 - ShadingGRPHICS06 - Shading
GRPHICS06 - Shading
 
GRPHICS05 - Rendering (2)
GRPHICS05 - Rendering (2)GRPHICS05 - Rendering (2)
GRPHICS05 - Rendering (2)
 
GRPHICS04 - Rendering (1)
GRPHICS04 - Rendering (1)GRPHICS04 - Rendering (1)
GRPHICS04 - Rendering (1)
 
GRPHICS03 - Graphical Representation
GRPHICS03 - Graphical RepresentationGRPHICS03 - Graphical Representation
GRPHICS03 - Graphical Representation
 
GRPHICS02 - Creating 3D Graphics
GRPHICS02 - Creating 3D GraphicsGRPHICS02 - Creating 3D Graphics
GRPHICS02 - Creating 3D Graphics
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D Graphics
 
GRPHICS09 - Art Appreciation
GRPHICS09 - Art AppreciationGRPHICS09 - Art Appreciation
GRPHICS09 - Art Appreciation
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
 
2CPP17 - File IO
2CPP17 - File IO2CPP17 - File IO
2CPP17 - File IO
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
2CPP15 - Templates
2CPP15 - Templates2CPP15 - Templates
2CPP15 - Templates
 

Recently uploaded

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 

Recently uploaded (20)

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 

PATTERNS05 - Guidelines for Choosing a Design Pattern

  • 2. Introduction  Knowing what the patterns are and what they are for is part of the battle.  Knowing when and where they should be applied is the other.  In this lecture we are going to discuss the ways in which you can determine the usefulness of a pattern.  And where they are not useful
  • 3. Key Points  Design patterns are generalized.  They must be adapted to context  Design patterns are a codified form of developer experience.  They represent good solutions, not necessarily the best solutions.  Design patterns are not always appropriate to be applied to a given problem.  It’s as important to know when not to use a pattern.
  • 4. Analyzing a Problem  Given a particular scenario, how can you tell if a pattern is called for?  Consider your three families of patterns.  Creational  Behavioural  Structural.  Analyse the scenario for the existence of terms relating to any of these three.
  • 5. Analyzing A Problem  The biggest skill in analyzing a scenario is appreciation of implications.  Put yourself in the shoes of someone writing the program.  What problems are you going to run into?  This requires not only an understanding of the scenario, but also of the nature of program design.  You need to know your stuff, you can’t fake this.
  • 6. Analyzing A Problem  Experience is the greatest predictor of future problems.  Call on your own experience in writing programs to effectively analyze a scenario.  The only way to really learn is to make mistakes – that’s not new age mumbo jumbo, it’s the truth.  Safe to work on the assumption that unless great care is taken with a design, it will have problems.  All designs do – programming is an eternal trade-off between competing goals.
  • 7. Analyzing A Problem  There is also no shortcut for working out the implications.  You just need to think your way through it.  Every scenario is unique, but programming is all about recognizing patterns.  Compile a list of the features you know of.  Follow them through to the logical conclusions.  Identify possible implications from those.
  • 8. Example Scenario - 1  Mega Games Corp are creating an online role playing game. The game consists of twenty character races, and a selection of twenty classes for each. Players can select the combination of the two, and choose between three hundred weapons, five hundred magic spells, and six hundred pieces of armour.  What’s the focus here?  What are the implications?
  • 9. Example Scenario - 2  Picture Perfect Software Inc are developing a new graphics package based on the principle of potato shapes. Users can select from a range of preconfigured shapes and ‘stamp’ them in paint before stamping them on the document. Users then get to move and recolour the pictures as needed.  What’s the focus here?  What are the implications?
  • 10. From Implications To Strategy  Knowing what the implications are allows you to map the scenario to your available patterns.  All patterns are designed to fill a certain role.  Consider the patterns you have been presented.  What is their role? What process are they designed to manage?  Does the analysis of the program implications suggest that a specific pattern will be relevant.  Note, relevant – don’t worry about whether or not it’s a good idea yet.  Do this for each pattern you know.  If you don’t understand the pattern, make the effort to do so.
  • 11. Candidate Patterns  Going through the patterns will give you a list of relevant patterns to assess.  They’re not all going to be winners.  Consider what the impact would be of applying a pattern.  What are the consequences of each pattern?  Will it improve maintainability?  Does it improve efficiency?  Does it open up new functionality?  Importantly, does it solve any problems you have identified?
  • 12. Identify Variability  Every program has parts of the program that are static and parts that will change according to circumstances.  Identifying that variability is a key to unlock which patterns are genuinely useful.  Which of the moving parts in the program are going to cause an issue?  Inappropriate handling of variability leads to design issues down the line.
  • 13. Cost of Implementation  There is a cost to implementing any given design pattern.  Often leads to additional complexity.  Often leads to over-engineering  Most patterns based on a trade-off  Consider what the impact will be if you implement a pattern.  The cost of implementation may outweigh any benefits.
  • 14. Finally  Having identified which design patterns are suitable:  Relevant  Beneficial  Net gain in application  You then take this smaller pool and work out which of these are going to be implemented.  If any.  Does the implementation of one design pattern open up new implications for the implementation of another?
  • 15. This Is Hard…  This is hard to do from a specification.  If it wasn’t, people wouldn’t make so many mistakes when designing systems!  It’s a hugely important skill though.  One you can practice.  It sits between ‘knowing’ and ‘doing’.  You need to be able to reasonably do both to effectively analyze.
  • 16. Refactoring  The biggest impact well selected patterns have is on the reduction in the need for refactoring.  It’s an unavoidable need, but can be managed.  Refactoring is the process whereby we rewrite code the way we would have written it before, if we weren’t operating under limits.  Time Constraints  Benefit of Hindsight
  • 17. Design Patterns and Refactoring  Design patterns are what emerge from successive refactoring.  They converge on a general and almost universally applicable solution to a given problem.  Adopting a design pattern early saves you from having to adopt it later.  Consciously or not.  After a while, experience tends to teach you to code in this way anyway.
  • 18. Deep Smarts  Some things you just can’t teach.  They are learned only as a result of the crushing grind of life.  Swap and Leonard (who coined the term) put the time needed at at least ten years.  Some writers have termed this experience based knowledge as deep smarts.  A big goal of knowledge management is cataloguing and translating as much of these deep smarts as possible.  Design patterns, for software engineering, represent a library of deep smarts.
  • 19. Where Next?  Even though we’ve done five lectures on this topic, we’ve only scratched the surface.  Design patterns are rich and supported by an extensive literature.  The seminal book on the topic is called Design Patterns and is authored by the ‘Gang of Four’  Erich Gamma  Richard Helm  Ralph Johnson  John Vlissides  Students are heartily recommended to check it out.  It covers these patterns (and more) in much more depth.
  • 20. Summary  Picking a design pattern is a complex task.  Involving a mixture of skills.  There is a process you can follow to help in this.  But it doesn’t do it for you.  Thinking through the implications of scenarios that are presented is something that comes easier with practice and experience.  As you build your deep smarts.