Samenvatting
Beknopte samenvatting OO Ontwerpen III
221 keer bekeken
13 keer verkocht
Instelling
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.
[Meer zien]
Voorbeeld 5 van de 34 pagina's
Heel boek samengevat?
Nee
Wat is er van het boek samengevat?
Besproken design patterns
Geupload op
7 juni 2018
Aantal pagina's
34
Geschreven in
2017/2018
Type
Samenvatting
object
oriented
design
ontwerp
ontwerpen
oo ontwerpen
ontwerpen iii
pattern
patterns
dcd
klassendiagram
uml
oo
3
Titel boek: Head first Design Patterns
Auteur(s): Eric Freeman, Elisabeth Robson
Uitgave: november 2004
ISBN: 9780596007126
Druk: 1
Samenvatting
Samenvatting design patterns
Alles voor dit studieboek
(2)
Instelling
Hogeschool Gent (HoGent)
Studie
Toegepaste informatica
Vak
OO Ontwerpen III
Alle documenten voor dit vak (2)
Door: chelseacarton • 3 jaar geleden
€2,99
Toegevoegd
In winkelwagen
Op verlanglijstje
100% tevredenheidsgarantie
Direct beschikbaar na betaling
Zowel online als in PDF
Je zit nergens aan vast
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