Software Architectures. Lecture 8

Software Architectures Lecture 8 Roadmap of the course  What is software architecture?  Designing Software Architecture  Requirements: quality a...
Author: Stuart Fox
19 downloads 0 Views 1MB Size
Software Architectures

Lecture 8

Roadmap of the course  What is software architecture?  Designing Software Architecture  Requirements: quality attributes or qualities  How to achieve requirements : tactics  How do tactics lead to architectural styles  Case studies on architectural styles, observe the achieved qualities  The ADD method

 Documenting software architecture  Bass and all  Hofmeister and all

 Evaluating an architecture  Today: ADLs and short discussion of formal approaches to

architectures

2

1.12.2011

Linguistic character of architectural description  Common patterns in different architectures  common kinds of elements  common inter-module connection strategies  Languages describe complex relations among

primitive elements and combinations of these  Semantic constructs => There is an appropriate linguistic basis in architectural descriptions

3

1.12.2011

Common patterns of SW organization  SA description often  Box-and-line diagrams  boxes  major components  lines  communication, control, data relation  Boxes and lines may mean different things  For different described systems  For different people  Supplemented with prose, no precise meaning  Informal terms  Still useful

4

1.12.2011

Usage of common patterns  Informal terms  Often refer to common patterns used to organize

the system  Used among SW engineers in high-level descriptions of designs  More precise definitions of these  (would be) Beneficial for SW developers  In the forms in which they appear  In the classes of functionality and interaction they provide

5

1.12.2011

Common component classes  (pure) Computation  Simple input/output relations, no retained state  Exp: Math functions, filters, transforms

 Memory  Shared collection of persistent structured data  Exp: Database, file system, symbol table, hypertext

 Manager  State and closely related operations  Exp: Abstract data type, servers

 Controller  Governs time sequences of other’s events  Exp: Scheduler, synchronizer

 Link  Transmits information between entities  Exp: Communication link, user interface

6

1.12.2011

Common interactions among components 

Procedure call  Single thread of control passes among definitions  Exp: Ordinary procedure call, remote procedure call



Dataflow  Independent processes interact through streams of data  Exp: Unix pipes



Implicit invocation  Computation is invoked by the occurrence of an event; no explicit interactions among

processes  Exp: Event systems, automatic garbage collection 

Message passing  Independent processes interact by explicit, discrete hand-off of data; may be synchronous or

asynchronous  Exp: TCP/IP 

Shared data  Components operate concurrently (probably with provisions for atomicity) on the same data

space  Exp: Blackboard systems, multiuser databases 

Instantiation  Instantiator uses capabilities of instantiated definition by providing space for state required by

instance  Exp: using abstract data types 7

1.12.2011

Critical elements of a design language  A (programming) language requires  Components  Primitive semantic elements and their values  Exp: integers, floating-point numbers, strings, records, arrays

 Operators  Functions that combine components  Exp: iteration, conditional constructs, +,-,*,/  Abstraction  Rules for naming expressions of components and operators  Exp: definition of macros and procedures  Closure  Rules to determine which abstractions can be added to the classes of primitive components and operators  Exp: procedures or user-defined types - first class entities  Specification  Association of semantics to the syntactic form  Formal, informal (in reference manual) 8

1.12.2011

The language problem for SA  SA deals with  Allocation of functionality to components  Data and communication connectivity  Quality attributes and system balance

 Quite different from the (conventional)

programming language concerns  Specific forms of the various language elements are

also different

9

1.12.2011

Critical elements of a SA design language  Components  Module-level elements; component classes listed before  Operators  Interaction mechanisms as listed before  Patterns/ abstraction  Compositions in which code elements are connected in a particular way; Exp: client-server relation  Closure  Conditions in which composition can serve as a subsystem in development of larger systems  Specification  Not only of functionality, but also of quality attributes

10

1.12.2011

Implication of the critical elements  Basis for designing ADLs provided by  Identification of architectural components  Identification of architectural techniques, for combining them into subsystems and systems  Such a language would support  Simple expressions of connections among simple modules, plus  Subsystems  Configurations of subsystems into systems  Common paradigms for such combinations  Expression of quality attributes and functional properties 11

1.12.2011

Requirements for ADLs 1. To provide models, notations, tools to

2. 3. 4. 5. 6. 12

describe architectural components and their interactions To handle large-scale, high-level designs To support the adaptation of designs to specific implementations To support user-defined abstractions To support application-specific abstractions To support the principled selection of architectural paradigms 1.12.2011

ADL and environment  Close relation between ADL and its

environment  ADL: precise descriptions  Environment: (re)uses the descriptions

 Ideal ADL should support  Composition  Abstraction  Reusability  Configuration  Heterogeneity  Analysis 13

1.12.2011

Composition  Describe a system as composition of

independent components and connections  Aspects  Divide a complex system (hierarchically) into

smaller parts  Assemble a large system from constituent elements  Independent elements  Can be understood in isolation from the system

 Separate issues of implementation-level from those

of architectural level 14

1.12.2011

Composition, 2  Another name: modularity  Closure rule: can see entities as both primitives

and composites  At different levels of abstraction

 Independence rule: can reuse parts of a

composite

15

1.12.2011

Composition, 3  Need for explicit and abstract composition rules  Pipe and filter  Sequence of pipes and filters

 Layered systems  Collection of abstract layers interacting according to

certain rules  Filter can internally be decomposed in  Another pipe and filter system  Instance of something else

 Filter may be used in any data stream transformation

system  Pipe may be used for any data transmission 16

1.12.2011

Abstraction  Allows to describe the abstract roles of elements and

their interaction within SA at a level well understood by designers  Clearly  Explicitly  Intuition

 Suppress unneeded detail but reveal important

properties • high-level pgm languages, register usage suppressed,

17

sequential control flow abstractions revealed • Interface: suppresses implementation issues, reveals use dependencies 1.12.2011

Abstraction, 2  Necessary to represent new architectural patterns

and new forms of interaction between them as first class abstractions  Architectural level of design  Different form of abstraction, to reveal high-level

structure  Distinct roles of each element in the high-level structure are clear  Example: client-server relationship

18

1.12.2011

Reusability  Reuse components, connectors, architectural styles in

different architectural descriptions  Reuse generic patterns of components and connectors  Families of SA as open-ended sets of architectural

elements  Structural and semantic constraints  Differs with respect to reusing components from libraries  Those are completely closed / parameterized components, retain

identities, are leaves of “is-composed-of” system structure  Reusing generic patterns of components and connectors: further instantiation, indefinite replication of relations, structured collections of internal nodes 19

1.12.2011

Reusability, 2  Systems rarely conceived in isolation  Instances of a family of similar systems that share

many architectural properties  Shared properties  Structural: specific topology of component and connectors  Constraints on using certain architectural elements

20

1.12.2011

Configuration  Architectural descriptions should localize the

description of system structure  Independently of the elements being structured  Dynamic reconfiguration permissible  Evolvability  Create/remove components, interactions initiated

 Allows to understand and change architectural

structure  Without examining individual components  ADL: should separate descriptions of compositions from

those of elements  Reason about composition as a whole 21

1.12.2011

Heterogeneity  Combine multiple, heterogeneous architectural

descriptions  Ability to combine different architectural styles in a

single system  Component A communicates with component B via a pipe, but

also accesses a shared database with a query  Different levels of architectural description should be allowed to use different architectural idioms

 Ability to combine components written in different

languages  Architectural description is at a higher level of abstraction than

the algorithms and data structures used for implementation 22

1.12.2011

Analysis  Possible to perform rich and varied analyses

of architectural descriptions  Each style facilitates a certain type of properties  Pipe and filter: possible to analyze throughput, investigate deadlock and resource usage, deduce the system I/O behavior from that of the filters  Should be possible to tailor special purpose analysis tools to architecture types  Automated and non-automated reasoning about

architectural descriptions

23

1.12.2011

Analysis, 2  Important for architectural formalisms  Many of the interesting architectural properties are

dynamic  Exp  If connector associated with protocol, is the use of connector

correct in its context?  Timing, performance, resource usage may aid in reasoning if SA adequate

 Variety of analyses => no single semantic framework

will be enough  Should be possible to associate specifications with 24

architectures as they become relevant to particular components, connectors, styles 1.12.2011

First-class connectors  SA treats SW systems as composition of

components  Focus on components  Description of interactions among components is

implicit, distributed, hard to identify  When interfaces explicit: import/export lists of data and procedures  Implicit interactions: include files => Info organized around components, significance of interactions, connections is ignored

25

1.12.2011

Problems with this practice 1. Inability to localize info about interactions 2. Poor abstractions 3. Lack of structure on interface definitions 4. Mixed concerns in programming language

specification 5. Poor support for components with incompatible packaging 6. Poor support for multi-language or multiparadigm systems 7. Poor support for legacy systems 26

1.12.2011

Fresh view of software system composition  Systems composed of identifiable

components of various distinct types  These interact in identifiable, distinct ways  Correspond to compilation units (roughly)

 Connectors mediate interactions among

components  Establish rules that govern component interaction  Specify any auxiliary mechanisms required  Do not correspond to compilation units

27

1.12.2011

Connectors  Manifest as  Table entries  Instructions to a linker  Dynamic data structures  System calls  Initialization parameters  Servers with multiple independent connections  Define a set of roles that specific named

entities of the components must play

28

1.12.2011

Connectors, 2  Place of relations among components  Mediate interactions  Have protocol specifications defining their properties  Rules about types of interfaces they are able to mediate for  Assurances about properties of interactions  Rules about order in which things happen  Commitments about interaction (ordering, performance, etc)  Are of some type/subtype  Roles to be satisfied: specific, visible named entities

in the protocol of a connector

29

1.12.2011

Components  Place of computation and state  Have interfaces specifying their properties    

Signatures Functionality of resources Global relations Performance properties

 Are of some type/subtype  Interface points: specific, visible named entities in

the interface of a component

30

1.12.2011

Primitive vs composite: components  Primitive components coded in the programming

language  Composite components define configurations in independent notation  Constituent components and connectors identified  Match connection points of components with roles

of connectors  Check integrity of the above

31

1.12.2011

Primitive vs composite: connectors  Of different kinds     

Shared data representations Remote procedure calls Dataflow Document-exchange standards Standardized network protocols

 Rich enough set to require taxonomy to show

relations among similar connector kinds

32

1.12.2011

Primitive connectors  Built-in mechanisms of programming languages  System functions of the OS  Shared data  Entries in task/routing tables  Interchange formats for static data  Initialization parameters  etc

33

1.12.2011

Summing up principles for ADL  Purpose: define roles and relationships instead of algorithms and

data structures  Must support  System configuration  Independence of entities (reusability)  Abstraction  Analysis of functional properties and QA

 Has syntax and  Defines semantics for connectors and their compositions  Generalize from import/export rules to rules with symmetry,

multiplicity, abstraction, locality, naming  Defines type structures for system organizations, components, connectors, primitive units of associations of these  Sets out appropriate rules for architectural abstractions 34

1.12.2011

Large grained structure of ADL

35

Component

Connector

Interface Component type Player Implementation

Protocol Connector type Role Implementation

1.12.2011

On ADL structure  Specify whether element primitive  Not further defined at architectural level, but

implemented in a programming language  Non-primitive element  Implementation: list of parts, composition

instructions, related specs => no more name matching

36

1.12.2011

Architecture Description Languages  The positives  ADLs provide a formal way of representing architecture  ADLs are intended to be both human and machine readable  ADLs support describing a system at a higher level than previously

possible  ADLs permit analysis of architectures – completeness, consistency, ambiguity, and performance  ADLs can support automatic generation of software systems  The negatives  There is no universal agreement on what ADLs should represent, particularly wrt the behavior of the architecture  Representations currently in use are relatively difficult to parse and are not supported by commercial tools  Most ADL work today has been undertaken with academic rather than commercial goals in mind  Most ADLs tend to be very vertically optimized toward a particular kind of analysis 37

1.12.2011

Software Architecture: ADL Perspective  The ADL community generally agrees that Software Architecture

is a set of components and the connections among them.  components  connectors  configurations  constraints

38

1.12.2011

ADLs  Leading candidates  ACME (CMU/USC)  Rapide (Stanford)  Wright (CMU)  Unicon (CMU)  Secondary candidates  Aesop (CMU)  MetaH (Honeywell)  C2 SADL (UCI)  SADL (SRI)  Others  Lileanna  UML  Modechart

39

1.12.2011

ACME  Acme was developed jointly by Monroe, Garlan (CMU) and Wile

(USC)  Acme is a general purpose ADL originally designed to be a lowest common denominator interchange language  Now  common interchange format for architecture design tools  foundation for developing new architectural design and analysis tools  simple architectural descriptions

 Acme language and Acme Tool Developer's Library (AcmeLib)  provide a generic, extensible infrastructure for describing, representing,

generating, and analyzing software architecture descriptions

40

1.12.2011

An ADL Example (in ACME) System simple_cs = { Component client = {Port send-request} Component server = {Port receive-request} Connector rpc = {Roles {caller, callee}} Attachments : {client.send-request to rpc.caller; server.receive-request to rpc.callee} }

rpc client send-request

41

caller

callee

server receive-request

1.12.2011

Rapide  Developed by David Luckham, Stanford  General purpose ADL designed with an emphasis on simulation  

 

42

yielding partially ordered sets of events (posets) Fairly sophisticated, including data types and operations Rapide analysis tools focus on posets  matching simulation results against patterns of allowed/prohibited behaviors  some support for timing analysis  focus on causality Rapide has some generation capability since Rapide specifications are executable Rapide has a fairly extensive toolset

1.12.2011

The Rapide Model  Concurrent, object-oriented, event-based simulation  

 

43

language Defines and simulates behavior of distributed object system architectures Produces a simulation represented by a set of events (poset)  Events are ordered with respect to time and causality System requirements are expressed as constraints on time and concurrent patterns of events Posets enable visualization and analysis of an execution 1.12.2011

Rapide Architectural Elements Components components

Architecture

connections constraints

Components interface interface

Component

architecture interface module

44

1.12.2011

Rapide Architectural Elements, 2  Components  Interface objects  Architecture that implements an interface  Module that implements an interface  Connections  Connects “sending interfaces” to “receiving interfaces”  Components communicate through connections by calling

actions or functions in their own interface  Events generated by components trigger event pattern connections between their interfaces  Three types of connections:  Basic connections  Pipe connections  Agent connections 45

1.12.2011

Architectural Elements (cont’d) Components provides part requires part

Interface

Components action part

in actions out actions

service part

state

Components behavior part

state transitions

constraint part

pattern constraints

Components private part

46

functions objects types

interface with no private part

1.12.2011

A Simple Specification in Rapide type Producer (Max : Positive) is interface action out Send (N: Integer); action in Reply(N : Integer); behavior Start => send(0); (?X in Integer) Reply(?X) where ?X Send(?X+1); end Producer; type Consumer is interface action in Receive(N: Integer); action out Ack(N : Integer); behavior (?X in Integer) Receive(?X) => Ack(?X); end Consumer architecture ProdCon() return SomeType is Prod : Producer(100); Cons : Consumer; connect (?n in Integer) Prod.Send(?n) => Cons.Receive(?n); Cons.Ack(?n) => Prod.Reply(?n); end architecture ProdCon; 47

1.12.2011

Wright  Developed by David Garlan at CMU  Wright is a general purpose ADL designed with an emphasis on





 

analysis of communication protocols  Uses a variation of CSP to specify the behaviors of components, connectors, and systems  CSP - Communicating Sequential Processes, process algebra developed by C. A. R. Hoare Focuses primarily on the basic component/connector/system paradigm  Similar syntactically to ACME and Aesop Wright analysis focuses on analyzing the CSP behavior specifications.  Any CSP analysis tool or technique could be used to analyze the behavior of a Wright specification Wright does not currently have a generation capability Wright has minimal native tool support (but CSP tools could be used)

A Simple Specification in Wright System simple_cs Component client = port send-request = [behavioral spec] spec = [behavioral spec] Component server = port receive-request= [behavioral spec] spec = [behavioral spec] Connector rpc = role caller = (request!x -> result?x ->caller) ^ STOP role callee = (invoke?x -> return!x -> callee) [] STOP glue = (caller.request?x -> callee.invoke!x -> callee.return?x -> callee.result!x -> glue) [] STOP Instances s : server c : client r : rpc Attachments : client.send-request as rpc.caller server.receive-request as rpc.callee end simple_cs. 49

1.12.2011

UML as an ADL  The Positive  lowers entry barrier, mainstreams modeling, tools

 Shortcomings of UML as an ADL  Weakly integrated models with inadequate

semantics for (automated) analysis  Connectors are not first class objects  Visual notation with little generation support, hidden and ambiguous relationships between views, both too much and too little

50

1.12.2011

Hence  There is a rich body of research to draw upon  Much has been learned about representing and

analyzing architectures  Effort is needed now to bring together the common knowledge and put it into practice

51

1.12.2011

For More Information  ACME: http://www.cs.cmu.edu/~acme  Rapide: http://pavg.stanford.edu/rapide/  Wright: 

   

52

http://www.cs.cmu.edu/afs/cs/project/able/www/wright/index.html Aesop: http://www.cs.cmu.edu/afs/cs/project/able/www/aesop/aesop_ho me.html Unicon: http://www.cs.cmu.edu/afs/cs/project/vit/www/unicon/index.html C2 SADL: http://www.ics.uci.edu/pub/arch/ SSEP: http://www.mcc.com/projects/ssepp ADML: http://www.mcc.com/projects/ssepp/adml

1.12.2011

Formalisms  Formal models and techniques are

cornerstones of a mature engineering discipline  Engineering disciplines used models and techniques in different ways  Provide precise, abstract models  Provide analytical techniques based on models  Provide design notations  Provide basis for simulations …

53

1.12.2011

What to formalize?  Architecture of a specific system  Allow the architect to plan a specific system  Becomes part of the specification of the system  Augments the informal characteristics of the SA  Permits specific analyses of the system

54

1.12.2011

What to formalize?  Architectural style  Describe architectural abstractions for families of

systems  Purposes:  Make common idioms, patterns and reference architectures

precise  Show precisely how different architectural representations can be treated as specializations of some common abstraction

55

1.12.2011

What to formalize  Theory of software architecture  Clarify the meaning of generic architectural

concepts  Architectural connection, hierarchical architectural

representation, architectural style

 Provide deductive basis for analyzing systems at an

architectural level  Might provide rules for determining when an architectural

description is well formed  Compositionality

56

1.12.2011

What to formalize  Formal semantics of ADL:s  Architectural description is a language issue  Apply traditional techniques for representing

semantics of languages

57

1.12.2011

Today’s takeaway  SA has a linguistic character  Programming languages are useful for

comparison  Connectors are needed in addition to components  ADLs may grow in the future

58

1.12.2011