軟件系統(tǒng)設(shè)計(jì)與體系結(jié)構(gòu):Ch5 Software Architecture Styles_第1頁
軟件系統(tǒng)設(shè)計(jì)與體系結(jié)構(gòu):Ch5 Software Architecture Styles_第2頁
軟件系統(tǒng)設(shè)計(jì)與體系結(jié)構(gòu):Ch5 Software Architecture Styles_第3頁
軟件系統(tǒng)設(shè)計(jì)與體系結(jié)構(gòu):Ch5 Software Architecture Styles_第4頁
軟件系統(tǒng)設(shè)計(jì)與體系結(jié)構(gòu):Ch5 Software Architecture Styles_第5頁
已閱讀5頁,還剩112頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Ch 5 Software Architecture StylesSoftware System Design and ArchitectureMain ContentsAn Introduction to Software Architecture StylesModule-Level Software Architecture StylesProcess-Level Software Architecture StylesPhysical Unit-Level Software Architecture StylesCombining StylesSoftware Architecture

2、 Design needs StylesD.E. Perry and A. L. Wolf, 1992M. Shaw, 1996F. Buschmann,What is a Software Architecture Style? An architectural style defines:a family of systems in terms of a pattern of structural organization a vocabulary of components and connectors, with constraints on how they can be combi

3、nedShaw & Garlan, “Software Architecture: Perspectives on an Emerging Discipline”, 1996An architecture style:Describes a class of architectures or significant architecture piecesIs found repeatedly in practiceIs a coherent package of design decisionsHas known properties that permit reuseClements, Ka

4、zman & Klein, “Evaluating Software Architecture”,2002Styles for Different-Level ComponentsObjectsDesign PatternsModulesProcessesPhysical UnitMain ContentsAn Introduction to Software Architecture StylesModule-Level Software Architecture StylesProcess-Level Software Architecture StylesPhysical Unit-Le

5、vel Software Architecture StylesCombining StylesA catalog of architectural styles for modulesExample System: KWICThe KWIC index system accepts:an ordered set of lineseach line is an ordered set of wordseach word is an ordered set of charactersEvery line is circularly shifted and copied by:repeatedly

6、 removing the first wordappending it at the end of the lineOutputs a listing of all circular shifts of all lines in alphabetical orderKWIC ExampleInput:bar sockcar dogtown fogOutput:bar sockcar dogdog carfog townsock bartown fogFour steps:InputCircular shiftAlphabetizeOutputCircular shift positions:

7、1 5 10 14 18 23Alphabetize:1 10 14 23 5 18Design ConsiderationsChanges in algorithm: line shifting can be performed on each line as it is read from the input deviceon all the lines after they are readon demand when the alphabetization requires a new set of shifted linesChanges in data representation

8、: circular shifts can be stored explicitlyimplicitly (as index and offsets)Extra Features: Have the system eliminate circular shifts that start with certain noise words (such as a, an, and, etc.). Make the system interactiveallow the user to delete lines from original list and re-output alphabetized

9、 listPerformance: Both space and timeReuse: To what extent can the components serve as reusable entitiesCall-and-Return styleSub-styles:Main-program-and-subroutineDecompose program hierarchically. Each component gets control from its parent.Object-oriented (Data Abstraction)Objects help achieve modi

10、fiability by encapsulating internal secrets from environmentAccess to objects is only through methods (constrained forms of procedure calls)Main Program and Subroutine ArchitectureInput: read lines and stores them in Text array (buffer), index records starting position of each lineCircular shift: Cr

11、eates an index of starting positions for circular shifts, stores these in Word indexAlphabetizer: Takes the input from Text array and Word index, creates an index of shifts which are alphabetizedDesign ConsiderationsChanges in algorithm: Somewhat, however explicit data structure limits possibilities

12、“Show me your data structures and Ill tell you your algorithm” Fred BrooksChanges in data representation: Not possible, because data is made available explicitly to all components.Extra Features: Have the system eliminate circular shifts that start with certain noise wordsMedium, requires changes to

13、 existing componentMake the system interactiveMedium, requires changes to AlphabetizerPerformance:Space: Good, data is sharedTime: Bad, no concurrencyReuse: To what extent can the components serve as reusable entitiesBad, explicit data representation dependenciesObject-Oriented ArchitectureLine stor

14、age: Exports operations for getting characters in different positionsCircular shifter: function SHIFT(l,w,c) returns cth character in the wth word of the lth shiftAlphabetizer: function ITH(i) returns lines in sorted orderDesign ConsiderationsChanges in algorithm: Medium, data is made available thro

15、ugh fine-grained operations, but special interface must be obeyedChanges in data representation: Good, data is hidden behind interfaceExample: Line storage could keep information from diskExtra Features: Have the system eliminate circular shifts that start with certain noise wordsMedium, requires ch

16、anges to existing componentMake the system interactiveMedium, may require Alphabetizer to interact with Line storagePerformance:Space: Good, data can be shared through function callsTime: Bad, no concurrencyReuse: To what extent can the components serve as reusable entitiesMedium, explicit interface

17、 dependenciesPipe and Filter ArchitectureEach filter processes the data and send to the next filter.Each filter can run whenever it has data on which to runData sharing between filters is strictly limited to that transmitted on pipesDesign ConsiderationsChanges in algorithm: Good, as long as it does

18、nt require sharing dataExample: Alphabetizer can use any sorting routineChanges in data representation: Medium, existing pipe will be changedExtra Features: Have the system eliminate circular shifts that start with certain noise wordsGood, easy to insert new component in pipelineMake the system inte

19、ractiveBad, there is no stored intermediate representation Performance:Space: Bad, data must be copiedTime: Good, components run in parallelBad, copying takes timeReuse: To what extent can the components serve as reusable entities.Good, depends only on very common textual representationImplicit Invo

20、cation ArchitectureLines encapsulate share data, protect exposing the storage formats to the computing modulesComputations are invoked implicitly as data is modifiedDesign ConsiderationsChanges in algorithm: Good, as long as it doesnt require sharing dataChanges in data representation: Medium, share

21、 data is encapsulated, but its still share data!Extra Features: Have the system eliminate circular shifts that start with certain noise wordsMedium, requires changes to existing componentMake the system interactiveMedium, requires changes to existing componentPerformance:Space: Good, data is sharedT

22、ime: Good, components run in parallelReuse: To what extent can the components serve as reusable entities.Good, depends only on certain externally triggered eventsComparisonsMain-program-and-subroutineObject-OrientedPipe and FilterImplicit InvocationChange in algorithmBadMediumGoodGoodChange in data

23、representationBadGoodMediumMediumChang in functionsMediumMediumGoodMediumMake system interactiveMediumMediumBadMediumSpace performanceGoodGoodBadGoodTime performanceBadBadMediumGoodReuse componentsBadMediumGoodGoodMain Program and Subroutine StyleComponents: procedures , functions and module.Connect

24、ors: calls between them.ConstraintsControl starts at the top of a subroutine hierarchy and moves downwards. Hierarchical decompositionBased on definition-use relationshipSingle thread of controlSubsystem structure implicitSubroutines typically aggregated to modulesHierarchical reasoningCorrectness o

25、f a subroutine depends on the correctness of the subroutines it callsAdvantages and DisadvantagesAdvantagesClear process, easy understanding Strong correctness controlDisadvantagesDifficult to change and reuseMay be Common couplingApplicable to sequential systemsCorrectness critical systemsMain Prog

26、ram and Subroutine StyleComponents: package/component(UML).Connectors: None.Additional: Utility, tools (replication)邏輯設(shè)計(jì)是嚴(yán)格層次的物理包不是嚴(yán)格層次的Object-Oriented StyleComponents: object or moduleConnectors: function or invocations (methods).ConstraintsThe data representation is hidden from other objects.Objec

27、ts are responsible for preserving the integrity (e.g., some invariant) of the data representation.Every objects is an autonomous agentsApplications of Object-Oriented StyleSuitable for applications in which a central issue is identifying and protecting related bodies of information (data).Data repre

28、sentations and their associated operations are encapsulated in an abstract data type.Examples: Abstract data types Object-Oriented AdvantagesBecause an object hides its data representation from its clients, it is possible to change the implementation without affecting those clients.Data hiding (inte

29、rnal data representations are not visible to clients)Can design systems as collections of autonomous interacting agents.Methods are invoked on the objects, maintaining invariants. Can decompose problems into sets of interacting agentsObject-Oriented DisadvantagesIn order for one object to interact w

30、ith another object (via a method invocation) the first object must know the identity of the second object.When the identity of an object changes it is necessary to modify all objects that invoke it.Objects cause side effect problems:E.g., A and B both use object C, then Bs affect on C look like unex

31、pected side effects to A.Object-Oriented StyleComponents: package/component(UML).Connectors: None / Interfaces.Additional: Utility, tools (replication)Main Program and Subroutine VSObject Oriented Different in thinking way MPS (Stepwise Refinement) Functional Decomposition, & Data Flow MethodAllocat

32、e data to functionsSoftware structure is solution structure, not Problem StructureOOData-Structure Methods Responsibility-DrivenAllocate behavior to data (Allocate responsibility to object)Software (Data) structure= Problem StructureLayered StyleComponents: typically collections of procedures or obj

33、ects.Connectors: typically procedure calls or methods invocations under restricted visibility.ConstraintsSystem organized hierarchically into layers, with each layer:Providing a service to the layer above it, andActing as a client to the layer below.Protocol is stable and importantBehavior (API), Da

34、ta (data format, VO, POJO, etc)Skip layers is not allowedApplications of Layered StyleSuitable for applications that involve distinct classes of services that can be organized hierarchically.Especially when applications might be changed in some hierarchically, such as interaction, communication, har

35、d-ware, platform, etc.Example:Layered Communication Protocols: Each layer provides a substrate for communication at some level of abstraction.Lower levels define lower levels of interaction, the lowest level being hardware connections (physical layer).Operating Systems UnixLayers in Network Protocol

36、sUnix Layered ArchitectureLayered Style AdvantagesDesign: based on increasing levels of abstraction.Enhancement: since changes to the function of one layer affects at most two other layers.Reuse: since different implementations (with identical interfaces) of the same layer can be used interchangeabl

37、y.Layered Style DisadvantagesNot all systems are easily structured in a layered fashion.Performance requirements may force the coupling of high-level functions to their lower-level implementations.Layered Style SpecializationsOften exceptions are be made to permit non-adjacent layers to communicate

38、directly. This is usually done for efficiency reasons.Layered StyleComponents: multi package/component(UML).Connectors: none/ Interfaces/ protocol, data.Additional: Utility, tools (replication)DIP邏輯設(shè)計(jì)是嚴(yán)格層次的物理設(shè)計(jì)是非層次的Main Program and Subroutine VSLayered StyleMain Program and SubroutineFunction Decomp

39、ositionY=f(x1,xn) y= f( f1(x1), fi( xi,.xj), fn(xn)LayeredAbstraction at different levelY=f(x1,xn) =f1(x1,x2,.xn)Leveln =f2(x11,.x1n)Leveln-1 . y=fn(xn1,xn2,.xnn)Level1Model-View-Controller StyleThe model subsystems are designed such that they do not depend on any view or controller subsystems. Chan

40、ges in their states are propagated to the view subsystemsModel-View-Controller StyleComponentsModel components are responsible for maintaining domain knowledge and notify view of changes View components are responsible for displaying information to the user and send user gestures to controllerContro

41、ller Changes the state of the modelMaps user actions to model updates Selects view for responseConnectors: Procedure calls, Messages, Events, Direct memory accesses.Applications of MVCSuitable for applications:Changes to user interface should be easy and possible at run-time.Adapting or porting the

42、user interface should not impact the design or code in the functional part of the application.Examples:Web applicationsModel-View-ControllerAdvantages:Allows multiple, independent views of the same modelViews can be synchronized“Pluggable” views and controllersDisadvantages:Increased complexityIneff

43、iciency of data access in viewNot particularly compatible with modern user interface tools.Model-View-Controller Style SpecializationsWeb MVCNo Change Notification Needed!XNot Web Layered VS MVCLayeredDifferent abstract levelPresentation/logic/Model is not necessaryProtocols are stableReusable, modi

44、fiability of all layersDIP、POJO, VO usedMVCDifferent concernsModels are stableViews and controllers modifiabilityController, observer, strategy usedPresentation/logic/Model Layer MVCWeb Layered VS MVCWeb LayeredDifferent abstract levelPresentation/logic/Model is not necessaryProtocols are stableReus

45、able, modifiability of all layersWeb MVCDifferent concerns (technologies)HTML, Servlet, JavaBeanModels are stableViews and controllers modifiabilityPresentation/logic/Model Layer MVCImplementation of styles with procedure calls分別使用主程序-子路徑、面向?qū)ο笫?、分層、MVC 風(fēng)格實(shí)現(xiàn)銷售功能的概要設(shè)計(jì):收銀員輸入會(huì)員標(biāo)識(shí),系統(tǒng)顯示會(huì)員信息收銀員輸入商品標(biāo)識(shí),系統(tǒng)記錄商品

46、,并顯示商品信息,商品信息包括系統(tǒng)顯示已購入的商品清單,商品清單包括收銀員重復(fù)2-3步,直到完成所有商品的輸入收銀員結(jié)束輸入,系統(tǒng)計(jì)算并顯示總價(jià),計(jì)算根據(jù)總額特價(jià)策略進(jìn)行收銀員請(qǐng)顧客支付賬單顧客支付,收銀員輸入收取的現(xiàn)金數(shù)額系統(tǒng)給出應(yīng)找的余額,收銀員找零系統(tǒng)記錄銷售信息、商品清單、贈(zèng)送清單和賬單信息,并更新庫存和會(huì)員信息系統(tǒng)打印收據(jù)Pipe and Filter Architectural StyleComponents: called filters, apply local transformations to their input streams and often do their

47、computing incrementally so that output begins before all input is consumed.Connectors: called pipes, serve as conduits for the streams, transmitting outputs of one filter to inputs of another.ConstraintsFilters do not share state with other filters.Filters do not know the identity of their upstream

48、or downstream filters.The correctness of the output of a pipe and filter network should not depend on the order in which their filters perform their incremental processing.Applications of Pipe and FilterSuitable for applications that require a defined series of independent computations to be perform

49、ed on ordered data.Examples:Batch Sequential Programs.UNIX shell commandsdata. pl | grep i fdep | grep -v FDep | less Compilers: Lexical Analysis - parsing - semantic analysis - code generation Signal ProcessingPipe and Filter AdvantagesEasy to understand the overall input/output behavior of a syste

50、m as a simple composition of the behaviors of the individual filters.They support reuse, since any two filters can be hooked together, provided they agree on the data that is being transmitted between them.Systems can be easily maintained and enhanced, since new filters can be added to existing syst

51、ems and old filters can be replaced by improved ones.They permit certain kinds of specialized analysis, such as throughput and deadlock analysis.The naturally support concurrent execution.Pipe and Filter DisadvantagesNot good for handling interactive systems, because of their transformational charac

52、ter.Transferring data need additional space Excessive parsing and unparsing leads to loss of performance and increased complexity in writing the filters themselves.Pipe and Filter SpecializationsPipelinesRestricts topologies to linear sequences of filters.Batch SequentialA degenerate case of a pipel

53、ine architecture where each filter processes all of its input data before producing any output.Implementation of Pipe-Filter StyleFilter: package/ component(UML)Pipe(1) OS Pipe (2) Configure, IO 并發(fā)控制;數(shù)據(jù)資源保護(hù)(3) Complex Logic: Adapter, Delegator or MediatorWith Configure and IO Replication 邏輯上Filter之間

54、完全獨(dú)立物理上,并不一定獨(dú)立Implicit invocation (Event based ) StyleComponents: agent (objects, procedures, processes)Connectors: broadcast mediums (Events Handler)RulesInstead of invoking a procedure directly . A component can announce (or broadcast) one or more events.Other components in the system can register

55、 an interest in an event by associating a procedure with the event.When an event is announced, the broadcasting system (connector) itself invokes all of the procedures that have been registered for the event.ConstraintsAnnouncers of events do not know which components will be affected by those event

56、s.Components cannot make assumptions about the order of processing.Components cannot make assumptions about what processing will occur as a result of their events (perhaps no component will respond).Applications of Implicit InvocationSuitable for applications that involve loosely-coupled collection

57、of components, each of which carries out some operation and may in the process enable other operations.Examples debugging systems (listen for particular breakpoints) database management systems (for data integrity checking) graphical user interfacesImplicit Invocation AdvantagesProvides strong suppo

58、rt for reuse since any component can be introduced into a system simply by registering it for the events of that system.Eases system evolution since components may be replaced by other components without affecting the interfaces of other components in the system.Implicit Invocation DisadvantagesAssu

59、rance of completeness and correctness is difficultHard to test and diagnoseWhen a component announces an event:it has no idea what other components will respond to it,it cannot rely on the order in which the responses are invoked,it cannot know when responses are finished.Implementation of Implicit

60、Invocation StyleAgent: Package / component(UML)Event broadcasterA managerDictionary Management“Call Back”register; unregister; announce; notifyEvent (exception) TreeEvent (exception) PackageReplication 邏輯上Agent之間完全獨(dú)立, 物理上不一定Repository (Blackboard) StyleComponents:A central data structure representin

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論