Design Patterns, Architectural Patterns - New York University

Transcription

Software EngineeringG22.2440-001Session 8 – Sub-Topic 1Design Patterns, Architectural PatternsDr. Jean-Claude FranchittiNew York UniversityComputer Science DepartmentCourant Institute of Mathematical Sciences1Design Patterns,Architectural Patterns1

Bibliography « A System of Pattern » Bushmann et All« Design Patterns » Gamma et All« Concurrent Programming in Java » D. Lea.« Distributed Objects » Orfali et All« Applying UML and Patterns » Larman3Patterns « Patterns help you build on the collectiveexperience of skilled software engineers. »« They capture existing, well-provenexperience in software development andhelp to promote good design practice »« Every pattern deals with a specific,recurring problem in the design orimplementation of a software system »« Patterns can be used to constructsoftware architectures with specificproperties »42

Becoming a Chess MasterFirst learn rules and physical requirements– e.g., names of pieces, legal movements, chess boardgeometry and orientation, etc.Then learn principles– e.g., relative value of certain pieces, strategic value ofcenter squares, power of a threat, etc.However, to become a master of chess, one muststudy the games of other masters– These games contain patterns that must be understood,memorized, and applied repeatedlyThere are hundreds of these patterns5Becoming a Software DesignerMasterFirst learn the rules– e.g., the algorithms, data structures and languages ofsoftwareThen learn the principles– e.g., structured programming, modular programming,object oriented programming, generic programming, etc.However, to truly master software design, onemust study the designs of other masters– These designs contain patterns must be understood,memorized, and applied repeatedlyThere are hundreds of these patterns63

Software ArchitectureA software architecture is a description of thesubsystems and components of a softwaresystem and the relationships between them.Subsystems and components are typicallyspecified in different views to show therelevant functional and non-functionalproperties of a software system.The software system is an artifact. It is theresult of the software design activity.7ComponentA component is an encapsulated part of asoftware system. A component has aninterface.Components serve as the building blocks forthe structure of a system.At a programming-language level,components may be represented asmodules, classes, objects or as a set ofrelated functions.84

SubsystemsA subsystem is a set of collaboratingcomponents performing a given task. Asubsystem is considered a separate entitywithin a software architecture.It performs its designated task by interactingwith other subsystems and components 9Architectural PatternsAn architectural Pattern expresses afundamental structural organization schemafor software systems. It provides a set ofpredefined subsystems, their responsibilities,and includes rules and guidelines fororganizing the relationships between them.105

Design patternsA design pattern provides a scheme forrefining the subsystems or components of asoftware system, or the relation shipsbetween them. It describes a commonlyrecurring structure of communicatingcomponents that solves a general designproblem within a particular context.11IdiomsAn Idiom is a low-level pattern specific to aprogramming language. An idiom describeshow to implement particular aspects ofcomponents or the relationships betweenthem using the features of the givenlanguage.126

FrameworkA framework is a partially complete software(sub-) system that is intended to beinstantiated. It defines the architecture for afamily of (sub-) systems and provides thebasic building blocks to create them. It alsodefines the places where adaptations forspecific functionality should be made.13First ExampleA Dice GameA Player rolls 10x 2 dicesIf result 7, score score 10 pointsAt the end, score of the player is registred inthe highscore table.147

Activity artturn 0RollDiceturn [true]Turn 10[false]Updatehighscore15Analysis Diagram Actor Playername : Stringscore : int 0;play()Player()DiefaceValue : int e() me:String : type initvalscore:int : type initval0.*Entry(name:String,score:int)()168

Design StageManage User InterfaceManage Persistence of highscore in a file orin relational databaseRealize a layered architecture : Apply theLayer Architectural Pattern17LayerHelps structure an application that can bedecomposed into groups of subtasks inwhich each group of subtasks is at aparticular level of abstraction.189

Layer: examples19Layer :Structure2010

Layer: Structure21Layer and components 2211

Layers : VariantsRelaxed Layered System:– A layer « j » can use service of j-1, j-2 – A layer can be partially opaque Some service to layer j 1, others to all upperservices Layering through inheritance:– Lower layers are implemented as base classes– Higher level can override lower level 23Layers : Known UsesVirtual machines: JVM and binary code formatAPI : Layer that encapsulates lower layersInformation System– Presentation, Application logic, Domain Layer, DatabaseWindows NT (relaxed for: kernel and IO and hardware)– System services,– Resource management (Object manager, security monitor, processmanager, I/O manager, VM manager, LPC),– Kernel (exception handling, interrupt, multipro synchro, threads),– HAL (Hardware Abstraction Level)– Hardware2412

Layers: benefitsReuse of layersSupport for standardization (POSIX)Dependencies are kept localExchangeabilities :– Replacement of old implementation with AdapterPattern– Dynamic exchange with Bridge Pattern25Layers: LiabilitiesCascades of changing behaviorLower efficiencyUnnecessary work: functions of a layercalled many times for one serviceDifficulty of establishing correct granularity oflayers: Too few layers - less benefits, toomany layers - complexity and overhead 2613

Applying Layer ArchitectureUICorePlayPersistenceView High ScoreFichier ou BDD27Package decomposition layer UI layer Core subsystem Util layer Persist2814

Layer « core »Contain business logic classes Adapt analysis classes for implementationUse of singleton Idiom 29Singleton (Idiom)Ensure a class only has one instance, andprovide a global point of access to it.3015

Singleton Structure31Core « Layer »:First diagramAnalysisDesignHighScore hs : HighScore nullHighscore()add()load()save()Entryname:String : type initvalscore:int : type initval10.*Entry(name:String,score:int)() Actor Playername : String 1score : int 0;Rolls2DiefaceValue : int 1roll()Die()play()Player()Plays1DiceGame dg iefaceValue : int 1roll()Die()display()1Singleton.-player1Playername : Stringscore : int 0;Player()display()IncludesDiceGame() me:String : type initvalscore:int : type initval0.*Entry(name:String,score:int)()3216

Package decomposition layer UI layer Core subsystem Util layer Persist33ObserverOne-to-many dependency betweenobjects: change of one object willautomatically notify observers3417

Observer: ApplicabilityA change to one object requires changing anunknown set of other objectsObject should be able to notify other objectsthat may not be known at the beginning35Observer: Structure3618

Observer: ConsequencesAbstract coupling between subject andobserverSupport for broadcast communicationHard to maintain37Applying Observer PatternObservable(from util)changed : boolean false Interface rs()(from util)0.*update(o : Observable, arg : Object) : voidDie(from Core)DieViewfaceValue : int 1Player(from Core)name : Stringscore : int 0;Player()display()DieView(die : Die)update(o : Observable, arg : Object) : r : Player)update(o : Observable, arg : Object) : void3819

Observer View Interface Observer(from util)update(o : Observable, arg : Object) : voidDieViewDieView(die : Die)update(o : Observable, arg : Object) : voidPlayerViewPlayerView(player : Player)update(o : Observable, arg : Object) : void39Views are graphical objectsObservable(from util)changed : boolean false Interface rs()(from util)0.*update(o : Observable, arg : Object) : voidPanel(from y()Die(from Core)DieViewfaceValue : int 1Player(from Core)name : Stringscore : int 0;Player()display()DieView(die : Die)update(o : Observable, arg : Object) : View(player : Player)update(o : Observable, arg : Object) : void4020

Setting up Observer: RollForm:Playe1: display( ): PlayerView: Die: DieView2: PlayerView(Player)3: addObserver(Observer)4: return component5: display()6: DieView(Die)7: addObserver(Observer)8: return component41Observer : Change Propagation: Die: Randomizer: DieView: JLabel1: getValue( )2: setValue(int)3: notifyObservers( )4: update(Observable, Object)5: getState()36: setText(3)4221

Layered Architecture.RollForm(from UI)roll action()cancel action()RollForm()DieView 2(from UI)UI thePlayerViewPlayerView(from UI)1 oupling classes Interface Displayable Interface ObserverObservable(from util)(from util)0.*and interfacesDiefaceValue : int 1Coreroll()Die()display()setValue()Playername : Stringscore : int 0;Player()display()43Package decomposition layer UI layer Core subsystem Util layer Persist4422

Pattern Factory MethodIntent– Define an interface for creating an object, but letsub-classes decide which class to instantiate– let a class defer instantiation to subclasses– Also known as Virtual Constructor45Factory MethodApplicability : Use when– a class cannot anticipate the class of objects itmust create– a class wants its subclasses to specify theobjects it creates– classes delegate responsibility to one of severalhelper subclasses, and you want to localize theknowledge of which helper subclass to delegate.4623

StructureFacteurProduitproduit cretFacteurConcretreturn new ProduitConcret()Fabrication()47Factory methodConsequences– Provide hooks for subclasses– connects parallel class hierarchiesKnown uses– MacApp, ET – ClassView in smalltalk80 MVC (controllercreation)– Orbix ORB for generating PROXY object4824

« Persist » LayerPersistence technical classesEnsure independence of Core/Persist– Be able to switch « persistent engine »For example:– Persistence via « Serialization »– Persistence via a relational database (JDBC).49Applying FactoryHighScore(from Core) hs : HighScore nullAbstract producConcrete productConcrete FactoryAbstract FactoryHighscore()add()load()save()HighScoreSr filename : String eKit()PersistKitmakeKit()5025

Applying Factory: RealPlayer: DiceGame: S rK it: HighScoreSr1: SrKit( )A ttention!DiceGame voit S rK it commeun P ersistKit et HighScoreSrcomme un HighS core2: getInstance( )3: DiceGame( )4: makeKit( )5: HighScoreSr( )6: load( )7: quit( )S eul le Realplayer sait qu'ilutilise un S rK it ! DiceGamenon !8: getInstance( )9: save( )51Summary1 Architectural pattern : Layer2 Design Patterns : Observer, Factory1 Idiom : SingletonPb:– Combining pattern to combine their forces 5226

53Bank example A basic bank system:– 1 bank, n Account.– Each account belong to 1 client.– Each account is credited by an amount a money.Bank functions– Withdrawal on an account, Credit an account,Transfer money from one account to another 5427

Naive solutionBanka dd Acco unt(S tring name, int a mo unt) : A ccountwithdrawal(int id a, int a mo unt) : voidd ep osit(int ida , int amout) : vo idtransfe r(int ida 1, int id a2 , int amount) : vo idg etA ccount(int ida ) : A ccountid a : intidc : int110.nAccountint a mo untint id a0.nid a : int1withdraw(int a ) 1 .nd ep osit(int a)A ccount(int ida )CustomerString name;int idcClient(String name, int idc)55Naive Solution: c li e n t: B a nktr a n s fe r ( 1 ,2 ,1 0 01 : A c co unt2 : A cco unt)w i t h d r a w a l (1 , 1 0 0)g e tA c c o un t( 1 )w i th d r a w ( 1 0 0 )d e p o s i t( 2 , 1 0 0)g e tA c c o un t( 2 )d e p o s i t( 1 0 0 )5628

Applying Command Pattern Encapsulate a request as an object, therebyletting you parameterize clients with differentrequests, queue or log requests, and supportundoable operations.57Command Example5829

Command Example59Command Structure6030

Command Structure61Command ConsequencesCommand decouples the object thatinvokes the operation from the one thatknows how to perform it.Commands are first-class objects. Theycan be manipulated and extended like anyother object.It's easy to add new Commands, becauseyou don't have to change existing classes.6231

Applying Command PatternCom m andb : banqueB ank receivergetAccount(int ida) : AccountExecute(cmd : Command) : voiddo() : voidundo() : voidCommand(Bank b)ida : intidc : int110.nA ccountint amountint idaTransferWithdrawalid a : inta mo unt : intDepositid a : inta mo unt : intd o() : voidund o:void ()d o() : voidund o: void ()ida1 : intida2 : intamount : intdo() : voidundo:void()opname()Transfer(ida1 : int, ida2 : int, int a, Bank b)withdraw(a : int)deposit(a : int)1.nida : int10 .nCustomerString name;int idcClient(String name, int idc)63Applying Command Pattern: clientt : Transfer: Bank1 : Acco unt2 : AccountTransfer(1,2,100 )Execute(t )do( )getAccount( 1)withdraw( 100)getAccount( 2)deposit( )6432

Composite PatternCompose objects into tree structures torepresent part-whole hierarchies. Compositelets clients treat individual objects andcompositions of objects uniformly.65Composite Example6633

Composite Example67Composite Structure6834

Applying Composite on Command69Applying CompositeCommandBank receiverb : banquegetAccount(int ida) : AccountExecute(cmd : Command) : void0.ndo() : voidundo() : voidCommand(Bank b)ida : intidc : int11MacrocomWithdrawalida : intamount : intdo() : voidundo:void()Withdrawal(b : Bank, ida : int, amount : int)add(Command cmd)remove(Command cmd)do()undo()Macrocom(b : Bank)0.nAccountint amountint ida1.nwithdraw(a : int)deposit(a : int)ida : int10.nCustomerString name;int idcClient(String name, int idc)Depositida : intamount : intdo() : voidundo: void()Deposit(b : Bank, ida : int, amount : int)7035

: clientw : Withdrawald : Depositm : Ma cro com: Bank1 : Acco unt2 : Acco untWithdrawal(b, 1,100 )Deposit(b,2,100 )M acroco m(b )add( w)add(d )Execute(m )do( )do( )getAccount( 1)withdraw( 100)do( )getAccount( 2)d ep osit( 10 0)71Applying SingletonBankinstance : BankCommand0.ngetAccount(int ida) : AccountExecute(cmd : Command) : void idc : int1getInstance() : Bankdo() : voidundo() : voidida : int1MacrocomWithdrawalida : intamount : intdo() : voidundo:void()Withdrawal(ida : int, amount : int)add(Command cmd)remove(Command cmd)do()undo()Macrocom()0.nAccountint amountint idawithdraw(a : int)deposit(a : int)1.nida : int10.nCustomerString name;int idcClient(String name, int idc)Depositida : intamount : intdo() : voidundo: void()Deposit(ida : int, amount : int)do () {Bank b Bank.getInstance();.}7236

And So on Storing state : Memento PatternObserving Account : Observer PatternVisiting all object graph : Visitor PatternRemote access : Proxy pattern 73Proxy PatternProvide a surrogate or placeholder foranother object to control access to it.7437

Proxy Example75Proxy Structure7638

Proxy benefitsremote proxy can hide the fact that anobject resides in a different address space.A virtual proxy can perform optimizationssuch as creating an object on demand.Both protection proxies and smartreferences allow additional housekeepingtasks when an object is accessed.77Command(from remotecommand)AccountViewer(from remotecommand)RemoteObservableexecute() : voidunexecute() : voidCommand()AccountViewer(arg0 : String)update(arg0 : Object) : void Interface BankServerI(from remotecommand)execute(arg0 : Command) : void(from remotecommand)update(arg0 : Object) : voidaddObserver(arg0 : RemoteObserver) : voidremoveObserver(arg0 : RemoteObserver) : voidsetChanged() : voidnotifyObservers() : voidnotifyObservers(arg0 : Object) : voidRemoteObservable()BankServerAccountCreate(from remotecommand)AccountWithdrawal(from remotecommand)(from remotecommand)sum : int Interface RemoteObserver(from remotecommand)changed : booleansum : intAccountCreate(arg0 : String, arg1 : int)execute() : voidunexecute() : voidtoString() : StringroAccountWithdrawal(arg0 : String, arg1 : int)execute() : voidunexecute() : voidAccountDeposit(from remotecommand)sum : intAccountDeposit(arg0 : String, arg1 : int)execute() : voidunexecute() : voidMacroCommandBankServer()execute(arg0 : Command) : voidmain(arg0 : String[]) : voidBankAccount(from remotecommand)amount : intBankAccount(arg0 : String, arg1 : int)name() : Stringamount() : intamount(arg0 : int) : voidtoString() : StringBankBase(from remotecommand)instance() : BankBaseaddAccount(arg0 : BankAccount) : voidgetAccount(arg0 : String) : BankAccountremoveAccount(arg0 : String) : voidtoString() : StringBankBase() bb(from remotecommand)execute() : voidunexecute() : voidadd(arg0 : Command) : voidMacroCommand()RegisterObserver(from remotecommand)RegisterObserver(arg0 : String, arg1 : RemoteObserver)execute() : voidunexecute() : void7839

Adapter PatternConvert the interface of a class into anotherinterface clients expect. Adapter lets classeswork together that couldn't otherwisebecause of incompatible interfaces.79Adapter Example8040

Adapter Structure81Visitor PatternRepresent an operation to be performed onthe elements of an object structure. Visitorlets you define a new operation withoutchanging the classes of the elements onwhich it operates.8241

Visitor example83Visitor example8442

Visitor applicabilitymany distinct and unrelated operations needto be performed on objects in an objectstructure, and you want to avoid "polluting"their classes with these operations85Visitor Structure8643

Visitor Structure87Visitor ConsequencesVisitor makes adding new operations easyA visitor gathers related operations andseparates unrelated onesAdding new Concrete Element classes ishardVisiting across class hierarchiesAccumulating state.Breaking encapsulation8844

Chain of responsibilityAvoid coupling the sender of a request to itsreceiver by giving more than one object achance to handle the request. Chain thereceiving objects and pass the request alongthe chain until an object handles it.899045

Chain of Responsibility91Chain of Responsibility9246

ParticipantsHandler (HelpHandler)– defines an interface for handling requests.– (optional) implements the successor link.ConcreteHandler (PrintButton, PrintDialog)– handles requests it is responsible for.– can access its successor.– if the ConcreteHandler can handle the request, it doesso; otherwise it forwards the request to its successor.Client– initiates the request to a ConcreteHandler object on thechain.93Example Awt 1.09447

StrategyDefine a family of algorithms, encapsulateeach one, and make them interchangeable.Strategy lets the algorithm varyindependently from clients that use it.95Strategy 9648

Strategy97ParticipantsStrategy (Compositor)– declares an interface common to all supportedalgorithms. Context uses this interface to call thealgorithm defined by a ConcreteStrategy.ConcreteStrategy (SimpleCompositor,TeXCompositor, ArrayCompositor)– implements the algorithm using the Strategy interface.Context (Composition)– is configured with a ConcreteStrategy object.– maintains a reference to a Strategy object.– may define an interface that lets Strategy access itsdata.9849

Strategy C o m p o ne nt( fr o m a w t )c o m p o n e n t[]B u tto nC o n ta i n e r( fr o m a w t )( fr o m a w t )la y o u tM g r In te r fa c e L a y o u tM a n a g e r( fr o m a w t ) In te r fa c e L a y o u tM a n a g e r2( fr o m a w t )G rid L a yo u t( fr o m a w t )B o rd e rL a yo u t( fr o m a w t )99StateAllow an object to alter its behavior when itsinternal state changes. The object willappear to change its class.10050

Example101Structure10251

ConsequencesIt localizes state-specific behavior andpartitions behavior for different states2. It makes state transitions explicit3. State objects can be shared1.103DecoratorAttach additional responsibilities to an objectdynamically. Decorators provide a flexiblealternative to subclassing for extendingfunctionality.10452

Example105Example10653

Example107Structure10854

Applicabilityto add responsibilities to individual objectsdynamically and transparently, that is,without affecting other objects.for responsibilities that can be withdrawnwhen extension by subclassing is impractical109ConsequencesMore flexibility than static inheritance2. Avoids feature-laden classes high up in thehierarchy3. A decorator and its component aren'tidentical4. Lots of little objects1.11055

InputStream(from io)SKIP BUFFER SIZE : int 2048skipBuffer[] : putStream(from io)(from io)FileInputStream(name : String)FileInputStream(file : File)FileInputStream(fdObj : FileDescriptor)open(name : String) : voidread() : intreadBytes(b[] : byte, off : int, len : int) : intread(b[] : byte) : intread(b[] : byte, off : int, len : int) : intskip(n : long) : longavailable() : intclose() : voidgetFD() : FileDescriptorinitIDs() : voidfinalize() : berInputStream(from io)pushBack : int - 1lineNumber : intmarkLineNumber : intmarkPushBack : int - backInputStream(from io)buf[] : bytepos : m(from io)defaultBufferSize : int 2048buf[] : bytecount : intpos : intmarkpos : int - 1marklimit : e an abstraction from itsimplementation so that the two can varyindependently.11256

Bridge113Bridge11457

Bridge Structure 115BridgeDecoupling interface and implementation2. Improved extensibility3. Hiding implementation details from clients1.11658

LabelUI11711859

BuilderSeparate the construction of a complexobject from its representation so that thesame construction process can createdifferent representations.119Builder12060

Builder Structure 121Builder12261

Builder ConsequencesIt lets you vary a product's internalrepresentation2. It isolates code for construction andrepresentation3. It gives you finer control over theconstruction process1.123FlyWeightUse sharing to support large numbers offine-grained objects efficiently.12462

FlyWeight125Flyweight: Structure12663

Flyweight example127Flyweight: Instances12864

Flyweight: ApplicabilityEtat intrinsèque/extrinsèque Les états extrinsèques peuvent êtrecalculés 129Flyweight (il a rien compris )13065

IteratorProvide a way to access the elements of anaggregate object sequentially withoutexposing its underlying representation131Iterator13266

Iterator example:133Example13467

MementoWithout violating encapsulation, capture andexternalize an object's internal state so thatthe object can be restored to this state later.135Memento Structure 13668

Memento 1.2.3.4.5.Preserving encapsulation boundariesIt simplifies OriginatorUsing mementos might be expensive.Defining narrow and wide interfacesHidden costs in caring for mementos137Case Study13869

Design problems Document structure. The choice of internal representationfor the document affects nearly every aspect of Lexi'sdesign. All editing, formatting, displaying, and textualanalysis will require traversing the representation. Theway we organize this information will impact the design ofthe rest of the application.Formatting. How does Lexi actually arrange text andgraphics into lines and columns? What objects areresponsible for carrying out different formatting policies?How do these policies interact with the document'sinternal representation?139Design problems Embellishing the user interface. Lexi's userinterface includes scroll bars, borders, and dropshadows that embellish the WYSIWYG documentinterface. Such embellishments are likely tochange as Lexi's user interface evolves. Henceit's important to be able to add and removeembellishments easily without affecting the rest ofthe application.Supporting multiple look-and-feel standards. Lexishould adapt easily to different look-and-feelstandards such as Motif and PresentationManager (PM) without major modification.14070

Design problems Embellishing the user interface. Lexi's userinterface includes scroll bars, borders, and dropshadows that embellish the WYSIWYG documentinterface. Such embellishments are likely tochange as Lexi's user interface evolves. Henceit's important to be able to add and removeembellishments easily without affecting the rest ofthe application.Supporting multiple look-and-feel standards. Lexishould adapt easily to different look-and-feelstandards such as Motif and PresentationManager (PM) without major modification.141Design problems Spelling checking and hyphenation. Howdoes Lexi support analytical operationssuch as checking for misspelled words anddetermining hyphenation points? How canwe minimize the number of classes wehave to modify to add a new analyticaloperation?14271

14314472

14514673

14714874

14915075

15115276

15315477

15515678

15715879

Summary (C. Alexander)It is possible to create building architectures bystringing together patterns in a rather looseway. A building made like this, is an assemblyof patterns. It is not dense. It is not profound.But it is also possible to put patterns together insuch way that many patterns overlap in thesame physical space: the building is verydense; it has many meanings captured in asmall space; and through this density, itbecomes profound.159Architectural Patterns From MUD to Structure – Layers, Pipe and Filters, BlackboardDistributed Systems – Broker, Pipe and Filters, MicrokernelInteractive Systems – MVC, PACAdaptable Systems – Microkernel, Reflection 16080

Layerhelps structure application that can bedecomposed into groups of subtasks inwhich each group of subtasks is at aparticular level of abstraction.161Layer: examples16281

Layer :Structure163Layer: Structure16482

Layer and components 165Layer and Facade DP 16683

Layer and Facade DP167Layers : VariantsRelaxed Layered System:– A layer « j » can use service of j-1, j-2 – A layer can be partially opaque Some service to layer j 1, others to all upperservices Layering through inheritance:– Lower layers are implemented as base classes– Higher level can override lower level 16884

Layers : Known UsesVirtual machines: JVM and binary code formatAPI : Layer that encapsulates lower layersInformation System– Presentation, Application logic, Domain Layer, DatabaseWindows NT (relaxed for: kernel and IO and hardware)– System services,– Resource management (Object manager, security monitor, processmanager, I/O manager, VM manager, LPC),– Kernel (exception handling, interrupt, multipro synchro, threads),– HAL (Hardware Abstraction Level)– Hardware169Layers: benefitsReuse of layersSupport for standardization (POSIX)Dependencies are kept localExchangeabilities :– Replacement of old implementation with AdapterPattern– Dynamic exchange with Bridge Pattern17085

Layers: LiabilitiesCascades of changing behaviorLower efficiencyUnnecessary work: functions of a layercalled many times for one serviceDifficulty of establishing correct granularity oflayers: Too few layers - less benefits, toomany layers - complexity and overhead 171Pipes and FiltersProvides a structure for systems thatprocess a stream of Data. Each processingstep is encapsulated in a filter component.Data is passed through pipes betweenadjacent filters.Recombining filters allows the building offamilies of related systems.17286

Pipes and Filters: Example173Pipes and Filters: Structure17487

Pipes and Filters175Pipes and Filters: push pipeline17688

Pipes and Filters: pull pipeline177Pipes and Filters: push-pull pipeline17889

Pipes and Filters : Threaded Filters179Pipes and Filters: Known UsesUnixCMS Pipelines (extension IBM mainframes)LASSPTools (Numerical Analysis)– Graphical input devices (knobs or sliders)– Filters for numerical analysis and data extraction– Data sinks to produce animation from numericaldata streams Khoros : Image recognition WEB !! Servlet !!18090

Pipes and Filters BenefitsNo intermediate file necessary (but possible)Flexibility by filter exchangeFlexibility by recombinationReuse of filter componentsRapid prototyping of pipelineEfficiency by parallel processing181Pipes and Filters LiabilitiesSharing sta

2 3 Bibliography « A System of Pattern » Bushmann et All « Design Patterns » Gamma et All « Concurrent Programming in Java » D. Lea. « Distributed Objects » Orfali et All « Applying UML and Patterns » Larman 4 Patterns « Patterns help you build on the collective experience of skilled s