SlideShare a Scribd company logo
1 of 24
Design Patterns
Jane.com Mountain
Jeff Potter
@jpotts18
Introduction
One tool for the job.
Understand it and use it, don’t abuse it
A design pattern is a general reusable
solution to commonly occurring problems
within a given context in software design.
What are design patterns?
● Initiated by Kent Beck &
Ward Cunningham
● Gang of Four wrote - Design
Patterns: Elements of Reusable
Object-Oriented Software
● Sold 500k books and 13
languages
Where did they come from?
Design Pattern Classifications
Creational Structural Behavioral
Creational Patterns
Aim to separate a system from how its objects are created,
composed, and represented.
Factory
Lazy Initialization
Prototype
Singleton
Have you seen these?
Use inheritance to compose interfaces and define ways to
compose objects to obtain new functionality
● Adapter
● Composite
● Decorator
● Proxy
Any experience with these?
Structural Patterns
Behavioral Patterns
Specifically concerned with the communication between objects.
● Template Method
● Observer
● Strategy
● Command
Do we use any of these at Jane.com?
Lets use a design
pattern!
Template Method: Encapsulate and Extend Algorithms
An algorithm is a step-by-step procedure for accomplishing some
end.
We follow millions of learned algorithms daily. One high level
algorithm that I do is called my morning routine. Let’s code it!
Create a new file in your language of choice.
Taken from blog - http://bit.ly/1TTrNwa
Morning Algorithm
1. Wake-up
2. Work out
3. Eat Breakfast
4. Drive to work
● execute() - Template Method
○ Encapsulates the steps
○ Executes without knowing
method implementation
1. wakeUp()
2. workOut()
3. eatBreakfast()
4. driveToWork()
Pseudo Code
Late Morning Algorithm
1. Wakeup
2. Skip Workout
3. Eat Fast Breakfast
4. Drive to work
● Inherit from MorningAlgorithm
● workOut()
○ Skip
● eatBreakfast()
○ Eat something quick
● driveToWork()
lma = new LateMorningAlgorithm()
lma.execute();
Pseudo Code
Is This Really Practical?
● Generating Emails
○ Fetch Data, Generate HTML, Send to Email Service
● Website Scraping
○ Download, parser, format data, export
● iOS ViewController Lifecycles
○ viewWillAppear, viewDidAppear
When have you seen the Template Method
pattern?
Caveat 1: Speculative Design
Trying to use all the patterns is a bad thing, because you will end
up with synthetic designs—speculative designs that have
flexibility that no one needs. These days software is too complex.
We can’t afford to speculate what else it should do. We need to
really focus on what it needs.” – Erich Gamma (GoF)
You Ain’t Gonna Need It
Keep It Simple Stupid!
4 Design Pattern to say in Hello World
http://bit.ly/1MkvyVJ
Caveat 2: YAGNI & KISS
Caveat 3: Language Suitability
Patterns that imply mutable state may be unsuited for functional
programming languages, some patterns can be rendered
unnecessary in languages that have built in support for solving
the problem they are trying to solve, and object-oriented
patterns are not necessary suitable for non-object-oriented
languages.
Great Resources
Thanks!
Sources
http://bit.ly/1TTrNwa
https://en.wikipedia.org/wiki/Software_design_pattern
https://taskinoor.wordpress.com/2011/09/21/the-abuse-of-design-patterns-in-writing-a-
hello-world-program/
https://sourcemaking.com
https://sourcemaking.com/design_patterns/template_method

More Related Content

Similar to Design patterns

Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014Alan Richardson
 
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...Dataconomy Media
 
Machine Learning Infrastructure
Machine Learning InfrastructureMachine Learning Infrastructure
Machine Learning InfrastructureSigOpt
 
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdfLearn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdfNemoPalleschi
 
Services, tools & practices for a software house
Services, tools & practices for a software houseServices, tools & practices for a software house
Services, tools & practices for a software houseParis Apostolopoulos
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy CodeAndrea Polci
 
Hybrid model for software development
Hybrid model for software developmentHybrid model for software development
Hybrid model for software developmenteSAT Journals
 
Lecture 7 program development issues (supplementary)
Lecture 7  program development issues (supplementary)Lecture 7  program development issues (supplementary)
Lecture 7 program development issues (supplementary)alvin567
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software DesignGiorgio Zoppi
 
Pentester++
Pentester++Pentester++
Pentester++CTruncer
 
Hack 2.0 Lego Agile Workshop
Hack 2.0 Lego Agile WorkshopHack 2.0 Lego Agile Workshop
Hack 2.0 Lego Agile WorkshopCharityComms
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptAyush Sharma
 
"What we learned from 5 years of building a data science software that actual...
"What we learned from 5 years of building a data science software that actual..."What we learned from 5 years of building a data science software that actual...
"What we learned from 5 years of building a data science software that actual...Dataconomy Media
 
Bridging the gap in enterprise AI
Bridging the gap in enterprise AIBridging the gap in enterprise AI
Bridging the gap in enterprise AIMax Pumperla
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code cleanBrett Child
 
Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Adi Bolboaca
 
Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?Kris Buytaert
 
AI hype or reality
AI  hype or realityAI  hype or reality
AI hype or realityAwantik Das
 

Similar to Design patterns (20)

Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014
 
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
DN18 | Demystifying the Buzz in Machine Learning! (This Time for Real) | Dat ...
 
Machine Learning Infrastructure
Machine Learning InfrastructureMachine Learning Infrastructure
Machine Learning Infrastructure
 
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdfLearn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
 
Services, tools & practices for a software house
Services, tools & practices for a software houseServices, tools & practices for a software house
Services, tools & practices for a software house
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Hybrid model for software development
Hybrid model for software developmentHybrid model for software development
Hybrid model for software development
 
Lecture 7 program development issues (supplementary)
Lecture 7  program development issues (supplementary)Lecture 7  program development issues (supplementary)
Lecture 7 program development issues (supplementary)
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
 
Pentester++
Pentester++Pentester++
Pentester++
 
Hack 2.0 Lego Agile Workshop
Hack 2.0 Lego Agile WorkshopHack 2.0 Lego Agile Workshop
Hack 2.0 Lego Agile Workshop
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
"What we learned from 5 years of building a data science software that actual...
"What we learned from 5 years of building a data science software that actual..."What we learned from 5 years of building a data science software that actual...
"What we learned from 5 years of building a data science software that actual...
 
Bridging the gap in enterprise AI
Bridging the gap in enterprise AIBridging the gap in enterprise AI
Bridging the gap in enterprise AI
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018
 
Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?
 
AI hype or reality
AI  hype or realityAI  hype or reality
AI hype or reality
 

Design patterns