SlideShare uma empresa Scribd logo
1 de 28
Design Patterns
How to include them in
existing code
/Studio
Architecture
• Wikipedia
– The software architecture of a program or
computing system is the structure or structures of
the system, which comprise software
components, the externally visible properties of
those components, and the relationships between
them.
Architecture defined - Decision
• Software architecture encompasses the set of significant
decisions about the organization of a software system
– Selection of the structural elements and their interfaces by
which a system is composed
– Behavior as specified in collaborations among those elements
– Composition of these structural and behavioral elements into
larger subsystems
– Architectural style that guides this organization
Booch, Kruchten, Reitman,
Bittner, and Shaw
Architecture defined - Irreversibility
• Architecture establishes the irreversible
context for design and implementation
architecture
CODE
implementation
design
Architectural
decisions are the
most fundamental
decisions; changing
them will have
significant ripple
effects because they
are hard to reverse
Architect defined - Irreversibility
• Architect’s most important tasks is to remove
architecture by finding ways to eliminate
irreversibility in software designs
Martin Fowler
Design challenges
• Design is non-deterministic
– Not a repeatable processes that are guaranteed to produce
predictable results
• Design techniques tend to be “heuristics”
– “rules of thumb”
– “things to try that sometimes work”
• Design is an iterative process
– Sloppy process
– About trade-offs and priorities
– Involves trial and error
Fundamentals heuristics
• Crisp abstractions
– Keep Your Design Modular
– Aim for Strong Cohesion
• Clear Separation of Concerns
– Stratification
• Accommodate human cognitive limitations
• Balanced distribution of responsibilities
– Find Behavior and Real-World Objects
• Keep Coupling Loose
– Hold connections among different parts to a minimum
– Formalize Class Contracts
– Encapsulate Implementation Details
Fundamentals heuristics
• Choose simple solution
– No extra parts (TDD enforce this)
– Avoid Failure
– Consider Using Brute Force
• Design for Test
• Identify Areas Likely to Change
– Extensibility, Plugins, IOC, DI
• Look for proven solution
– Patterns
Patterns defined
• A pattern is a proven solution to a common and
recurring problem
• A pattern codifies specific knowledge collected from
experience in a domain
• A pattern resolves forces in context
• All well-structured systems are full of patterns
•http://www.hillside.net
Patterns raise the level of abstraction
• For a developer the standard design elements are
objects
– Everything is an object
• For an architect the standard design elements are
patterns
Patterns creates a vocabulary
• “Everything is an object” is like an architect
summing up a house by saying “Everything is a
room”
– Big room with high voltage outlets and a sink to
cook
– Small room upstairs to sleep
• Room follow patterns and special names are
created to describe it
– Kitchen
– Bedroom
Patterns simplifies communication
• It enables packing a huge amount of information
into a short sentence
– Three-bedroom, two-bath house with an open-plan
kitchen
Patterns are proven solutions
• Not all combinations of design elements are
practical
• Bedroom and bathroom are separated
– Bathrooms have specialized and expensive
infrastructure requirements
– Bathroom require maximum privacy while
bedroom can be share
• Bathtub and toilet end up in the same room
– Both require the same infrastructure
Patterns avoid silly mistake
• Putting a toilet next to a refrigerator
• Putting dishwasher next to a bathtubs
Patterns and software design
• Starting in the 1990s software patterns were
applied in many ways with success
– Design Patterrns (Gang of four 1994)
– Enterprise architecture (Fowler 2002)
Layered Architecture
• Common technique to break apart
complicated software system into
partition in which each partition is at a
particular level of abstraction
• A layer is a cohesive and tightly
coupled partition that depends only
on the layers below
• The most simple but also the most
important enterprise application
patterns
• The hardest part of a layered
architecture is deciding what layers to
have and what the responsibilities of
each layer should be
Presentation
Infrastructure
Layers
Domain Logic
Patterns
• Use Factories to delegate the production of
objects.
• Use Decorators to avoid hierarchy explosion.
• Use Proxies to control access to objects.
• Use Strategies to pass algorithms to objects.
• Use Commands to pass requests to objects.
• Use Template Method to delegate parts of an
algorithm
• Use the Composite Pattern to treat objects and
collections uniformly.
Use Factories to delegate the production of objects.
Use Decorators to avoid hierarchy explosion
Use Proxies to control access to objects
Use Strategies to pass algorithms to objects
Use Commands to pass requests to objects
Use Template Method to delegate part of an algorithm
Use the Composite Pattern to treat objects and collections uniformly
Complexity
0
1
0 1 2 3 4 5 6
Local
Complexity
Abstraction level
Complexity
0
1
0 1 2 3 4 5 6
Local
Global
Complexity
Abstraction level
Confort zone
• Transform code to use patterns
DEMO
The end
• Remember
– Pattern for common naming
– Pattern to solve well known problem
– Watch out for complexity
• Eric De Carufel
– eric@decarufel.net
– http://blog.decarufel.net
– http://pyxis-tech.com
• Questions?
28

Mais conteúdo relacionado

Destaque

Big refactoring #12
Big refactoring #12Big refactoring #12
Big refactoring #12Jay Kim
 
TDD&Refactoring Day 01: Refactoring
TDD&Refactoring Day 01: RefactoringTDD&Refactoring Day 01: Refactoring
TDD&Refactoring Day 01: RefactoringSuwon Chae
 
[NEXT] Nextgram Refactoring
[NEXT] Nextgram Refactoring[NEXT] Nextgram Refactoring
[NEXT] Nextgram RefactoringYoungSu Son
 
Refactoring tutorial
Refactoring tutorialRefactoring tutorial
Refactoring tutorialBingu Shim
 
Refactoring tutorial 1주차[refactoring 개요]
Refactoring tutorial 1주차[refactoring 개요]Refactoring tutorial 1주차[refactoring 개요]
Refactoring tutorial 1주차[refactoring 개요]bbongcsu
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Wim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websocketsWim Godden
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developersWim Godden
 
The Progressive Web and its New Challenges - Confoo Montréal 2017
The Progressive Web and its New Challenges - Confoo Montréal 2017The Progressive Web and its New Challenges - Confoo Montréal 2017
The Progressive Web and its New Challenges - Confoo Montréal 2017Christian Heilmann
 
The Soul in The Machine - Developing for Humans
The Soul in The Machine - Developing for HumansThe Soul in The Machine - Developing for Humans
The Soul in The Machine - Developing for HumansChristian Heilmann
 

Destaque (11)

Big refactoring #12
Big refactoring #12Big refactoring #12
Big refactoring #12
 
TDD&Refactoring Day 01: Refactoring
TDD&Refactoring Day 01: RefactoringTDD&Refactoring Day 01: Refactoring
TDD&Refactoring Day 01: Refactoring
 
[NEXT] Nextgram Refactoring
[NEXT] Nextgram Refactoring[NEXT] Nextgram Refactoring
[NEXT] Nextgram Refactoring
 
Refactoring tutorial
Refactoring tutorialRefactoring tutorial
Refactoring tutorial
 
Refactoring tutorial 1주차[refactoring 개요]
Refactoring tutorial 1주차[refactoring 개요]Refactoring tutorial 1주차[refactoring 개요]
Refactoring tutorial 1주차[refactoring 개요]
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
 
The Progressive Web and its New Challenges - Confoo Montréal 2017
The Progressive Web and its New Challenges - Confoo Montréal 2017The Progressive Web and its New Challenges - Confoo Montréal 2017
The Progressive Web and its New Challenges - Confoo Montréal 2017
 
The Soul in The Machine - Developing for Humans
The Soul in The Machine - Developing for HumansThe Soul in The Machine - Developing for Humans
The Soul in The Machine - Developing for Humans
 

Semelhante a Refactoring to Design Patterns

Semelhante a Refactoring to Design Patterns (20)

Software Design Concepts
Software Design ConceptsSoftware Design Concepts
Software Design Concepts
 
Unit 5 design engineering ssad
Unit 5 design engineering ssadUnit 5 design engineering ssad
Unit 5 design engineering ssad
 
Chapter 6 design
Chapter 6 designChapter 6 design
Chapter 6 design
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
Patterns
PatternsPatterns
Patterns
 
Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5
 
Software architecture 4
Software architecture 4Software architecture 4
Software architecture 4
 
Analysis
AnalysisAnalysis
Analysis
 
unit 3 Design 1
unit 3 Design 1unit 3 Design 1
unit 3 Design 1
 
UNIT-4design-concepts-se-pressman-ppt.PPT
UNIT-4design-concepts-se-pressman-ppt.PPTUNIT-4design-concepts-se-pressman-ppt.PPT
UNIT-4design-concepts-se-pressman-ppt.PPT
 
11.ppt
11.ppt11.ppt
11.ppt
 
DESIGN PATTERN.pptx
DESIGN PATTERN.pptxDESIGN PATTERN.pptx
DESIGN PATTERN.pptx
 
DESIGN PATTERN.pptx
DESIGN PATTERN.pptxDESIGN PATTERN.pptx
DESIGN PATTERN.pptx
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Architecture in action 01
Architecture in action 01Architecture in action 01
Architecture in action 01
 
Good Slides on Architecture.ppt
Good Slides on Architecture.pptGood Slides on Architecture.ppt
Good Slides on Architecture.ppt
 
Design pattern
Design patternDesign pattern
Design pattern
 
Software Design - SDLC Model
Software Design - SDLC ModelSoftware Design - SDLC Model
Software Design - SDLC Model
 
Design engineering
Design engineeringDesign engineering
Design engineering
 

Mais de Eric De Carufel

Bracket Show Episode 35 - histoire de c# de 2002 à 2019
Bracket Show Episode 35 - histoire de c# de 2002 à 2019Bracket Show Episode 35 - histoire de c# de 2002 à 2019
Bracket Show Episode 35 - histoire de c# de 2002 à 2019Eric De Carufel
 
Architecture azure performante
Architecture azure performanteArchitecture azure performante
Architecture azure performanteEric De Carufel
 
Cqrs + event sourcing pyxis v2 - en
Cqrs + event sourcing   pyxis v2 - enCqrs + event sourcing   pyxis v2 - en
Cqrs + event sourcing pyxis v2 - enEric De Carufel
 
Top 5 des meilleures façons d'améliorer votre code
Top 5 des meilleures façons d'améliorer votre codeTop 5 des meilleures façons d'améliorer votre code
Top 5 des meilleures façons d'améliorer votre codeEric De Carufel
 
Dvcs mercurial - pyxis - eric de carufel
Dvcs   mercurial - pyxis - eric de carufelDvcs   mercurial - pyxis - eric de carufel
Dvcs mercurial - pyxis - eric de carufelEric De Carufel
 
Top 5 des meilleures façon d'améliorer ton code
Top 5 des meilleures façon d'améliorer ton codeTop 5 des meilleures façon d'améliorer ton code
Top 5 des meilleures façon d'améliorer ton codeEric De Carufel
 

Mais de Eric De Carufel (8)

Bracket Show Episode 35 - histoire de c# de 2002 à 2019
Bracket Show Episode 35 - histoire de c# de 2002 à 2019Bracket Show Episode 35 - histoire de c# de 2002 à 2019
Bracket Show Episode 35 - histoire de c# de 2002 à 2019
 
Gadgteteer clean code
Gadgteteer   clean codeGadgteteer   clean code
Gadgteteer clean code
 
Architecture azure performante
Architecture azure performanteArchitecture azure performante
Architecture azure performante
 
Cqrs + event sourcing pyxis v2 - en
Cqrs + event sourcing   pyxis v2 - enCqrs + event sourcing   pyxis v2 - en
Cqrs + event sourcing pyxis v2 - en
 
Top 5 des meilleures façons d'améliorer votre code
Top 5 des meilleures façons d'améliorer votre codeTop 5 des meilleures façons d'améliorer votre code
Top 5 des meilleures façons d'améliorer votre code
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
Dvcs mercurial - pyxis - eric de carufel
Dvcs   mercurial - pyxis - eric de carufelDvcs   mercurial - pyxis - eric de carufel
Dvcs mercurial - pyxis - eric de carufel
 
Top 5 des meilleures façon d'améliorer ton code
Top 5 des meilleures façon d'améliorer ton codeTop 5 des meilleures façon d'améliorer ton code
Top 5 des meilleures façon d'améliorer ton code
 

Último

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Último (20)

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

Refactoring to Design Patterns

  • 1. Design Patterns How to include them in existing code /Studio
  • 2. Architecture • Wikipedia – The software architecture of a program or computing system is the structure or structures of the system, which comprise software components, the externally visible properties of those components, and the relationships between them.
  • 3. Architecture defined - Decision • Software architecture encompasses the set of significant decisions about the organization of a software system – Selection of the structural elements and their interfaces by which a system is composed – Behavior as specified in collaborations among those elements – Composition of these structural and behavioral elements into larger subsystems – Architectural style that guides this organization Booch, Kruchten, Reitman, Bittner, and Shaw
  • 4. Architecture defined - Irreversibility • Architecture establishes the irreversible context for design and implementation architecture CODE implementation design Architectural decisions are the most fundamental decisions; changing them will have significant ripple effects because they are hard to reverse
  • 5. Architect defined - Irreversibility • Architect’s most important tasks is to remove architecture by finding ways to eliminate irreversibility in software designs Martin Fowler
  • 6. Design challenges • Design is non-deterministic – Not a repeatable processes that are guaranteed to produce predictable results • Design techniques tend to be “heuristics” – “rules of thumb” – “things to try that sometimes work” • Design is an iterative process – Sloppy process – About trade-offs and priorities – Involves trial and error
  • 7. Fundamentals heuristics • Crisp abstractions – Keep Your Design Modular – Aim for Strong Cohesion • Clear Separation of Concerns – Stratification • Accommodate human cognitive limitations • Balanced distribution of responsibilities – Find Behavior and Real-World Objects • Keep Coupling Loose – Hold connections among different parts to a minimum – Formalize Class Contracts – Encapsulate Implementation Details
  • 8. Fundamentals heuristics • Choose simple solution – No extra parts (TDD enforce this) – Avoid Failure – Consider Using Brute Force • Design for Test • Identify Areas Likely to Change – Extensibility, Plugins, IOC, DI • Look for proven solution – Patterns
  • 9. Patterns defined • A pattern is a proven solution to a common and recurring problem • A pattern codifies specific knowledge collected from experience in a domain • A pattern resolves forces in context • All well-structured systems are full of patterns •http://www.hillside.net
  • 10. Patterns raise the level of abstraction • For a developer the standard design elements are objects – Everything is an object • For an architect the standard design elements are patterns
  • 11. Patterns creates a vocabulary • “Everything is an object” is like an architect summing up a house by saying “Everything is a room” – Big room with high voltage outlets and a sink to cook – Small room upstairs to sleep • Room follow patterns and special names are created to describe it – Kitchen – Bedroom
  • 12. Patterns simplifies communication • It enables packing a huge amount of information into a short sentence – Three-bedroom, two-bath house with an open-plan kitchen
  • 13. Patterns are proven solutions • Not all combinations of design elements are practical • Bedroom and bathroom are separated – Bathrooms have specialized and expensive infrastructure requirements – Bathroom require maximum privacy while bedroom can be share • Bathtub and toilet end up in the same room – Both require the same infrastructure
  • 14. Patterns avoid silly mistake • Putting a toilet next to a refrigerator • Putting dishwasher next to a bathtubs
  • 15. Patterns and software design • Starting in the 1990s software patterns were applied in many ways with success – Design Patterrns (Gang of four 1994) – Enterprise architecture (Fowler 2002)
  • 16. Layered Architecture • Common technique to break apart complicated software system into partition in which each partition is at a particular level of abstraction • A layer is a cohesive and tightly coupled partition that depends only on the layers below • The most simple but also the most important enterprise application patterns • The hardest part of a layered architecture is deciding what layers to have and what the responsibilities of each layer should be Presentation Infrastructure Layers Domain Logic
  • 17. Patterns • Use Factories to delegate the production of objects. • Use Decorators to avoid hierarchy explosion. • Use Proxies to control access to objects. • Use Strategies to pass algorithms to objects. • Use Commands to pass requests to objects. • Use Template Method to delegate parts of an algorithm • Use the Composite Pattern to treat objects and collections uniformly.
  • 18. Use Factories to delegate the production of objects.
  • 19. Use Decorators to avoid hierarchy explosion
  • 20. Use Proxies to control access to objects
  • 21. Use Strategies to pass algorithms to objects
  • 22. Use Commands to pass requests to objects
  • 23. Use Template Method to delegate part of an algorithm
  • 24. Use the Composite Pattern to treat objects and collections uniformly
  • 25. Complexity 0 1 0 1 2 3 4 5 6 Local Complexity Abstraction level
  • 26. Complexity 0 1 0 1 2 3 4 5 6 Local Global Complexity Abstraction level Confort zone
  • 27. • Transform code to use patterns DEMO
  • 28. The end • Remember – Pattern for common naming – Pattern to solve well known problem – Watch out for complexity • Eric De Carufel – eric@decarufel.net – http://blog.decarufel.net – http://pyxis-tech.com • Questions? 28