10. Subsystems
31/10/22
Subsystem
- Inital design - classes, responsibilities, collaborations
- Second stage - analyse hierarchies, identify contracts
- New goals: Simplify patterns of communication, identify subsystems, design good interface to subsystems and classes
Collaboration Graphs
Represent the flow of information in system during execution. Collaboration graph includes:
- Classes and their hierarchies
- Contracts
- Collaborations
Subsystems - Groups of classes that collaborate among themselves to support a set of contracts From outside - The classes work closely together to provide a clearly defined unit of functionality From inside - Classes can have some complex interrelationships of collaborations
Superclass vs Subsystem
- Superclass groups a set of classes with identical responsibilities
- Subsystem is a group of classes with different responsibilities that can work together to fulfil a greater responsibilities
Contracts
Subsystems also support contracts.
- Collaboration from a class outside the subsystem to a class inside subsystem is redefined to be a collaboration with subsystem
- The contract used for collaboration becomes a subsystem contract. This delegates contract to the class that supports it
Subsystems from Top
Help simplify a design near the end of design
- Used early in design:
- Identify its major subsystems
- Treat them as classes
- Decompose subsystems into other subsystems
- Used to start out a class:
- Too complex or has too many responsibilities
- Gets subdivided into more classes that combine into subsystem
Subsystems are Conceptual
Only conceptual units
- They don't exist at execution time but their classes do
- Don't directly fulfil responsibilities
Identifying Subsystems
Look for strongly coupled classes Coupling is a measure of how much they depend on each other
Coupling
- Frequently used collaborations
- A web of many collaborations among a set of classes that are connected to reset of the graph with fewer collaborations
Simplifying Interactions
Should help to simplify class interactions
- Complex interactions are hard to maintain, lead to spaghetti code, and are generally to be avoided
- Area of complexity in graph should be focus of effort
- Proposed change should simplify graph