Wzorce projektowe at JInkubator
-
Upload
krzysztof-jelski -
Category
Software
-
view
79 -
download
3
Transcript of Wzorce projektowe at JInkubator
![Page 1: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/1.jpg)
![Page 2: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/2.jpg)
developer,
agile coach
@Pragmatists
właściciel
agile-elearning.pl
Krzysztof Jelski
[email protected] @krzysztofjelski
![Page 3: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/3.jpg)
• przykład
• historia
• przegląd
• jdk
• zasoby
Wzorce projektowe
![Page 4: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/4.jpg)
Feature: Basic sales
Scenario: Standard order includes shipping cost
Given client wants to buy items:
| price | type |
| 100 | cd |
| 100 | book |
When client views the order summary
Then total of the order is 215
Scenario: Order of books only has lower shipping cost
Given client wants to buy items:
| price | type |
| 50 | book |
| 50 | book |
When client views the order summary
Then total of the order is 105
![Page 5: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/5.jpg)
Scenario: Order of books only worth more than 200 is free
Given client wants to buy items:
| price | type |
| 100 | book |
| 105 | book |
When client views the order summary
Then total of the order is 205
Scenario: International shipping of light items
Given client wants to buy items:
| price | weight |
| 100 | 1 |
And wants them delivered to 'Germany'
When client views the order summary
Then total of the order is 150
Scenario: International shipping of heavy items
Given client wants to buy items:
| price | weight |
| 100 | 15 |
And wants them delivered to 'Germany'
When client views the order summary
Then total of the order is 170
![Page 6: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/6.jpg)
KOD
![Page 7: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/7.jpg)
![Page 8: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/8.jpg)
2 najlepsze zasady
projektowania obiektowego
1. Preferuj kompozycję nad dziedziczenie
2. Znajdź to co się zmienia i hermetyzuj to
![Page 9: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/9.jpg)
Algorytm wyliczania całkowitego
kosztu zamówienia
● Oblicz koszt pozycji
● Oblicz koszt wysyłki
● Zsumuj
![Page 10: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/10.jpg)
Standard Promocja na
książki Zagranica
Koszt
wysyłki stała stawka
za darmo jeśli
> 200,
5 jeśli nie
stawka
międzynarodowa,
wyższa gdy
zamówienie jest
ciężkie
![Page 11: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/11.jpg)
SalesOrder
+getTotal()
LineItems
![Page 12: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/12.jpg)
SalesOrder
+getTotal()
StandardSalesOrder
+getTotal()
BooksSalesOrder
+getTotal()
InternationalSalesOrder
+getTotal()
![Page 13: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/13.jpg)
SalesOrder
+getTotal()
#shippingCost()
StandardSalesOrder
#shippingCost()
BooksSalesOrder
#shippingCost()
InternationalSalesOrder
#shippingCost()
![Page 14: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/14.jpg)
SalesOrder
+getTotal()
StandardShippingCost
#shippingCost()
BooksShippingCost
#shippingCost()
InternationalShippingCost
#shippingCost()
ShippingCost
+shippingCost(salesOrder)
![Page 15: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/15.jpg)
SalesOrder
+getTotal()
StandardShippingCost
#shippingCost()
BooksShippingCost
#shippingCost()
InternationalShippingCost
#shippingCost()
ShippingCost
+shippingCost(salesOrder)
![Page 16: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/16.jpg)
Strategy
algorithmInterface()
ConcreteStrategyB
algorithmInterface()
ConcreteStrategyA
algorithmInterface()
strategy Context
contextInterface()
![Page 17: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/17.jpg)
Behawioralne
Strukturalne
Konstrukcyjne
![Page 18: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/18.jpg)
• definiuje rodzinę wymiennych
algorytmów
• hermetyzuje je w postaci klas
• umożliwia wymianę algorytmów
niezależnie od klienta kontekstu
![Page 19: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/19.jpg)
• Możliwość zmiany zachowania
Kontekstu przez zmianę Strategii
• Mniej if-ów
• Klient musi znać różnice między
strategiami by wybrać właściwą
![Page 20: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/20.jpg)
![Page 21: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/21.jpg)
![Page 22: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/22.jpg)
"Each pattern is a three-part rule, which
expresses a relation between a certain
context, a problem, and a solution."
-Christopher Alexander
![Page 23: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/23.jpg)
![Page 24: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/24.jpg)
23
![Page 25: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/25.jpg)
• nazwa
• problem
• rozwiązanie
• konsekwencje
![Page 26: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/26.jpg)
• nazwa
• intencja
• motywacja
• stosowalność
• struktura
• uczestnicy
• współpraca
• konsekwencje
• implementacja
• kod
• zastosowania
• powiązane
wzorce
![Page 27: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/27.jpg)
Silne Luźne
![Page 28: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/28.jpg)
Niska Wysoka
![Page 29: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/29.jpg)
SalesOrder
+getTotal()
StandardShippingCost
#shippingCost()
BooksShippingCost
#shippingCost()
InternationalShippingCost
#shippingCost()
ShippingCost
+shippingCost(salesOrder)
![Page 30: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/30.jpg)
![Page 31: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/31.jpg)
![Page 32: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/32.jpg)
![Page 33: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/33.jpg)
![Page 34: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/34.jpg)
![Page 35: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/35.jpg)
• rozwiązania powracających
problemów
• nazwy ułatwiają komunikację
• luźne powiązania, wysoka spójność
![Page 36: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/36.jpg)
![Page 37: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/37.jpg)
![Page 38: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/38.jpg)
![Page 40: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/40.jpg)
![Page 41: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/41.jpg)
![Page 42: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/42.jpg)
![Page 43: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/43.jpg)
![Page 44: Wzorce projektowe at JInkubator](https://reader030.fdocuments.net/reader030/viewer/2022020123/55a6cdd61a28abe07a8b4625/html5/thumbnails/44.jpg)