How to Document the Architecture of Your Application Using UML and More
I created this diagram 14 years ago The design may be OK But the design description is bad and by the end of this talk Ill have told you why!
2010 Carnegie Mellon University
How many of you work in industry with software development? How many are familiar with basic UML?
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
Requirements
???
Implementation
Requirements
Architecture
Implementation
The software architecture of a computing system is the set of structures needed to reason about the system, which comprise software elements, relations among them, and properties of both.1
P. Clements et al, Documenting Software Architectures: Views and Beyond, 2nd Edition. Addison-Wesley, 2010.
Create an architecture
o
Refine, update and refactor the architecture along the way Use the architecture to guide implementation (Try to) enforce the architecture during implementation and throughout maintenance
Architecture documentation is a key artifact in all these activities
10
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
11
Views (1)
Code units, their decomposition and dependencies Processes and how they interact How software is deployed on hardware Many others
Views are also known as viewpoints or perspectives
12
Views (2)
P. Clements et al, Documenting Software Architectures: Views and Beyond, 2nd Edition. Addison-Wesley, 2010.
13
TOGAF:
Business architecture views Data architecture views Application architecture views Technology architecture views
RM-ODP:
Enterprise viewpoint Information viewpoint Computational viewpoint Engineering viewpoint Technology viewpoint
Philips CAFCR
Customer view Application view Functional view Conceptual view Realization view
14
Choose what views to create (and what views do spend more time on) based on:
The structures inherent to that software system The stakeholders of the documentation and what do they use it for
15
16
Module Views
2. How is it structured as a set of elements that have runtime presence?
Runtime Views
3. How are artifacts organized in the file system and how is the system deployed to
Data Model
17
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
18
Module Views
Show structure of the system in terms of units of implementation Elements: modules, i.e. implementation units Relations:
A is part of B: part-whole relation among modules A depends on B: dependency relation among modules A is a B: specialization/generalization relation among modules, or interface realization
19
Is part of
Package contains subpackages or classes
Depends on
Dependency can be <<use>>, <<refine>>, <<instantiate>>, etc.
Is a
Generalization and interface realization
UML has other standard relations, and you can specialize any of them with stereotypes
20
10
Disclaimer about examples: no need to understand the design are real hence not perfect not the latest version diagram cant tell everything
21
22
11
23
24
12
Constructionthey are the blueprints for the code Budgeting, work assignment, tracking Modifiability and impact analysis Education of new developers
25
26
13
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
27
Runtime Views
Also known as Component and Connector (C&C) views Show structure of the system when its executing Elements:
The runtime view is clearly the most suitable for showing SOA architectures
Components that have runtime presence (e.g., processes, threads, EJBs, Servlets, ASP.NET components, service agents) Data stores Complex connectors (e.g., queues, pipes)
Relations:
28
14
Informal notation
30
15
Required interface
Delegation connector
Port
Assembly connector
31
32
16
P. Clements et al, Documenting Software Architectures: Views and Beyond, 2nd Edition. Addison-Wesley, 2010.
2008 Carnegie Mellon University
33
How components interact at runtime What components are replicated What components access data stores
34
17
customer_account_xref
Inconsistent naming
next_tx_id
Incorrect interaction
Original diagram of Dukes Bank Application from Sun J2EE 1.3 tutorial (w/ our amendment) http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Ebank2.html
35
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
36
18
Deployment Views
Show the hardware infrastructure of the production environment, along with deployment files and components allocated to them Elements:
Processing and communication nodes (e.g., server machine, router) Deployment artifacts Components
Relations:
Interaction mechanisms between hardware elements are usually communication channels A deployment artifact may contain other artifacts and is deployed to hardware elements Components are allocated to hardware elements and deployment artifacts
2010 Carnegie Mellon University
37
Informal notation
2010 Carnegie Mellon University
38
19
39
40
20
41
Education and stakeholder communication Defining deployment and operation procedures Auditing runtime failures Designing automatic updates feature
42
21
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
43
Data Model
Shows structure of data manipulated in the software system Elements: data entities (persisted domain elements) Relations:
44
22
45
Useful reference for developers of data access code Modifiability impact analysis
46
23
47
48
24
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
49
Behavior Documentation
Diagrams we see in the views are usually structural diagrams Structural diagrams show all potential interactions among elements Behavioral diagrams describe specific patterns of interactionthe systems response to stimuli
Behavioral diagrams complement structural diagrams
50
25
sequence diagram communication diagram activity diagram timing diagram state machine diagram
Non UML
52
26
duration constraint
loop
alternative traces
53
Frames
Reentrant call
54
27
55
56
28
57
58
29
State machine for a car stereo with AM/FM tuner and CD player
59
State machine diagrams simple, powerful and yet misused and underutilized
Boxes in a state diagram are states, not components or modules; arrows are transitions, not connectors or calls The diagram may model states of
part of or the entire system, a component or module, a collection of components of modules, or even an attribute of a component/module
Beware of the state explosion problem
Be clear as to what is the scope of your state machine diagram By definition, a state machine diagram should show
All possible states All possible transitions out of any given state
60
30
61
In what order do modules/components interact? Whats the response time for a given transaction? Whats the startup and shutdown procedure? Whats the life cycle of a given software element? What components execute in parallel? What happens when specific stimulus arrive at the system?
62
31
63
Exercise
Create a state machine diagram for your laptop wireless connection.
connecting
connected
not connected
64
32
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
65
Software interface
An interface is a boundary across which two elements meet and interact or communicate with each other.1
P. Clements et al, Documenting Software Architectures: Views and Beyond, 2nd Edition. Addison-Wesley, 2010.
66
33
To handle different groups of users, When 2+ versions of the same interface are available at the same time
67
Interfaces can be extended through generalization Elements provide interfaces and may require interfaces
68
34
69
70
35
Interfaces in UML
71
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
72
36
73
what pieces of information should be documented whats the best organization for the document
74
37
Is usually graphical Shows elements and relations among them Should include a key that explains the notation
Indicate the meaning of each symbol. Dont forget the lines! Try to use consistent notation across diagrams
75
Explains elements depicted in the primary presentation Its usually just a list of element names and textual descriptions May contain interface specifications May contain behavior documentation
76
38
Shows whats in and whats out of the system (or the part of the system the view is focusing on) Common notation:
77
Substitution of an element with another that has the same interface Optional inclusion (e.g., plug-ins, add-ons) Component replication Parameterization (build-time flags, config files, etc.)
what can vary and the effect of the variation binding time (compile, build, install, start, or run time) how to exercise each variation/configuration
78
39
Rationale for design decisions (including relevant rejected alternatives) Results of analysis, prototypes and experiments Assumptions and constraints affecting this view Known patterns used in the design
6. Related Views
79
80
40
Shows how documentation is organized Has reference to template used Includes scenarios for different stakeholders to use the documentation
2. System Overview
Description of the system and its purpose May point to overview elsewhere in the overall system documentation
81
3.1
3.2
3.3
82
41
Tables showing how elements in one view map to elements in another view
83
Rationale for cross-view design decisions (including rejected alternatives) Results of architecture evaluation (e.g., ATAM report)
Shows how each requirement is satisfied by one or more elements of the architecture, or an architectural approach
84
42
85
Agenda
Introduction Multi-View Architecture
Behavior Documentation Software Interface Documentation Template for an Architecture Document Outroduction
86
43
Code is king!
Code is king!
87
Important takeaways
Describe the architecture in multiple views Documentation should not appeal to readers intuition
Always use a key or indicate the diagram notation Dont forget the lines Use different symbols for different types of elements and relations
Define and use a template for architecture documentation Choose notation based on the reader
88
44
Use view refinement Combine views as appropriate Document variability Create context diagrams Enforce the architecture
89
sei.cmu.edu/architecture
90
45
91
Backup slides
92
46
93
Disclaimer about examples: no need to understand the design are real hence not perfect not the latest version diagram cant tell everything
94
47
95
96
48
Provided interface
Port
Required interface
97
soapatterns.org notation
49
Informal notation
Reconstructed from Dukes Bank ApplicationSun J2EE 1.3 tutorial
2010 Carnegie Mellon University
99
50
Peer-to-peer example
101
Informal notation
102
51
103
104
52
105
Module views showing generalization and usage dependencies Runtime views in general Deployment view focusing on structure of files and folders High-level module view showing layers Deployment view focusing on the hardware infrastructure Rational of design decisions Mapping to requirements Behavior documentation showing important traces (using sequence and activity diagrams for example)
Process view
Development view
Physical view
106
53
107
108
54
109
110
55
111
112
56
113
114
57