Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Engineering and Architecture

Similar presentations


Presentation on theme: "Software Engineering and Architecture"— Presentation transcript:

1 Software Engineering and Architecture
Deriving Abstract Factory The dependency injection pattern

2 Demo: code-demo/PayStationWithGUI
Prelude The Receipt class revisited Add responsibility to print itself Provided by method Result: Demo: code-demo/PayStationWithGUI

3 BetaTown Change is the only constant in software dev.
Req: Receipts with bar code for easy scanning

4 A ”new BarCodeReceiptImpl(tb)” in BetaTown
Code View Something must be done at: A ”new BarCodeReceiptImpl(tb)” in BetaTown

5 Yet another Variability
New variability point! Resulting configurations:

6 The Compositional Design

7 3-1-2 Cranking the 3-1-2 blindly
3) Identify what varies: instantiation of receipts 1) Interface express responsibility: ReceiptIssuer 2) Compose behavior: delegate to ReceiptIssuer

8 Trying it out Quickly add a test:
Low cohesion: object creation in two different objects – why not make one cohesive object???

9 More Cohesive Design One place to “create delegates”: the factory

10 Usage Only one delegate!

11 Why TestTownFactory()?
Because I use a One2OneRateStrategy()

12 Why? Cohesion – do the same thing in the same place!
To Configure BetaTown The factory for BetaTown Important benefit: all configuration is contained in one java source file! Why? Cohesion – do the same thing in the same place!

13 Henrik Bærbak Christensen
SideBar Huh? No ‘barcode’ receipt subclass? No composition? Only two variants envisioned! Parametric variability much simpler = the right variability management choice! Henrik Bærbak Christensen

14 TestTownFactory

15 The Compositional Process

16 The Process Again Again

17 Or… Who is this Martin guy?

18 Abstract Factory

19 Deriving it… 3-1-2 has derived yet another design pattern
An object (factory) whose responsibility it is to create objects (products) that the client need.

20 Deriving it…

21 Mandatory Note Abstract Factory is complex Morale Lots of relations
Easy to get confused or miss the whole idea Easy to misimplement a little with BIG consequences Morale Do not underestimate it in the Mandatory…


Download ppt "Software Engineering and Architecture"

Similar presentations


Ads by Google