an introduction to software architecture by david …a78khan/cs446/lectures/2011_05-may_16...an...

35
WATERLOO CHERITON SCHOOL OF COMPUTER SCIENCE An Introduction to An Introduction to Software Architecture Software Architecture By By David Garlan & Mary Shaw – 94 David Garlan & Mary Shaw – 94 CS 446/646 ECE452 May 16 th , 2011 IMPORTANT NOTICE TO STUDENTS These slides are NOT to be used as a replacement for student notes. These slides are sometimes vague and incomplete on purpose to spark a class discussion

Upload: vukhuong

Post on 16-Mar-2018

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

An Introduction to An Introduction to Software ArchitectureSoftware Architecture

ByByDavid Garlan & Mary Shaw – 94David Garlan & Mary Shaw – 94

CS 446/646 ECE452May 16th, 2011

IMPORTANT NOTICE TO STUDENTS

These slides are NOT to be used as a replacement for student notes.These slides are sometimes vague and incomplete on purpose to spark a class discussion

Page 2: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 2WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

MotivationSoftware Systems● are more complex & bigger● are not just about “algorithms” anymore

Challenges– structural issues– communication (type, protocol)– synchronization– data access & manipulation– deployment– performance– testing

Which ones of these issues are more important than the others?

Page 3: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 3WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Architectural StyleRecognize common patterns● build new systems as variation on old systems

Selecting the right architecture● crucial to success

Page 4: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 4WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Page 5: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 5WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Page 6: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 6WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Page 7: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 7WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Page 8: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 8WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Page 9: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 9WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Page 10: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 10WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Page 11: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 11WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Architectural StyleMaking Choices● choices should be guided by system goals

– anything else ?

System Representation● describes the high level properties

Page 12: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 12WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Architectural StyleArchitecture Anatomy● component: represents computation (work)● connectors: facilitates component communication

Architectural Style/Configuration● architecture = {components, connectors, constraints}

– sounds UMLish?

Visualization ● graph representation

Page 13: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 13WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Architectural Styles

Pipes & filters

Data abstraction

Implicit invocation

Layered systems

Repositories

Page 14: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 14WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersOverview● architectural pattern for stream

processing● a filter defines a

processing/computation step● data flows through a

sequential chain of filters● a filter chain represents a system

F1

F2

F3

Component

Connector

data flow

Page 15: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 15WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersComponents (Filters)● set of inputs and outputs● input & output streams● local transformation

– incremental output

Connectors (Pipes)● facilitate data flow

Page 16: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 16WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersInvariants● filters are independent entities

– do not share state– have no knowledge of other filters

● data transformation– incremental – not dependent on order in the chain

● what does this mean?

Page 17: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 17WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersSpecialization● Pipelines

– restricted to linear topology● Bounded pipes

– restricts the amount of data on a pipe● Typed pipes

– data on a pipe to be of an acceptable type

Can a filter process all of its input data as a single entity?

Page 18: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 18WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersExamples● unix shell programs

– pipelines (cat file1 | sort | grep keyword)

Page 19: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 19WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersExamples● JEE Servlet Filter (javax.servlet.Filter)

– typed pipes

request

response

HTTPRequest

HTTPResponse

server servlet

server servletf1 f2 fn

Page 20: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 20WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersExamples● compilers

– more of a sequential batch architecture

lex syn sem opt code

source code machine code

Page 21: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 21WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersAdvantages● simple composition● reuse

– any two filters can be combined together● as long as they speak the same data language

● prototyping– how many scripts make use of grep, awk, sed etc?

● easy growth & evolution (how?)● architectural evaluation for performance & bottlenecks● naturally support concurrency & parallelism

Page 22: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 22WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Pipes & FiltersDisadvantages● poor performance

– each filter has to parse data– sharing global data is difficult

● not appropriate for interaction● low fault tolerance threshold

– what happens if a filter crashes● data transformation

– to LCD to accommodate filters – increases complexity & computation

Page 23: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 23WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Data AbstractionObject Oriented Organization (OOO)● encapsulation (data & operations)● division of responsibility

Page 24: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 24WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Data AbstractionComponents● objects, modules● discrete, independent, loosely coupled

Connectors● represent inter-object communication

– synchronous or asynchronous ● via messaging

– method calls ● interface● property access methods,

Page 25: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 25WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Data AbstractionKey Aspects● objects preserve their integrity ● no direct access● object representation is a private affair● functional composition

– objects can be assembled from other objects● inheritance & polymorphism

Page 26: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 26WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Data AbstractionAdvantages● implementation changes with minimal global impact

– is this really true?● decomposition

– large system into a set of interacting objects– easy to manage & evolve

● highly cohesive– really?

● extensible– via inheritance & polymorphism

Page 27: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 27WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Data AbstractionDisadvantages● interaction == coupling

– objects interact via public contract– what happens when the contract changes?– indirect coupling:

● A uses B, C uses B, then changes made by C on B are unexpected to A

Page 28: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 28WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Data AbstractionSome Thoughts● design by contract – interfaces

– decouples inter-object dependencies● synchronization● fault-tolerance

– what would happen if an object were to fail during an operation?

● evolution– does an OO system guarantee a good evolution path?

Page 29: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 29WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Implicit InvocationEvent-based● components do not directly invoke other components● similar to observer (GOF) design pattern

– implicit invocation architectural style has broader scope

Page 30: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 30WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Implicit InvocationComponents● modules {event, callback | procedure}

– objects, processes, distributed applications

Connectors● traditional method call● broadcast of events

Page 31: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 31WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Implicit InvocationPublish & Subscribe● components register for events● events are generated/published

– by different sources to a centralized system● events are broadcast

– via callback or procedure

Page 32: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 32WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Implicit InvocationInvariants● event generators do not know

– about event consumers– functional impact on different components

● broadcast ordering– components cannot make assumptions about ordered

delivery

Page 33: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 33WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Implicit InvocationExamples● news, fire alarms etc. (hmmm...sort of)● model view controller (MVC)● integrated development environments (IDE)● database systems to

– ensure consistency constraints– execute stored procedures

● user interface– separation of data presentation from data management

● enterprise application interaction

Page 34: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 34WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Implicit InvocationAdvantages● minimal dependency and loose coupling

– components do not directly interact with each other– components can be added or removed

● highly reusable– components can be replaced with newer components

● without changing their interfaces (TRUE/FALSE)?● scalable

– new components can simply register themselves– how about purging the older components?

Page 35: An Introduction to Software Architecture By David …a78khan/cs446/lectures/2011_05-may_16...An Introduction to Software Architecture By ... news, fire alarms etc. (hmmm ... Atif Khan

2011-05-04CS446/646 ECE452 35WATERLOOCHERITON SCHOOL OFCOMPUTER SCIENCE

Implicit InvocationDisadvantages● loss of execution control

– who, when, what● data exchange

– information has to be encapsulated within an event– shared repository– impact on global system performance & resource

management● event context

– unpredictable side effects– how to debug such a problem?