W2-1 Viewsx - Department of Computer Science
Download
Report
Transcript W2-1 Viewsx - Department of Computer Science
Software Architecture
in Practice
Views and Structures
Example: Biology – what is a lion?
• Entry in the taxonomy of animals?
• Behavior, its role in the ecology of the savanna?
• Which is the best/right perspective?
2
Example: Computer Science
• public class Student {
• String name;
• …
• }
3
Comparison
• Actually the biology and CS example are similar
• The static aspects
– The abstract/structural stuff :
Taxonomy/Class
• The dynamic aspects
– The concrete/behavioral stuff:
Ecosystem/Object
4
Views
• “A view represents a partial aspect of a software
architecture that shows specific properties of a
software system.” [Buschmann]
• Example: Consider a bridge
joint 2: Fx = fa( -cos45) + fc (cos90) + fe( cos45) = 0; Fx = - cfa + cfe = 0
joint 2: Fy = -fa(sin45) + - fc(sin90) + - fe(sin45) = 0; Fy = -sfa - fc - sfe = 0
5
What views to consider
• There have been many suggestions
Implementation
view
Design view
Use case view
Process view
Conceptual View
Module View
Execution View
Deployment view
Code View
• Krutchen 4+1,
• Hofmeister et al.
Christensen et al.
6
Elements of an Architectural
Description
• Architectural views (N)
– What is the software architecture?
• Multiple viewpoints, here
– Module viewpoint
– Component & Connector viewpoint
– Allocation viewpoint
• Architectural requirements (+1)
– Why is the software architecture the way it is?
• Scenario-based requirements
– E.g., paths through significant use cases
• Quality-attribute-based requirements
– Primary concerns (e.g., critical quality requirements)
– Quality attribute specifications
• Design decisions
7
Our suggestion
• Inspired by Clements et al. we suggest at least
three central views must be present
– Module viewpoint
• Static stuff – packages and classes
– Component and Connector viewpoint
• Dynamic stuff – processes, objects, excuting stuff
– Allocation viewpoint
• Physical stuff – computers, networks, JVMs,
• As well as architectural significant scenarios and
requirements
• Basically this is a 3+1 model…
8
Literature
• SAiP chapter 18 (cursory)
• Christensen, Corry, Hansen:
– An approach to software architecture
documentation using UML 2.3
9
Example
World of Warcraft
Some wildly ”bad” architectures but it
will illustrate that at least I
can communicate it…
Component & Connector Viewpoint
• Elements
– Components
• Functional behaviour
• What part of the system is doing what?
• Relations
– Connectors
The software architecture of a computing
system is the structures of the system,
which comprise software elements, the
externally visible properties of those
elements, and the relationships among
them [Bass et al., 2003]
• Control and communication aspects
• Define protocols for control and data exchange
– Incoming and outgoing operations
– Mandates ordering of operations
– Define roles for attached components
• Mapping to UML
– Object diagrams, interaction diagrams
– Components = active objects
– Connectors = links + annotations, messages
• + textual description of responsibilities
11
Basic C&C Elements
Active Objects
Sequence Diagrams
component 1:
Type 1
component: Type
role name 2
connector name
create
new component
role name 1
message
component 2
self delegation
delete
•
[Fowler, 2000]
12
Proposal 1: Major Components
:WoW Client 1
:NPC AI
NPC:Character
:Screen Buffer
Position
Accessories
Hero:Character
Position
Accessories
:Gfx Rendering
:User Input
:Accesory Gfx
Model
:Character Gfx
Model
:World Gfx Model
• Responsibilities (not all listed here)
– Gfx Rendering:
• Rendering loop, draws all polygons for a complete image
• Renders 20 fps
– User Input:
• Receives keyboard and mouse input
• Changes position of our “hero” avatar / “toon”
13
Discussion
• This architecture is missing the perhaps most
important property of the real WoW.
:WoW Client 1
:NPC AI
NPC:Character
:Screen Buffer
Position
Accessories
Hero:Character
Position
Accessories
:Gfx Rendering
:User Input
:Accesory Gfx
Model
:Character Gfx
Model
:World Gfx Model
• Which one am I thinking of?
14
Proposal 1: Connector
• A Connector is a protocol
– hero.getPosition(p) is “pull-data connector”
– could have made a MVC protocol instead
Gfx Step 1: Render world view
:Gfx Rendering
:World Gfx Model
Hero:Character
:Screen Buffer
:User Input
getPosition()
p
getPolygons(p)
changePosition()
ui events
renderPolygons
• Use sequence diagrams to illustrate connectors
– i.e. the flow of data and control between components
15
Discussion
• This diagram has some obvious implications on
the Hero object!
Gfx Step 1: Render world view
:Gfx Rendering
:World Gfx Model
Hero:Character
:Screen Buffer
:User Input
getPosition()
p
getPolygons(p)
changePosition()
ui events
renderPolygons
• Which one?
16
Proposal 2: Components
:WoW Server
:NPC AI
User:Profile
Password
Payment
NPC:Character
Hero:Character
Position
Accessories
Position
Accessories
:WoW Client 2
:Screen Buffer
:User Input
:Gfx Rendering
:Accesory Gfx
Model
:Character Gfx
Model
:World Gfx Model
17
Proposal 2: Connector
Gfx Step 2: Render NPCs
:Gfx Rendering
:Character Gfx
Model
:NPC List
:Screen Buffer
:NPC AI
For all NPCs
getNext()
npc
getPolygons(npc)
changePositionOf(npc_x)
updatePosition
renderPolygons
• Keeping the pull connector
• This shows a major problem – which one?
18
Proposal 2: Connector
Gfx Step 2: Render NPCs
:Gfx Rendering
:Character Gfx
Model
:server
:client
:NPC List
:Screen Buffer
:NPC AI
For all NPCs
getNext()
npc
getPolygons(npc)
changePositionOf(npc_x)
updatePosition
renderPolygons
• Keeping the pull connector
• This shows a major problem – which one?
19
Summary
• C&C view describes run-time aspects
– Dynamics / “what happens”
– Objects, threads, processes
– Flow of data and control
• What earns money in a software company
– Class diagrams and text files of Java classes?
– Executing objects doing stuff the user wants?
• Morale: This is a central viewpoint !!!
20
Module Viewpoint
• Elements
– Classes, packages, interfaces
• Relations
The software architecture of a computing
system is the structures of the system,
which comprise software elements, the
externally visible properties of those
elements, and the relationships among
them [Bass et al., 2003]
– Associations, generalizations, realizations,
dependencies
• Mapping to UML
– Class diagrams…
21
Basic Module Elements (1)
Packages
Package 2
dependency
Contained
Class 1
Package 1
Contained
Package 1
Contained
Class 2
Contained
Package 2
Interfaces
Abstract Class
•
<<interface>>
Interface
dependency
Client Class
Interface
[Fowler, 2000]
dependency
Implementing
Class
Client Class
realization
Implementing
Class
22
Basic Module Elements (2)
Associations
role A
1
Class A
Class B
Class
role B
Class A
Class B
*
Class
navigable
0..1
Class A
Aggregation
Class A
Composition
Class
m..n
Class
• [Fowler, 2000]
23
Working Together in Teams!
24
…
• Each package can then be detailed – i.e.
showing their inner contents of interfaces and
classes (and subpackages…)
– PaSOOS forced you to read/write quite a few!
– Much closer to the code (nearly one-to-one mapping)
– You will get a chance in H1
25
Allocation Viewpoint
• Elements
– Software elements: Components, objects
– Environmental elements: Nodes
• Relations
– Allocated-to
– Dependencies
– Connections (communication paths)
The software architecture of a computing
system is the structures of the system,
which comprise software elements, the
externally visible properties of those
elements, and the relationships among
them [Bass et al., 2003]
• Mapping to UML
– Here: focus on deployment
• Deployment and component diagrams
26
Basic Allocation Elements
• (Note: UML components are used here)
• [Ambler: Agile modelling]
27
Example: WoW deployment
:Subscriber database
:Character Database
:SQL database
:SQL database
TCP/IP
TCP/IP
: Realm Server
{OS=Linux}
TCP/IP
:User PC
{OS=MacOS 10}
:Account Mgt
:Realm Server
WoW protocol
:WoW Client
• Realms are a real WoW artifact to tame the
performance demands
28
Summary
• Deployment viewpoint shows physical
deployment
– Computers / execution environments
• A Java VM can thus also be shown as a UML “box”
– Deployment units
• Programs, assemblies, jar
– Communication links and dependencies
29
Discussion
• Component & Connector viewpoint does not map well to
implementation?
– Few languages have interaction as first-class construct
– Neither to the UML – bound tightly to OO implementation
– On the other hand central in many approaches to architectural
design
• UML is not designed specifically for software architecture
description?
– Many (irrelevant) modeling constructs
– But very widely used and supported
• Not precise enough for formal analysis…
30
(The real thing)
CS@AU
Henrik Bærbak Christensen
31