I Love Patterns
-
Upload
matt-ruma -
Category
Technology
-
view
113 -
download
5
description
Transcript of I Love Patterns
![Page 1: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/1.jpg)
I <3 Patterns
Matt Ruma (@mattruma)Ann Arbor Day of .NET, October 29, 2011
![Page 2: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/2.jpg)
You work small miracles every day.
Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From Journeyman to Master.
![Page 3: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/3.jpg)
It’s a difficult job.
Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From Journeyman to Master.
![Page 4: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/4.jpg)
There are no easy answers.
Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From Journeyman to Master.
![Page 5: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/5.jpg)
You get the job done, and do it well.
Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From Journeyman to Master.
![Page 6: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/6.jpg)
You want to become a better software developer.
Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From Journeyman to Master.
![Page 7: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/7.jpg)
Patterns will help you become a better software
developer.
![Page 8: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/8.jpg)
Agenda
• Patterns in the wild• Speaking in patterns• Patterns defined• Advantages of patterns• Disadvantages of patterns (not really)• Pattern examples• Chase a rabbit, look at anti-patterns• Getting started with patterns• Wrap things up
![Page 9: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/9.jpg)
PATTERNS IN THE WILD
![Page 10: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/10.jpg)
Patterns are models deserving of imitation.
![Page 11: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/11.jpg)
Patterns in books and movies.
![Page 12: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/12.jpg)
Patterns in music.
![Page 13: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/13.jpg)
Patterns in presentations.
![Page 14: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/14.jpg)
Patterns for raising children.
![Page 15: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/15.jpg)
On and on we could go.
• Patterns for operating a gas station.• Patterns for operating a restaurant.• Patterns for operating a customer
service desk.• Patterns for putting on a conference.• Patterns for the construction of
buildings.
![Page 16: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/16.jpg)
Patterns are part of everyday life.
![Page 17: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/17.jpg)
SPEAKING IN PATTERNS
![Page 18: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/18.jpg)
Is beauty in the eye of the beholder?
Alexander, Christopher (1977). A Pattern Language: Towns, Buildings, Construction.
![Page 19: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/19.jpg)
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.
Alexander, Christopher (1977). A Pattern Language: Towns, Buildings, Construction.
![Page 20: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/20.jpg)
Architecture Patterns
• Accessible Green• Four Story Limit• Warm Colors
Alexander, Christopher (1977). A Pattern Language: Towns, Buildings, Construction.
![Page 21: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/21.jpg)
What does all this architectural babble have to
do with software developers?
![Page 22: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/22.jpg)
PATTERNS DEFINED
![Page 23: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/23.jpg)
Patterns describe a recurring problem and a
solution.
![Page 24: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/24.jpg)
Each pattern, in its simplest form, is a three-part rule,
which expresses a relation between a certain context, a problem, and a solution.
![Page 25: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/25.jpg)
Pattern Elements
• Context is the situation in which the pattern applies.
• Problem refers to the goal you are trying to achieve in this context.
• Solution is what you’re after: a general design that anyone can apply which resolves the goal and set of constraints.
![Page 26: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/26.jpg)
Chocolate Chip Ratio
• Context. You are baking chocolate chip cookies in small batches for family and friends
• Problem. Determine the optimum ratio of chocolate chips to cookie dough
• Solution. Observe that most people consider chocolate to be the best part of the chocolate chip cookie. Also observe that too much chocolate may prevent the cookie from holding together, decreasing its appeal. Since you are cooking in small batches, cost is not a consideration. Therefore, use the maximum amount of chocolate chips that results in a really sturdy cookie.
![Page 27: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/27.jpg)
Patterns != Principles
![Page 28: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/28.jpg)
Patterns are discovered not created.
Alexander, Christopher (1977). Timeless Way of Building
![Page 29: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/29.jpg)
ADVANTAGES
![Page 30: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/30.jpg)
Someone has already solved your problem.
Freeman, Elisabeth; Freeman, Eric; Bates, Bert; Sierra, Kathy (2004). Head First Design Patterns
![Page 31: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/31.jpg)
Keeps you sane.
![Page 32: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/32.jpg)
Allows for change.
![Page 33: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/33.jpg)
Establish common terminology to improve communication within
teams.
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 34: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/34.jpg)
So many words
Carpenter 1: How do you think we should build these drawers?
Carpenter 2: Well, I think we should make the joint by cutting straight down into the wood, and then cut back up the other way 45 degrees, and then going straight back down, and then …
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 35: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/35.jpg)
Just right
Carpenter 1: Show we use a dovetail joint or a miter joint?
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 36: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/36.jpg)
You are saying more with less.
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 37: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/37.jpg)
Allows you to stay in the “design” frame of mind.
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 38: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/38.jpg)
Move more quickly, less room for misunderstanding.
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 39: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/39.jpg)
Motivates junior developers.
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 40: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/40.jpg)
Uncle Bob says so.
![Page 41: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/41.jpg)
DISADVANTAGES
![Page 42: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/42.jpg)
Disadvantages, some so-so
• Maslow’s hammer• Too complex• Different interpretations• Whoops! Using the wrong one• Pattern happy
Shalloway, Allen; Trott, James (2005). Designs Patterns Explained: A New Perspective on Object-Oriented Design
![Page 43: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/43.jpg)
EXAMPLES
![Page 44: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/44.jpg)
Pattern Categories
• Design Patterns• Application Architecture Patterns• Database Patterns• Refactoring Patterns• Application Presentation Patterns• User Interface Patterns
![Page 45: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/45.jpg)
Design Patterns
• Descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context
• Purpose can be creational, structural and behavioral
• Scope can be class or object• Catalogued 23 popular patterns• Singleton, Decorator, Adapter, Façade,
Composite and FactoryGamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John M. (1994). Design Patterns: Elements of Reusable Object-Oriented Software
![Page 46: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/46.jpg)
Application Architecture Patterns
• Client/Server• Layered• Multi-Tier (N-Tier)• Service Oriented Architecture (SOA)• Message Bus
![Page 47: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/47.jpg)
Database Patterns
• Table design– Small master– Large master
• Database normalization– First normal form– Second normal form– Third normal form or Business normal
form
![Page 48: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/48.jpg)
Refactoring Patterns
• Code– Extract method– Extract interface– Rename method– Replace inheritance with delegation
• Database– Drop column– Introduce soft delete– Split table– Add lookup table
![Page 49: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/49.jpg)
Application Presentation Patterns
• Model View Presenter (MVP)• Model View Controller (MVC)• Model View View Model (MVVM)
![Page 50: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/50.jpg)
User Interface Patterns
• Lazy registration• Progressive Disclosure• Forgiving format• Clear primary actions
http://uxdesign.smashingmagazine.com/2009/06/23/10-ui-design-patterns-you-should-be-paying-attention-to/
![Page 51: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/51.jpg)
ANTI-PATTERNSChasing a Fat Rabbit
![Page 52: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/52.jpg)
Anti-pattern
• Tells you why a bad solution is attractive.
• Tells you why that solution in the long term is bad.
• Suggests other patterns which may provide good solutions.
• Code smells.
![Page 53: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/53.jpg)
Examples of Anti-patterns
• Death march• Gold plating• God object• Object orgy• Reinventing the wheel
![Page 54: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/54.jpg)
GETTING STARTED WITH PATTERNS
![Page 55: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/55.jpg)
Start learning
![Page 56: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/56.jpg)
Start talking in patterns
![Page 57: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/57.jpg)
Start using patterns
![Page 58: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/58.jpg)
The best designs will use multiple design patterns
![Page 59: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/59.jpg)
Build you own patterns catalog
• Pattern name• Description of the problem• Solution to the problem (include
examples)• Consequences
![Page 60: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/60.jpg)
CONCLUSION
![Page 61: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/61.jpg)
Wrapping things up
• Patterns are everywhere.• Patterns describe a problem and provide a
solution.• Patterns embody principles.• The advantages of using patterns far out weigh
their disadvantages.• Beware of anti-patterns.• Just do it• Using patterns in all facets of software
development will make us better developers.• Better developers write better software.
![Page 62: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/62.jpg)
62
References• The Timeless Way of Building by Christopher Alexander
• A Pattern Language: Towns, Buildings, Construction by Christopher Alexander, Sara Ishikawa and Murray Silverstein
• Design Patterns: Elements of Reusable Object-Oriented Software by Eric Gamma, Richard Helm, Ralph Johnson and John Vlissides
• Design Patterns Explained: A New Perspective on Object-Oriented Design by Alan Shalloway and James Trott
• Refactoring to Patterns by Joshua Kerievsky
• The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and David Thomas
• Agile Principles, Patterns and Practices in C# by Robert Martin and Micah Martin
• Head First Design Patterns by Eric Freeman, Elisabeth Freeman, Kathy Sierra and Bert Bates
• Universal Principles of Design by William Lidwell, Kritina Holden and Jill Butler
• Refactoring Databases: Evolutionary Database Design Scott Ambler and Pramodkumar Sadalage
• Adrenaline Junkies and Template Zombies: Understanding Patterns of Project Behavior by Tom Demarco, Peter Hruschka, Tim Lister and Suzanne Robertson
• Smashing Magazine http://smashingmagazine.com
![Page 63: I Love Patterns](https://reader034.fdocuments.in/reader034/viewer/2022042623/54c8315e4a7959986d8b4585/html5/thumbnails/63.jpg)
Go work some small miracles.
Matt RumaMaster Technology GuideEpitec Group
mattruma
mattruma.com