+ All Categories
Home > Documents > Subsystems

Subsystems

Date post: 06-Jan-2016
Category:
Upload: miriam
View: 44 times
Download: 0 times
Share this document with a friend
Description:
Subsystems. CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, 1990. (Chapter 7). 1. 1. Outline. Subsystems: what and why? Subsystem documentation Subsystems cards Collaboration graphs Guidelines for defining subsystems. 2. 2. - PowerPoint PPT Presentation
Popular Tags:
35
1 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, 1990. (Chapter 7)
Transcript
Page 1: Subsystems

111

Subsystems

CS 4311

Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, 1990. (Chapter 7)

Page 2: Subsystems

222

Outline

Subsystems: what and why? Subsystem documentation

Subsystems cards Collaboration graphs

Guidelines for defining subsystems

Page 3: Subsystems

333

Steps for Producing Initial Designs

Identify Classes Responsibilities Collaborations

Analyze Class hierarchies Contracts Collaboration graphs

Page 4: Subsystems

4

Motivation: Collaboration Graph

Account1 2

Balance Deposit Withdrawal TransferTransaction 8

Display Device

Input Device

BCR

Output Device

3

5

7

ATM

Form

Menu

UserMessage

User Interaction

4

6

9

Page 5: Subsystems

5

Problem

Collaboration graphs get very complicated. Too many lines (i.e., interactions or communications)

Designs become incomprehensible. How to simply the design, esp. patterns of

communications?

Page 6: Subsystems

6

Solution

Need an abstraction tool to provide macro views Collect classes together to form subsystems that

Behave like a class. Support services to outside via contracts.

Page 7: Subsystems

7

What Are Subsystems?

Groups of classes that collaborate among themselves to support a set of contracts

Goal: To simplify patterns of communications

Page 8: Subsystems

8

What Are Subsystems? (Cont.)

Subsystems are not super classes. Subsystems are not “just a bunch of classes.” Subsystems should provide a good abstraction. Subsystems should provide a clearly defined

interface, called subsystem contracts.

Page 9: Subsystems

9

Subsystem Contracts

All contracts supported by things inside a

subsystem for things outside the

subsystem.

Delegation of contracts

Printing Subsystem

Print Server

Printer

LaserPrinter

InkJetPrinter

1

1

2

Page 10: Subsystems

10

Subsystem Cards for Documenting Subsystems Write the subsystem name at the top List all classes in the subsystem Include ref. to the subsystem’s position in the

collaborations graphs Describe the purpose of the subsystem List contracts for which it is a server For each contract, identify the class or

subsystem to which the contract is delegated

Page 11: Subsystems

11

Subsystem Cards (Cont.)

Subsystem: Drawing Subsystem

Classes: Control Point, Drawing, Drawing Element, …

Collaborations Graphs: see Figure 4-6

Description: Responsible for displaying and maintaining

the contents of the drawing…

Contracts

1. Display itself

Server: Drawing

2. Access and modify the contents of a drawing

Server: Drawing

3. Modify the attributes of a Drawing Element

Server: Control Point

Page 12: Subsystems

12

How to Identify Subsystems?

Bottom-up and top-down approaches Bottom up

Start with classes and responsibilities Identify collaborations Partition the classes based on patterns of

collaborations

This approach is useful when managing the complexity as a system grows.

Page 13: Subsystems

13

Subsystem Identification

Draw collaboration graph (use white board). Look for strongly coupled classes. Look for ways to simplify your description of the

system. Look for clean separations. Look for good abstractions.

Page 14: Subsystems

14

How to Identify Subsystems?

Top down Look at high level functions of system Look at data sources and uses Look at supporting technologies Partition to manage complexity and reduce

coupling

This approach may be useful when managing the complexity imposed by initial specification.

Page 15: Subsystems

15

Guidelines for Simplifying Interactions Minimize number of collaborations a class has

with other classes or subsystems. Minimize number of classes and subsystems to

which a subsystem delegates. Minimize number of contracts supported by a

class or subsystem.

Page 16: Subsystems

16

G-1: Minimize Number of Collaborations Class should collaborate with as few other

classes and subsystems as possible. (Why?) Heuristic: Centralize communications

Page 17: Subsystems

17

Example

Printing Subsystem

PrintServer

Printer

LaserPrinter

ColorPrinter

1

1

2

3

File

3

Printing Subsystem

PrintServer

Printer

LaserPrinter

ColorPrinter

1

1

2

File

3

Page 18: Subsystems

18

G-2: Minimize Delegations of Subsystem Contracts Keep the number of classes inside the

subsystem that support subsystem contracts to a minimum

Again, centralize communications into and out of the subsystem

Page 19: Subsystems

19

G-3: Minimize Number of Contracts Too many contracts in one place indicate too

much intelligence concentrated in one place: split the functionality between two or more classes.

Re-examine the collaboration patterns

Page 20: Subsystems

20

Example

CashRegister

Warehouse

InventoryItem

TransactionLog

AccountingSubsystem

21 3

Page 21: Subsystems

21

Example

CashRegister

Warehouse

InventoryItem

TransactionLog

AccountingSubsystem

21 3

Page 22: Subsystems

22

Example Refined

CashRegister

Warehouse

InventoryItem

TransactionLog

AccountingSubsystem

21 3

1 2 3InventorySubsystem

Page 23: Subsystems

23

InventoryManager

Example Refined Again

CashRegister

Warehouse

InventoryItem

TransactionLog

AccountingSubsystem

21 3

5

5

InventorySubsystem

4 6

4 6

Page 24: Subsystems

24

InventoryManager

Example Refined Further

CashRegister

Warehouse

InventoryItem

TransactionLog

AccountingSubsystem

21 3

4

4

InventorySubsystem

Page 25: Subsystems

25

If You Have to Redesign ...

Redraw the graphs Re-examine the collaboration patterns Walk through scenarios (all of them) Verify that things are simpler, have improved

cohesion and reduced coupling

Page 26: Subsystems

26

ATM Example: Contracts

1. Account: access and modify balance2. Account: commit result to database3. Display: display information4. Form: get numeric value from user5. Input Device: accept user input6. Menu: get user selection7. Output Device: output to the user8. Transaction: execute financial transaction9. User Message: display message and wait

Page 27: Subsystems

27

Collaboration Graph

Account1 2

Balance Deposit Withdrawal TransferTransaction 8

Display Device

Input Device

BCR

Output Device

3

5

7

ATM

Form

Menu

UserMessage

User Interaction

4

6

9

Page 28: Subsystems

28

Refining

Account1 2

Balance Deposit Withdrawal TransferTransaction 8

Display Device

Input Device

BCR

Output Device

3

5

7

ATM

Form

Menu

UserMessage

User Interaction

4

6

9

Page 29: Subsystems

29

9

6

Simplified Graph 1FinancialSubsystem

8

Display Device

Input Device

BCR

Output Device

3

5

7

ATM

Form

Menu

UserMessage

User Interaction

4

Page 30: Subsystems

30

9

6

RefiningFinancialSubsystem

8

Display Device

Input Device

BCR

Output Device

3

5

7

ATM

Form

Menu

UserMessage

User Interaction

4

Page 31: Subsystems

31

9

6

Simplified Graph 2Financial

Subsystem8

3

5

7

ATM

4

I/OSubsystem

UserInteractionSubsystem

Page 32: Subsystems

32

ATM

Even More Simplified Graph

FinancialSubsystem

User InterfaceSubsystem

8

3 5 64 7 9

Page 33: Subsystems

33

ATM

Even More Simplified Graph

FinancialSubsystem

User InterfaceSubsystem

8

3 5 64 7 9

Any critique?

Page 34: Subsystems

34

Rework

Rework your design. If it isn’t changing, you’re not working.

Do not change just to change, but change based on recognition of better design.

Take pride in your work.

Page 35: Subsystems

3535

Group Work and Assignment

Group work (see handout) Subsystems for the project

Due: Mar. ?, 2015 Leader: Architect Contents

Class diagram showing all classes and their relationships (inheritance and associations)

Contracts by refining your CRC cards Subsystems by grouping classes and identifying subsystem

contracts (subsystem cards) Collaboration graphs


Recommended