Architectural Styles 1 - Rose–Hulman Institute of …...Architectural Styles 1 CSSE 574: Session...
Transcript of Architectural Styles 1 - Rose–Hulman Institute of …...Architectural Styles 1 CSSE 574: Session...
Architectural Styles 1 CSSE 574: Session 8, Part 4
Steve Chenoweth
Phone: Office (812) 877-8974, Cell (937) 657-3885
Email: [email protected]
And this is not a filter!
Images below –
Homage to Magritte,
in a way…
2
This Discussion
Architectural styles, Part 1 Relates strongly to software reliability/availability, and
the other QA’s
We’ll talk about these thru slide 28.
More details – read the article case studies (relate to the rest of the slides in this set)!
Right – The real Magritte.
What does “This is not a
pipe” mean, Rene?
3
Acknowledgements
Some of the material in these slides is taken from “An Introduction to
Software Architecture” by Garlan and Shaw,
http://www.cs.cmu.edu/afs/cs/project/vit/ftp/pdf/intro_softarch.pdf.
David Garlan and Mary Shaw, from their home
pages http://www.cs.cmu.edu/~garlan/ and
http://spoke.compose.cs.cmu.edu/shaweb/.
4
What is an Architectural Style?
5
What is a Software Architectural Style?
Architectural Style =
Components + Connectors + Constraints
Primarily, the dynamics of the design
Components: computational elements
Connectors: interactions between
components
Constraints: how components and connectors
may be combined
6
Questions About Architectural Styles
What is the design vocabulary?
What are the allowable patterns?
What is the underlying computational model?
What are the essential invariants?
What are common examples?
What are advantages and disadvantages?
What are common specializations?
7
Styles covered in these slides
Call and Return
Data Abstraction
Implicit Invocation
Pipe and Filter
Layered
… with examples!
Garlan & Shaw’s TOC:
(Slides 29+)
8
Call and Return
Main
One Two Three
Foo Bar
Basically, this is application of a “divide and conquer” systems theory.
“I’ll design and code Main and One, you want to take Two and Three? Then we’ll have another look at Foo and Bar…”
Most common style?
Fits with organizational considerations!
Like calling a sequence of functions.
9
Call and Return Properties
Components are subroutines
Connectors are invocations
Heuristic: Cycles (recursion) are discouraged Clearest when subroutines (or whatever the boxes mean)
are called once to do “something”
Heuristic: Multitasking is discouraged Easier to follow “what happens next”
Usually synchronous “call and return” message style
Heuristic: Try to follow an organized pattern of calling subroutines (like hierarchical).
Invariants? Not a lot of guarantees about how data is manipulated as it moves through the system.
Note: “Invariants” = architectural principles that are true for this style,
especially in regard to maintaining integrity of data.
10
Call and Return Example
Commonly seen as a way to organize large systems like this.
Gives a basic way to control coupling and cohesion.
Down in the details, usually you need layers or abstraction (OO) to keep complexity down.
Example is LDAP (Lightweight Directory Access Protocol) system, UC Berkeley. From
http://softwareengineeringnotes.blogspot.com/2007/07/call-and-return-architecture.html.
11
Data Abstraction (Object Oriented)
12
Data Abstraction
Properties
Components are objects - act as
managers of resources
Connectors are function invocations
Invariant 1: object maintains integrity of its
representation
Invariant 2: representation is hidden from
other objects
13
Data Abstraction
Advantages
May change representation without
affecting clients
Facilitates decomposition of problems
Objects that mirror real-world entities will
evolve slowly
14
Data Abstraction
Disadvantages
Must know identity of object in order to
interact with it
Our next style fixes that!
Side effects: changes caused by method
calls may propagate to clients
Example – a change in the number of
parameters you need to pass
15
Implicit Invocation (Callback)
Event 1
Event 2
Event 3
...
Foo
Bar
Register interest in events
Notification of events
Announcement of events
16
Implicit Invocation
Properties
Components are modules with:
procedures
events that are announced
events of interest
Invariant: announcers of events do not
know which components are registered
with those events
17
Implicit Invocation
Advantages
Reuse: any component can be introduced
by registering it for appropriate events
Evolution: components may be replaced
without affecting other interfaces
18
Implicit Invocation
Disadvantages
Control: no way to know what will happen
after event is announced
Data: may lead to performance problems
Correctness: meaning of procedure is
context dependent
19
Implicit Invocation Example
Publisher-Subscriber systems – used for event management, and more:
DB
S’s = subscribers to information. P’s = providers of information.
Think RSS Feed, or Object Request Brokers like CORBA.
S1 P1
P2 S3
S2 Web
Client
Another
System
Managed
System
Managed
System
Connection
to Broker
Connection
to Broker
Connection
to Broker
Connection
to Broker
Connection
to Broker
Subscription
Dis
trib
ution
Subscription
Broker
Architecture
Services
Provided
Services
Provided
Subscriptions
Subscriptions
Subscriptions
20
Pipe and Filter
21
Pipe and Filter
Properties
Components apply local transformation to
their inputs - filters
Connectors act as conduits - pipes
Invariant 1: filters must be independent
Invariant 2: filters do not know their
neighbors
22
Pipe and Filter
Examples Common Examples
Unix shell scripts
Compilers
How you translate the data coming & going from an application (often using 3rd party products)
Work flow manager – has a supervisory layer above the pipes and filters controls the flows of data
Specializations Pipelines: linear structures
Bounded pipes: restrict amount of data
Typed pipes: data must be of certain type
23
Pipe and Filter
Advantages Behavior is just composition of filters
Support reuse -- just reconnect
Using standard I/F’s, can build out of off-the-shelf pieces
Easy to maintain and enhance
Permit analysis - throughput, deadlock
Support concurrency The filters can hand-off individual records, vs. whole files. Or better…
This is roughly how router connections on the Internet work, sometimes with only ~ 1-bit delays per box (like for ATM).
Two years ago in 377, teams built pipe and filter systems and had a speed contest. The winner converted a megabyte spreadsheet into XML in two seconds!.
24
Pipe and Filter
Disadvantages Often lead to batch processing
What’s that? Programs in each stage run to completion before the next one starts.
Note that “batch” is legitimately how server maintenance is done – like backups and DB updating after hours, with checkpoints in the processes between steps
May be hard to coordinate streams
May force lowest common denominator for transmission
On one computer – a memory hog (how would you fix that?)
What do you do when there’s an error? Can you debug the problem?
Can you backtrack for recovery?
25
Layered
U p
v C
26
Layered Properties
Components often implement a virtual
machine for upper layers
Connectors defined by protocols between
layers
Quasi-invariant: Layers often only interact
with neighbors
27
Layered Advantages
Abstraction: separation of concerns
Evolution: changes to one layer only affect
neighboring layers
Reuse: layers have strong interfaces
28
Layered Disadvantages
Some systems are hard to partition this
way
Performance may require closer coupling
between upper and lower layers
Hard to find the right levels of abstraction
for all features
More Complex
Examples…
See Garlan & Shaw’s
article (Case Studies) for
more info on each of these.
Backup Slides
30
KWIC – Call and Return
31
Key Word in Context (KWIC)
The KWIC index system accepts an ordered set of
lines, each line is an ordered set of words, and
each word is an ordered set of characters. Any line
may be "circularly shifted'' by repeatedly removing
the first word and appending it at the end of the
line. The KWIC index system outputs a
listing of all circular shifts of all lines in
alphabetical order.
-- David Parnas, 1972. He’s still around – see
his profile at http://sigsoft.org/SEN/parnas.html.
32
KWIC Example
Input: descent of man
the ascent of man
the old man and the sea
Output: the ASCENT of man
DESCENT of man
descent of MAN
the ascent of MAN
the old MAN and the sea
the OLD man and the sea
the old man and the SEA
33
KWIC – Data Abstraction
34
KWIC – Implicit Invocation
35
KWIC – Pipe and Filter
36
Oscilloscope
Sample electrical
signals
Display pictures
(traces)
Perform
measurements
37
Oscilloscope – Data Abstraction
38
Oscilloscope – Layered
39
Oscilloscope – Pipe and Filter
40
Oscilloscope – Modified Pipe and Filter