Summary
Beknopte samenvatting OO Ontwerpen III
Institution
Hogeschool Gent (HoGent)
Zeer beknopte samenvatting van alle design patterns met kleine uitleg.
Inclusief klassendiagrammen en voorbeelden uitgewerkt in code.
Ideaal om voor het examen eens te herhalen.
[Show more]
Preview 5 out of 34 pages
Summarized whole book?
No
Which chapters are summarized?
Besproken design patterns
Uploaded on
June 7, 2018
Number of pages
34
Written in
2017/2018
Type
Summary
object
oriented
design
ontwerp
ontwerpen
oo ontwerpen
ontwerpen iii
pattern
patterns
dcd
klassendiagram
uml
oo
3
Book Title: Head first Design Patterns
Author(s): Eric Freeman, Elisabeth Robson
Edition: november 2004
ISBN: 9780596007126
Edition: 1
Summary
Samenvatting design patterns
All for this textbook (1)
Institution
Hogeschool Gent (HoGent)
Education
Toegepaste informatica
Course
OO Ontwerpen III
All documents for this subject (2)
By: chelseacarton • 3 year ago
$3.25
Added
Add to cart
Add to wishlist
100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached
OO ONTWERPEN III
Academiejaar 2017 - 2018
Jakob Lierman
HoGent
,Jakob Lierman OO Ontwerpen III
Inhoud
INLEIDING .................................................................................................................................................. 4
CREATIONAL PATTERNS .............................................................................................................................................. 4
BEHAVIOR PATTERNS ................................................................................................................................................. 4
STRUCTURAL PATTERNS .............................................................................................................................................. 4
FACTORY PATTERN ..................................................................................................................................... 5
FACTORY METHOD .................................................................................................................................................... 5
UML Diagram ................................................................................................................................................... 5
Ontwerpprincipe .............................................................................................................................................. 5
Code ................................................................................................................................................................. 5
ABSTRACT FACTORY ................................................................................................................................................... 6
UML Diagram ................................................................................................................................................... 7
BUILDER PATTERN ...................................................................................................................................... 8
UML DIAGRAM ........................................................................................................................................................ 8
CODE ...................................................................................................................................................................... 8
VOORDELEN ........................................................................................................................................................... 10
GEBRUIK EN NADELEN .............................................................................................................................................. 10
FLUENT VARIANT ..................................................................................................................................................... 10
SINGLETON PATTERN................................................................................................................................ 12
UML DIAGRAM ...................................................................................................................................................... 12
CODE .................................................................................................................................................................... 12
MULTITHREADING OPLOSSINGEN................................................................................................................................ 12
Zonder lazy loading ........................................................................................................................................ 12
Met lazy loading............................................................................................................................................. 13
TEMPLATE METHOD ................................................................................................................................. 14
UML DIAGRAM ...................................................................................................................................................... 14
CODE .................................................................................................................................................................... 14
COMMAND PATTERN ............................................................................................................................... 17
UML DIAGRAM ...................................................................................................................................................... 17
CODE .................................................................................................................................................................... 17
MACRO-COMMAND................................................................................................................................................. 19
UML Diagram ................................................................................................................................................. 19
Code ............................................................................................................................................................... 19
ITERATOR ................................................................................................................................................. 21
UML DIAGRAM ...................................................................................................................................................... 21
CODE .................................................................................................................................................................... 21
COMPOSITE PATTERN ............................................................................................................................... 23
UML DIAGRAM ...................................................................................................................................................... 23
CODE .................................................................................................................................................................... 23
NULL ITERATOR ....................................................................................................................................................... 25
COMPOSITE ITERATOR .............................................................................................................................................. 25
ADAPTER PATTERN ................................................................................................................................... 27
UML DIAGRAM ...................................................................................................................................................... 27
CODE .................................................................................................................................................................... 27
2
,Jakob Lierman OO Ontwerpen III
PROXY PATTERN....................................................................................................................................... 29
UML DIAGRAM ...................................................................................................................................................... 29
CODE .................................................................................................................................................................... 29
REMOTE PROXY (RMI)............................................................................................................................................. 30
VIRTUAL PROXY ...................................................................................................................................................... 31
DYNAMIC PROXY ..................................................................................................................................................... 32
3
,Jakob Lierman OO Ontwerpen III
Inleiding
Creational Patterns
- Factory method
- Abstract factory
- Builder
- Singleton
Behavior Patterns
- Template method
- Command
- Iterator
Structural Patterns
- Composite
- Adaptor
- Proxy
4
, Jakob Lierman OO Ontwerpen III
Factory Pattern
Voorbeeld: pizzeria.
Factory Method
Het factory method pattern definieert een interface voor het creëren van een object, maar laat de
subklassen beslissen welke klasse er geïnstantieerd wordt. De factory method draagt de instantie
over aan de subklassen.
UML Diagram
Ontwerpprincipe
Dependency inversion principe:
- Wees afhankelijk van abstracties
- Wees niet afhankelijk van concrete klassen
Het principe suggereert dat onze high-level componenten niet afhankelijk mogen zijn van onze low-
level componenten. Beiden zouden moeten afhangen van abstracties.
Code
public interface PizzaIngredientFactory {
public Dough createDough();
public Sauce createSauce();
public Cheese createCheese();
}
public class BinfPizzaIngredientFactory implements PizzaIngredientFactory {
public Dough createDough() {
return new ThinCrustDough();
}
public Sauce createSauce() {
return new MarinaraSauce();
}
public Cheese createCheese() {
return new ReggianoCheese();
}
}
public abstract class Pizza {
private Dough dough;
5