• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 19 pages
Summary

Samenvatting ASD2

Document preview thumbnail
Preview 3 out of 19 pages

Met deze samenvatting een 16/20 gescoord. Voorbeelden komen beide uit de les en van andere bronnen. Bevat elk design pattern dat in ASD2 voorkomt.

Content preview

ASD2 Samenvatting
Design Patterns........................................................................................................................... 2
Factory Method (Creational).................................................................................................... 2
Abstract Factory (Creational)...................................................................................................3
Builder (Creational)..................................................................................................................4
Zonder director...................................................................................................................4
Met director........................................................................................................................ 4
Singleton..................................................................................................................................6
Eager loading (Multithreading)...........................................................................................6
Lazy Loading (Multithreading)............................................................................................6
Enum Singleton (Multithread safe).....................................................................................6
Iterator & Composite (Behavioral)........................................................................................... 7
Command (Behavioral)............................................................................................................8
Template Method (Behavioral).................................................................................................9
Adapter (Structural)............................................................................................................... 10
Proxy (Structural)................................................................................................................... 11
Protection proxy............................................................................................................... 11
Remote proxy...................................................................................................................11
Virtual proxy..................................................................................................................... 11
Multithreading............................................................................................................................ 12
Levenscyclus......................................................................................................................... 12
Priorities & Scheduling...........................................................................................................12
ThreadLocalRandom............................................................................................................. 13
Creatie & Executie van threads............................................................................................. 13
.run()................................................................................................................................ 13
Aanmaken........................................................................................................................13
Starten............................................................................................................................. 13
Threadpool Maken........................................................................................................... 13
Thread Synchronisatie...........................................................................................................13
Locks................................................................................................................................13
Producer/consumer relatie (zonder synchronisatie).............................................................. 14
Producer/consumer relatie (met synchronisatie)................................................................... 15
Methodes van klasse Object............................................................................................15
Praktische uitvoering: locks, conditions, await() en signal().............................................15
Set methode.....................................................................................................................16
Get methode.................................................................................................................... 17
Product/consumer relatie: ArrayBlockingQueue....................................................................17
Interface Callable...................................................................................................................18
Stop, suspend & resume threads.......................................................................................... 18

,Design Patterns

Factory Method (Creational)




PizzaStore (abstracte klasse) als Creator.
GhentPizzaStore en BrusselsPizzaStore als Concrete Creator

Beide concrete creators implementeren de abstracte methode createPizza en geven daarbij de
pizza die tot hen behoort. Deze wordt in dit voorbeeld onderling opgeroepen in orderPizza.
Pizza (product) kan hier een abstracte of interface klasse zijn.

Voorbeeld code:
GhentPizzaStore ghentPizzaStore = new GhentPizzaStore();
ghentPizzaStore.orderPizza("pepperoni");

, Abstract Factory (Creational)




De statische methode getFactory zorgt er voor dat we de juiste AbstractFactory terug krijgen.
Eens dat we de juiste factory hebben, kunnen we voort met hun getShape methodes.


Voorbeeld code:
// Aanmaak rounded figuren
AbstractFactory roundedFactory = FactorySupplier.getFactory("rounded");

Shape shape1 = roundedFactory.getShape("RECTANGLE");
shape1.draw();
Shape shape2 = roundedFactory.getShape("SQUARE");
shape2.draw();

// Aanmaak smooth figuren
AbstractFactory smoothFactory = FactorySupplier.getFactory("smooth");
Shape shape3 = smoothFactory.getShape("RECTANGLE");
shape3.draw();
Shape shape4 = smoothFactory.getShape("SQUARE");
shape4.draw();

Document information

Study
Uploaded on
July 26, 2024
Number of pages
19
Written in
2023/2024
Type
Summary
$9.80

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
1
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions