View
221
Download
1
Embed Size (px)
Citation preview
Architectural Styles 1
CSSE 377 Software Architecture and Design 2Steve Chenoweth, Rose-Hulman InstituteWeek 2, Day 3, September 15, 2011
And this is not a filter!
Images below – Homage to Magritte, in a way…
2
Today First biweekly quiz from Tuesday – go over Architectural styles, Part 1 – this
Relates strongly to software reliability/availability, and the other QA’s We’ll talk about these thru slide 28 today. More details – read the article case studies! Tonight – HW 2
Project 2 – Progress reports: We’ll discuss in class the issues you’ve come up
with, trying to test your system’s availability over since Tuesday. Time to work on Project 2 in class Friday, 9/16 (tomorrow), 11:55 PM – File a spreadsheet showing the
“availability” of the part of the system you stressed, and how much you predict you can improve it. Also turn in your journal with a discussion of that spreadsheet – how you decided on the numbers, especially.
Policy clarification – Late = significant points off, unless previously negotiated.
Right – The real Magritte. What does “This is not a pipe” mean, Rene?
First biweekly quiz - feedback
Look at the ones you missed! “Key” is now out on course website, under Quizzes
Grading scale (“out of” 100, could get 111): Counted # 3 as 2 pts each part (poss 12) Counted all the others as 11 if full credit ()
Let’s go over a couple in class3. Performance scenarios
6. Architecture methodology See next slide We want to be at “models and theories”
3
Slide 4Am I architecting software? Why am I architecting software?
The “Novelty Circle” of The “Novelty Circle” of engineering; or, “Hey, engineering; or, “Hey, where’s my needle in where’s my needle in
this haystack?”this haystack?”
Top: The real person shown here is Denzil Biter, City Engineer for Clarksville, TN. See www.cityofclarksville.com/ cityengineer/.
FolkloreAd hoc solutions
New problems (novelty and nefarious outside forces)
Codification
Models & theories
Background is Claude Monet’s Meule, Soleil Couchant, 1891; Museum of Fine Arts, Boston Figure derived from Software Architecture: Perspectives on an Emerging Discipline, by Mary Shaw and David Garlan. Prentice Hall, 1996, ISBN 0-13-182957-2.
Image from www.reg.ufl.edu/ suppapp-splash.html.
Astronomer documenting observations. From
www.astro.caltech.edu/ observatories/palomar/
faq/answers.htm.
Cir
que
du S
olei
l aer
ial c
onto
rtio
nist
is I
sabe
lle C
hass
e,
from
http
://w
ww
.mon
trea
lene
span
ol.c
om/q
uida
m.h
tm“Here’s a great war story from the 1B project -- Impossible, but true!”
Imag
e fr
om w
ww
.st
urdy
kids
tuff
.com
/ tab
les.
htm
l
Improved practice
Bou
lder
clim
ber
from
ww
w.g
tonl
ine.
net
/com
mun
ity/ g
mc/
boul
der/
pecq
ueri
es.h
tm
“Yikes!”
5
Architectural Styles
Acknowledgement: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/.
7
What is a Software Architectural Style?
Architectural Style = Components + Connectors + Constraints Primarily, the dynamics of the designComponents: computational elementsConnectors: interactions between
componentsConstraints: how components and connectors
may be combined
8
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?
9
Today’s styles (more tomorrow)
Call and Return Data Abstraction Implicit Invocation Pipe and Filter Layered
… with examples!
Garlan & Shaw’s TOC:
(Slides 31+)
10
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.
11
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.
12
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.
14
Data Abstraction Properties Components are objects - act as managers of
resources Connectors are function (method) invocations Invariant 1: object maintains integrity of its
representation Invariant 2: representation is hidden from
other objects
15
Data Abstraction Advantages May change representation without
affecting clients Facilitates decomposition of problems Objects that mirror real-world entities will
evolve slowly
16
Data Abstraction Disadvantages Must know identity of object in order to
interact with itOur 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
17
Implicit Invocation (Callback)
Event 1Event 2Event 3...
Foo
Bar
Register interest in events
Notification of events
Announcement of events
18
Implicit Invocation Properties Components are modules with:
proceduresevents that are announcedevents of interest
Invariant: announcers of events do not know which components are registered with those events
19
Implicit Invocation Advantages Reuse: any component can be introduced
by registering it for appropriate events Evolution: components may be replaced
without affecting other interfaces
20
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
21
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
P2S3
S2WebClient
AnotherSystem
ManagedSystem
ManagedSystem
Connectionto Broker
Connectionto Broker
Connectionto Broker
Connectionto Broker
Connectionto Broker
Sub
scrip
tion
Dis
trib
utio
n
SubscriptionBroker
Architecture
ServicesProvided
ServicesProvided
Subscriptions
Subscriptions
Subscriptions
23
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
24
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
25
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!.
26
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?
28
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
29
Layered Advantages
Abstraction: separation of concerns Evolution: changes to one layer only affect
neighboring layers Reuse: layers have strong interfaces
30
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
33
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.
34
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