SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Selected Design Patterns
Prof. Dr. Ralf Lämmel
Universität Koblenz-Landau
Software Languages Team
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Reusable solutions to
recurrent problems
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Selected patterns
(Pattern names with intents)
Composite -- provide uniform interface on part-whole hierarchies
Command -- encapsulate the execution of functionality; enable undo
Visitor -- represent operations on object structure as objects
Observer -- provide change notifications to objects depending on state
MVC -- decouple model, view, control in for interactive applications
Proxy -- refine or replace behavior of a given object
Object Adapter -- provide a different interface for an existing object
Template Method -- capture general structure of an algorithm
...
Intent = short combo
of problem + solution
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Observer -- Problem
The observer pattern (aka publish/subscribe) involves
an object, called the subject, which maintains a list of
its dependents, called observers, and notifies them
automatically of any state changes.
Do you know the problem?
Do you know a solution?
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Observer -- Solution
http://en.wikipedia.org/wiki/File:Observer.svg
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Essential elements of a
design pattern
Name
The problem describes when to apply the pattern.
The solution describes elements of the design, their
relationships, responsibilities, and collaborations.
The consequences are the results and trade-offs of
applying the pattern.
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Describing design patterns
Pattern Name
Classification
Intent
Also Known As
Motivation
Applicability
Structure
Participants
Collaborations
Consequences
Implementation
Sample Code
Known Uses
Related Patterns
We do
not go into all
these details in this
course.
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Classification of
design patterns
Aspects
Creational patterns
Structural patterns
Behavioral patterns
Scope
Class
Object
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Design patterns -- Overview
[Gamma et al., 1995, S. 10]
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Design patterns
of this slide deck
Template Method
Abstract Factory
Object Adapter
Observer
Proxy
You are definitely
expected to expand on
your knowledge of
design patterns.
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Abstract Factory -- Problem
Object models often give rise to variation. For instance,
there may be multiple GUI libraries subject to different
widget hierarchies. Whenever components want to
abstract from the specific choice, then substantial efforts
are required. For instance, the construction of objects
must be tunneled through a factory.
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Abstract Factory -- Solution
http://sourcemaking.com/design_patterns/abstract_factory
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Abstract Factory
DEMO
Two alternative object models for companies.
POJOs
Some sort of beans
Make the choice of the object model configurable.
Contribution:javaExorcism
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Proxy -- Problem
Additional access behavior for objects
Access management for remote objects
Access management for expensive objects
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Proxy -- Solution
http://en.wikipedia.org/wiki/File:Proxy_pattern_diagram.svg
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Proxy -- Scenarios
Additional access behavior for objects
Access management for remote objects
Access management for expensive objects
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Proxy
DEMO
Use security proxy to protect salary access.
Interesting issue of proxy deployment.
Contribution:javaExorcism
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Observer -- Problem
The observer pattern (aka publish/subscribe) involves
an object, called the subject, which maintains a list of
its dependents, called observers, and notifies them
automatically of any state changes.
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Observer -- Solution
http://en.wikipedia.org/wiki/File:Observer.svg
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Observer
DEMO
Use observer to providing logging.
Use observer to enforce data constraint.
Contribution:javaExorcism
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Object Adapter -- Problem
A given object often has about the right capabilities for a
specific client but not necessarily the precise interface
expected. Accordingly, an interface adaptation can be
achieved by an extra wrapper around the given object.
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Adapter -- Solution
(object adapters)
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Adapter -- Solution
(class adapters)
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Adapter
DEMO
Class adapter: add observability of list interface.
Object adapter: downgrade java.util.List to simple list.
Contribution:javaExorcism
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Template Method -- Problem
Some algorithms or strategies in a system may be very
similar and hence it may be desirable to capture their
commonalities in a sort of template so that specifics can
be expressed through refinement giving rise to a high
degree of reuse.
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Template Method -- Solution
http://stephane.ducasse.free.fr/FreeBooks/SmalltalkDesignPatternCompanion/templateMethod.pdf
Intent
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Temp
Method lets subclasses redefine certain steps of an algorithm without changing the algorith
structure.
Structure
Description
Template Method may be #1 on the Design Patterns Pop Charts. Its structure and use are at the h
of much of object-oriented programming. Template Method turns on the fundamental object-orie
templateMethod
AbstractClass
ConcreteClassA
primitiveMethod2
primitiveMethod1
primitiveMethod1
primitiveMethod2
...
self primitiveMethod1.
...
self primitiveMethod2.
...
ConcreteClassB
primitiveMethod1
primitiveMethod2
ConcreteClassC
primitiveMethod2
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Template
DEMO
Two general class of algorithms can identified:
Queries such as 101feature:Total
Transformations such as 101feature:Cut
Contribution:javaTemplate
Contribution:javaExorcism
(C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Summary
The use of design patterns is a basic element of software
development. If you wouldn’t use them, your designs
and implementations are unnecessarily unstandardized,
idiosyncratic, incomprehensible, unmaintainable, etc.
That is, if you are interested in a software development
career, or you plan to talk to software developers at an
interesting level of detail, you have to aggregate
substantial knowledge of design patterns.

Mais conteúdo relacionado

Mais procurados

Interoperability of Meta-Modeling Tools
Interoperability of Meta-Modeling ToolsInteroperability of Meta-Modeling Tools
Interoperability of Meta-Modeling Toolsheigoo
 
LDAC 2015 - Towards an industry-wide ifcOWL: choices and issues
LDAC 2015 - Towards an industry-wide ifcOWL: choices and issuesLDAC 2015 - Towards an industry-wide ifcOWL: choices and issues
LDAC 2015 - Towards an industry-wide ifcOWL: choices and issuesPieter Pauwels
 
Generative programming (mostly parser generation)
Generative programming (mostly parser generation)Generative programming (mostly parser generation)
Generative programming (mostly parser generation)Ralf Laemmel
 
Model Comparison for Delta-Compression
Model Comparison for Delta-CompressionModel Comparison for Delta-Compression
Model Comparison for Delta-CompressionMarkus Scheidgen
 
Generation of Random EMF Models for Benchmarks
Generation of Random EMF Models for BenchmarksGeneration of Random EMF Models for Benchmarks
Generation of Random EMF Models for BenchmarksMarkus Scheidgen
 

Mais procurados (7)

Interoperability of Meta-Modeling Tools
Interoperability of Meta-Modeling ToolsInteroperability of Meta-Modeling Tools
Interoperability of Meta-Modeling Tools
 
Topic 1 PBO
Topic 1 PBOTopic 1 PBO
Topic 1 PBO
 
LDAC 2015 - Towards an industry-wide ifcOWL: choices and issues
LDAC 2015 - Towards an industry-wide ifcOWL: choices and issuesLDAC 2015 - Towards an industry-wide ifcOWL: choices and issues
LDAC 2015 - Towards an industry-wide ifcOWL: choices and issues
 
Generative programming (mostly parser generation)
Generative programming (mostly parser generation)Generative programming (mostly parser generation)
Generative programming (mostly parser generation)
 
Matlab OOP
Matlab OOPMatlab OOP
Matlab OOP
 
Model Comparison for Delta-Compression
Model Comparison for Delta-CompressionModel Comparison for Delta-Compression
Model Comparison for Delta-Compression
 
Generation of Random EMF Models for Benchmarks
Generation of Random EMF Models for BenchmarksGeneration of Random EMF Models for Benchmarks
Generation of Random EMF Models for Benchmarks
 

Destaque

Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013
Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013
Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013Ralf Laemmel
 
Fotos De Santa Catarina
Fotos De Santa CatarinaFotos De Santa Catarina
Fotos De Santa Catarinaichliebe
 
C004 60190 02238 1 Roberts Stuart
C004 60190 02238 1 Roberts StuartC004 60190 02238 1 Roberts Stuart
C004 60190 02238 1 Roberts StuartStuartRoberts
 
Grey Food Trends - Recession and "Credit Crunch Cuisine"
Grey Food Trends - Recession and "Credit Crunch Cuisine"Grey Food Trends - Recession and "Credit Crunch Cuisine"
Grey Food Trends - Recession and "Credit Crunch Cuisine"Andre Prior
 
Functional data structures
Functional data structuresFunctional data structures
Functional data structuresRalf Laemmel
 
Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)Ralf Laemmel
 
Ramadan For Bodyand Soul
Ramadan For Bodyand SoulRamadan For Bodyand Soul
Ramadan For Bodyand Soulaskme
 
Do U Know Him
Do U Know HimDo U Know Him
Do U Know Himaskme
 
Human Generation
Human GenerationHuman Generation
Human Generationaskme
 
Modeling software systems at a macroscopic scale
Modeling software systems  at a macroscopic scaleModeling software systems  at a macroscopic scale
Modeling software systems at a macroscopic scaleRalf Laemmel
 

Destaque (12)

Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013
Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013
Surfacing ‘101’ in a Linked Data manner as presented at SATToSE 2013
 
XML data binding
XML data bindingXML data binding
XML data binding
 
Fotos De Santa Catarina
Fotos De Santa CatarinaFotos De Santa Catarina
Fotos De Santa Catarina
 
C004 60190 02238 1 Roberts Stuart
C004 60190 02238 1 Roberts StuartC004 60190 02238 1 Roberts Stuart
C004 60190 02238 1 Roberts Stuart
 
Grey Food Trends - Recession and "Credit Crunch Cuisine"
Grey Food Trends - Recession and "Credit Crunch Cuisine"Grey Food Trends - Recession and "Credit Crunch Cuisine"
Grey Food Trends - Recession and "Credit Crunch Cuisine"
 
Ec305.13 buses mgl
Ec305.13 buses mglEc305.13 buses mgl
Ec305.13 buses mgl
 
Functional data structures
Functional data structuresFunctional data structures
Functional data structures
 
Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)
 
Ramadan For Bodyand Soul
Ramadan For Bodyand SoulRamadan For Bodyand Soul
Ramadan For Bodyand Soul
 
Do U Know Him
Do U Know HimDo U Know Him
Do U Know Him
 
Human Generation
Human GenerationHuman Generation
Human Generation
 
Modeling software systems at a macroscopic scale
Modeling software systems  at a macroscopic scaleModeling software systems  at a macroscopic scale
Modeling software systems at a macroscopic scale
 

Semelhante a Selected design patterns (as part of the the PTT lecture)

Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)Ralf Laemmel
 
Multithreaded programming (as part of the the PTT lecture)
Multithreaded programming (as part of the the PTT lecture)Multithreaded programming (as part of the the PTT lecture)
Multithreaded programming (as part of the the PTT lecture)Ralf Laemmel
 
P Training Presentation
P Training PresentationP Training Presentation
P Training PresentationGaurav Tyagi
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Ralf Laemmel
 
Writting Better Software
Writting Better SoftwareWritting Better Software
Writting Better Softwaresvilen.ivanov
 
DRESD Project Presentation - December 2006
DRESD Project Presentation - December 2006DRESD Project Presentation - December 2006
DRESD Project Presentation - December 2006santa
 
MODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSE
MODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSEMODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSE
MODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSEAnže Vodovnik
 
A Program Transformation Technique to Support Aspect-Oriented Programming wit...
A Program Transformation Technique to Support Aspect-Oriented Programming wit...A Program Transformation Technique to Support Aspect-Oriented Programming wit...
A Program Transformation Technique to Support Aspect-Oriented Programming wit...Sabrina Ball
 
Database programming including O/R mapping (as part of the the PTT lecture)
Database programming including O/R mapping (as part of the the PTT lecture)Database programming including O/R mapping (as part of the the PTT lecture)
Database programming including O/R mapping (as part of the the PTT lecture)Ralf Laemmel
 
Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016Russell Childs
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
MoDisco & ATL - Eclipse DemoCamp Indigo 2011 in Nantes
MoDisco & ATL - Eclipse DemoCamp Indigo 2011 in NantesMoDisco & ATL - Eclipse DemoCamp Indigo 2011 in Nantes
MoDisco & ATL - Eclipse DemoCamp Indigo 2011 in NantesHugo Bruneliere
 
Full_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_ChildsFull_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_ChildsRussell Childs
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
Object oriented design-UNIT V
Object oriented design-UNIT VObject oriented design-UNIT V
Object oriented design-UNIT VAzhar Shaik
 
Extending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective LanguagesExtending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective Languagesfranciscoortin
 

Semelhante a Selected design patterns (as part of the the PTT lecture) (20)

Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)
 
Multithreaded programming (as part of the the PTT lecture)
Multithreaded programming (as part of the the PTT lecture)Multithreaded programming (as part of the the PTT lecture)
Multithreaded programming (as part of the the PTT lecture)
 
L03 Design Patterns
L03 Design PatternsL03 Design Patterns
L03 Design Patterns
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)
 
Day1
Day1Day1
Day1
 
Writting Better Software
Writting Better SoftwareWritting Better Software
Writting Better Software
 
DRESD Project Presentation - December 2006
DRESD Project Presentation - December 2006DRESD Project Presentation - December 2006
DRESD Project Presentation - December 2006
 
MODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSE
MODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSEMODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSE
MODEL DRIVEN ARCHITECTURE, CONTROL SYSTEMS AND ECLIPSE
 
A Program Transformation Technique to Support Aspect-Oriented Programming wit...
A Program Transformation Technique to Support Aspect-Oriented Programming wit...A Program Transformation Technique to Support Aspect-Oriented Programming wit...
A Program Transformation Technique to Support Aspect-Oriented Programming wit...
 
Database programming including O/R mapping (as part of the the PTT lecture)
Database programming including O/R mapping (as part of the the PTT lecture)Database programming including O/R mapping (as part of the the PTT lecture)
Database programming including O/R mapping (as part of the the PTT lecture)
 
Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
MoDisco & ATL - Eclipse DemoCamp Indigo 2011 in Nantes
MoDisco & ATL - Eclipse DemoCamp Indigo 2011 in NantesMoDisco & ATL - Eclipse DemoCamp Indigo 2011 in Nantes
MoDisco & ATL - Eclipse DemoCamp Indigo 2011 in Nantes
 
Full_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_ChildsFull_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_Childs
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Object oriented design-UNIT V
Object oriented design-UNIT VObject oriented design-UNIT V
Object oriented design-UNIT V
 
Ase02 dmp.ppt
Ase02 dmp.pptAse02 dmp.ppt
Ase02 dmp.ppt
 
Extending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective LanguagesExtending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective Languages
 
ALT
ALTALT
ALT
 

Último

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Selected design patterns (as part of the the PTT lecture)

  • 1. Selected Design Patterns Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team
  • 2. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Reusable solutions to recurrent problems
  • 3. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Selected patterns (Pattern names with intents) Composite -- provide uniform interface on part-whole hierarchies Command -- encapsulate the execution of functionality; enable undo Visitor -- represent operations on object structure as objects Observer -- provide change notifications to objects depending on state MVC -- decouple model, view, control in for interactive applications Proxy -- refine or replace behavior of a given object Object Adapter -- provide a different interface for an existing object Template Method -- capture general structure of an algorithm ... Intent = short combo of problem + solution
  • 4. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Observer -- Problem The observer pattern (aka publish/subscribe) involves an object, called the subject, which maintains a list of its dependents, called observers, and notifies them automatically of any state changes. Do you know the problem? Do you know a solution?
  • 5. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Observer -- Solution http://en.wikipedia.org/wiki/File:Observer.svg
  • 6. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Essential elements of a design pattern Name The problem describes when to apply the pattern. The solution describes elements of the design, their relationships, responsibilities, and collaborations. The consequences are the results and trade-offs of applying the pattern.
  • 7. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Describing design patterns Pattern Name Classification Intent Also Known As Motivation Applicability Structure Participants Collaborations Consequences Implementation Sample Code Known Uses Related Patterns We do not go into all these details in this course.
  • 8. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Classification of design patterns Aspects Creational patterns Structural patterns Behavioral patterns Scope Class Object
  • 9. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Design patterns -- Overview [Gamma et al., 1995, S. 10]
  • 10. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Design patterns of this slide deck Template Method Abstract Factory Object Adapter Observer Proxy You are definitely expected to expand on your knowledge of design patterns.
  • 11. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Abstract Factory -- Problem Object models often give rise to variation. For instance, there may be multiple GUI libraries subject to different widget hierarchies. Whenever components want to abstract from the specific choice, then substantial efforts are required. For instance, the construction of objects must be tunneled through a factory.
  • 12. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Abstract Factory -- Solution http://sourcemaking.com/design_patterns/abstract_factory
  • 13. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Abstract Factory DEMO Two alternative object models for companies. POJOs Some sort of beans Make the choice of the object model configurable. Contribution:javaExorcism
  • 14. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Proxy -- Problem Additional access behavior for objects Access management for remote objects Access management for expensive objects
  • 15. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Proxy -- Solution http://en.wikipedia.org/wiki/File:Proxy_pattern_diagram.svg
  • 16. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Proxy -- Scenarios Additional access behavior for objects Access management for remote objects Access management for expensive objects
  • 17. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Proxy DEMO Use security proxy to protect salary access. Interesting issue of proxy deployment. Contribution:javaExorcism
  • 18. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Observer -- Problem The observer pattern (aka publish/subscribe) involves an object, called the subject, which maintains a list of its dependents, called observers, and notifies them automatically of any state changes.
  • 19. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Observer -- Solution http://en.wikipedia.org/wiki/File:Observer.svg
  • 20. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Observer DEMO Use observer to providing logging. Use observer to enforce data constraint. Contribution:javaExorcism
  • 21. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Object Adapter -- Problem A given object often has about the right capabilities for a specific client but not necessarily the precise interface expected. Accordingly, an interface adaptation can be achieved by an extra wrapper around the given object.
  • 22. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Adapter -- Solution (object adapters)
  • 23. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Adapter -- Solution (class adapters)
  • 24. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Adapter DEMO Class adapter: add observability of list interface. Object adapter: downgrade java.util.List to simple list. Contribution:javaExorcism
  • 25. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Template Method -- Problem Some algorithms or strategies in a system may be very similar and hence it may be desirable to capture their commonalities in a sort of template so that specifics can be expressed through refinement giving rise to a high degree of reuse.
  • 26. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Template Method -- Solution http://stephane.ducasse.free.fr/FreeBooks/SmalltalkDesignPatternCompanion/templateMethod.pdf Intent Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Temp Method lets subclasses redefine certain steps of an algorithm without changing the algorith structure. Structure Description Template Method may be #1 on the Design Patterns Pop Charts. Its structure and use are at the h of much of object-oriented programming. Template Method turns on the fundamental object-orie templateMethod AbstractClass ConcreteClassA primitiveMethod2 primitiveMethod1 primitiveMethod1 primitiveMethod2 ... self primitiveMethod1. ... self primitiveMethod2. ... ConcreteClassB primitiveMethod1 primitiveMethod2 ConcreteClassC primitiveMethod2
  • 27. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Template DEMO Two general class of algorithms can identified: Queries such as 101feature:Total Transformations such as 101feature:Cut Contribution:javaTemplate Contribution:javaExorcism
  • 28. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable) Summary The use of design patterns is a basic element of software development. If you wouldn’t use them, your designs and implementations are unnecessarily unstandardized, idiosyncratic, incomprehensible, unmaintainable, etc. That is, if you are interested in a software development career, or you plan to talk to software developers at an interesting level of detail, you have to aggregate substantial knowledge of design patterns.