software designchate/2110634/02-sw-design.pdf · software architecture software design 17 . 18...
TRANSCRIPT
Software Design
Software Design
• A software design is a precise description of a system, using variety of different perspective.
Software design are complicated, therefore, they must be modeled.
Software Design 2
Modeling as a design technique
• Similar to an architects blueprint
• A model is an abstraction of the underlying problem
• Designs are too complicated to develop from scratch
• Good designs tend to be build using models… – Abstract different views of the system
– Build models using precise notations (e.g., UML)
– Verify that the models satisfy the requirements
– Gradually add details to transform the models into the design
Software Design 3
Modeling as a design technique
Software Design 4
Modeling as a design technique - improved
Software Design 5
UML – a modeling notation
Software Design 6
Software Architecture
• According to Shaw and Garlan [1]
– The Software Architecture of a system consists of a description of the system elements, interactions between the system elements, patterns that guide the system elements, and constraints on the relationships between system elements.
• Its a more abstract view of the design
• Its helpful for communication and complexity management
Software Design 7
Software Architecture
• The software architecture of a program or computing system is a depiction of the system that aids in the understanding of how the system will behave.
• serves as the blueprint for both the system and the project developing it,
• defining the work assignments that must be carried out • primary carrier of system qualities such as
– performance, modifiability, and security, none of which can be achieved without a unifying architectural vision.
• Architecture is an artifact for early analysis to make sure that a design approach will yield an acceptable system.
Software Design 8
http://www.sei.cmu.edu/architecture/
The Software Architecture “Stack”
Software Design 9
The Software Architecture “Stack”
Software Design 10
Design Methodologies
Software Design 11
Jumpstart Design
Software Design 12
templates, patterns, frameworks, … from scratch is difficult
Spring Framework
Software Design 13
Software Design 14
Improving Existing Designs
• Refactoring
– technique for restructuring an existing body of code, altering its internal structure without changing its external behavior
Software Design 15
Design Patterns & Anti Patterns
• a formal way of documenting a solution to a design problem
• Anti patterns – negative solutions
Software Design 16
SOFTWARE ARCHITECTURE
17 Software Design
18
Software Decomposition
Software Decomposition
– Subsystem
– Partition
• Software Design Quality
– Coupling
– Cohesion
Software Design
19
What is Subsystem
• Collection of software elements such as software modules and their relations
• The subsystem boundary is defined explicitly
• The dependency relations among subsystems are defined
• Using “Partition” and “Layer” techniques to minimize the dependency relations
Software Design
20
Sample of Subsystem Decomposition
Modeling
Authoring
Workorder Repair
Inspection
Augmented
Reality
Workflow
Software Design
21
Partitions and Layers
• Partitioning and layering are techniques to achieve low coupling
• A large system is usually decomposed into subsystems using both, layers and partitions
• Partitions vertically divide a system into several independent (or weakly-coupled) subsystems that provide services on the same level of abstraction
• A layer is a subsystem that provides subsystem services to a higher layers (level of abstraction) – A layer can only depend on lower layers – A layer has no knowledge of higher layers
Software Design
22
F:SubsystemE:Subsystem G:Subsystem
D:SubsystemC:SubsystemB:Subsystem
A: Subsystem Layer 1
Layer 2
Layer 3
Subsystem Decomposition into Layers
• Subsystem Decomposition Heuristics: – No more than 7+/-2 subsystems – More subsystems increase cohesion but also
complexity (more services) – No more than 4+/-2 layers, use 3 layers (good)
Software Design
Closed Architecture (Opaque Layering)
• Any layer can only invoke operations from the immediate layer below
• Design goal: High maintainability, flexibility
Software Design 23
Open Architecture (Transparent Layering)
• Any layer can invoke operations from any layers below
• Design goal: Runtime efficiency
Software Design 24
Coupling and Cohesion
• Goal: Reduction of complexity while change occurs
• Cohesion measures the dependence among modules –High cohesion: The modules in the subsystem
perform similar tasks and are related to each other (via associations)
–Low cohesion: Lots of miscellaneous and auxiliary modules, no associations
Software Design 25
Coupling and Cohesion
• Coupling measures dependencies between subsystems – High coupling: Changes to one subsystem will have high
impact on the other subsystem (change of model, massive recompilation, etc.)
– Low coupling: A change in one subsystem does not affect any other subsystem
• Subsystems should have as maximum cohesion and minimum coupling as possible: – How can we achieve high cohesion?
– How can we achieve loose coupling?
Software Design 26
Sample of Cohesion
Software Design 27
Subsystem A
Subsystem B
M1
M4
M2
M5
M3 M1
M4
M2
M5
M3
High Cohesion Low Cohesion
28
Sample of Coupling
Subsystem A
M1 M2
Subsystem B
M3 M4
Subsystem A
M1 M2
Subsystem B
M3 M4
High Coupling Low Coupling Software Design
Software Architecture Design
• Software Architectural Styles
– Client/Server
– Peer-to-Peer
– Repository
– Model/View/Control
– Pipe and Filter
Software Design 29
Software Architectural Styles
• Subsystem decomposition – Identification of subsystems, services, and their
relationship to each other.
• Specification of the system decomposition is critical.
• Patterns for software architecture – Client/Server
– Peer-To-Peer
– Repository
– Model/View/Controller
– Pipes and Filters
Software Design 30
Client/Server Architectural Style
• One or many servers provides services to instances of subsystems, called clients.
• Client calls on the server, which performs some service and returns the result – Client knows the interface of the server (its service)
– Server does not need to know the interface of the client
• Response in general immediately
• Users interact only with the client
Software Design 31
Client
Server
service1()service2()
serviceN()…
**requester provider
Client/Server Architectural Style
• Often used in database systems: – Front-end: User application (client) – Back end: Database access and manipulation (server)
• Functions performed by client: – Customized user interface – Front-end processing of data – Initiation of server remote procedure calls – Access to database server across the network
• Functions performed by the database server: – Centralized data management – Data integrity and database consistency – Database security – Concurrent operations (multiple user access) – Centralized processing (for example archiving)
Software Design 32
Design Goals for Client/Server Systems
• Service Portability – Server can be installed on a variety of machines and operating systems
and functions in a variety of networking environments • Transparency, Location-Transparency
– The server might itself be distributed (why?), but should provide a single "logical" service to the user
• Performance – Client should be customized for interactive display-intensive tasks – Server should provide CPU-intensive operations
• Scalability – Server should have spare capacity to handle larger number of clients
• Flexibility – The system should be usable for a variety of user interfaces and end
devices (eg. WAP Handy, wearable computer, desktop) • Reliability
– System should survive node or communication link problems
Software Design 33
Problems with Client/Server Architectural Styles
• Layered systems do not provide peer-to-peer communication
• Peer-to-peer communication is often needed
• Example: Database receives queries from application but also sends notifications to application when data have changed
Software Design 34
Peer-to-Peer Architectural Style
• Generalization of Client/Server Architecture
• Clients can be servers and servers can be clients
• More difficult because of possibility of deadlocks
Software Design 35
Peer
service1()service2()
serviceN()…
requester
provider
*
*
Model/View/Controller
• Subsystems are classified into 3 different types – Model subsystem: Responsible for application domain knowledge – View subsystem: Responsible for displaying application domain
objects to the user – Controller subsystem: Responsible for sequence of interactions with
the user and notifying views of changes in the model.
• MVC is a special case of a repository architecture: – Model subsystem implements the central datastructure, the Controller
subsystem explicitly dictate the control flow
Software Design 36
Repository Architectural Style (Blackboard Architecture)
• Subsystems access and modify data from a single data structure
• Subsystems are loosely coupled (interact only through the repository)
• Control flow is dictated by central repository (triggers) or by the subsystems (locks, synchronization primitives)
Software Design 37
Subsystem
Repository
createData() setData() getData() searchData()
Pipe and Filter
• Subsystems process data received from a set of inputs and send results to other subsystems via a set of outputs
• The subsystems are called “Filters”
• The associations between the subsystems are called “Pipes”
Software Design 38
Sub1 Sub4
Sub3
Sub2 Sub5 Filter
Pipe
Sample of Subsystem Decomposition
Software Design 39
<<Subsystem>>
Purchase Order
<<Subsystem>>
Inventory
Verification
<<Subsystem>>
Invoice
<<Subsystem>>
Goods Receive
<<Subsystem>>
Budgeting
<<Subsystem>>
Payment
<<Subsystem>>
Vendor
Maintenance
Decomposing a set of Subsystems
40
Sample of Subsystem Decomposition
<<Subsystem>>
Purchase Order
<<Subsystem>>
Inventory
Verification
<<Subsystem>>
Invoice
<<Subsystem>>
Goods Receive
<<Subsystem>>
Budgeting
<<Subsystem>>
Payment
<<Subsystem>>
Vendor
Maintenance
Define the dependency among subsystems
Software Design
41
Sample of Subsystem with Interfaces
<<Subsystem>>
Purchase Order
<<Subsystem>>
Inventory
Verification
<<Subsystem>>
Invoice
<<Subsystem>>
Goods Receive
<<Subsystem>>
Budgeting <<Subsystem>>
Payment
<<Subsystem>>
Vendor
Maintenance
Decomposing a set of Subsystems
IPO2 IPO1
IIV1
IP1
IGR1
Software Design
42
Sample of Hierarchy of Subsystems
<<Subsystem>>
Purchase
Order <<Subsystem>>
Inventory
Verification
<<Subsystem>>
Goods Receive
<<Subsystem>>
Budgeting
<<Subsystem>>
Payment
<<Subsystem>>
Vendor
Maintenance
<<Subsystem>>
<<Subsystem>>
Inventory
Purchasing
IIV1
IGR1 IP1
IPO2 IPO1
IX1
Finance
<<Subsystem>>
Bank System
<<Subsystem>>
Invoice
Software Design
43
Sample of Hierarchy of Subsystems (with Information Hiding)
<<Subsystem>>
<<Subsystem>>
Inventory
Purchasing
IIV1
IGR1 IP1
IPO2 IPO1
IX1
Finance
<<Subsystem>>
Bank System Software Design
44
Typical Sale Component
<<Subsystem>>
Purchase
Order
<<Subsystem>>
Invoice
<<Subsystem>>
Vendor
Maintenance
<<Component>> Purchasing
IPO2 IPO1
1 Subsystem = 1 Component
<<Subsystem>>
Purchase
Order
<<Subsystem>>
Vendor
Maintenance
<<Subsystem>>
Purchasing
IPO2 IPO1
<<Subsystem>>
Invoice
Software Design
45
Typical Sale Component (with Information Hiding)
<<Component>>
Purchasing
IPO2
IPO1 1 Subsystem = 1 Component
<<Subsystem>>
Purchase
Order
<<Subsystem>>
Vendor
Maintenance
<<Subsystem>>
Purchasing
IPO2 IPO1
<<Subsystem>>
Invoice
Software Design
46
Typical Finance Component (with Information Hiding)
<<Subsystem>>
Budgeting
<<Subsystem>>
Payment
IP1
Finance
<<Subsystem>>
<<Component>>
Finance
IP1 1 Subsystem = 1 Component
Software Design
Typical Inventory Component (with Information Hiding)
Software Design 47
<<Component>>
Inventory
IX1 1 Subsystem = 1 Component <<Subsystem>>
Inventory
Verification
<<Subsystem>>
Goods Receive
<<Subsystem>>
Inventory
IIV1
IGR1
IX1
IIV1
IGR1
Sample of Hierarchy of Subsystems (with Information Hiding)
Software Design 48
<<Subsystem>>
<<Subsystem>>
Inventory
Purchasing
IIV1
IGR1 IP1
IPO2 IPO1
IX1
Finance
<<Subsystem>>
Bank System
Define a Component Diagram
Software Design 49
<<Component>>
Purchasing
IPO2
IPO1
<<Component>>
Finance
IP1
<<Component>>
Inventory
IX1
IIV1
IGR1
Deployment of Client-Server
Software Design 50
Application Server Client
<<Component>>
Sale
IPO2 IPO1
<<Component>>
Finance
IP1
<<Component>>
Inventory
IX1 IIV1
IGR1
Deployment of Web Application
Software Design 51
Client
<<Component>>
Web Server
Application Server
<<Component>>
Sale
IPO2 IPO1
<<Component>>
Finance
IP1
<<Component>>
Inventory
IX1 IIV1
IGR1
Tracing from Use Cases to Design
Software Design 52
Finance
Bank System
Check Available Budget
Prepare Payment
Check Credit Line
Officer
Tracing from Use Cases to Design
Software Design 53
<<Subsystem>>
Budgeting
<<Subsystem>>
Payment
IP1
Finance
<<Subsystem>>
Bank System
Check Available Budget
Prepare Payment
Check Credit Line
Officer
<<Realize>>
<<Realize>>
<<Realize>>
Reference
[1] http://www.cs.cmu.edu/afs/cs/project/vit/ftp/pdf/intro_softarch.pdf
Software Design 54