软件系统设计与体系结构:Ch5 Software Architecture Styles_第1页
软件系统设计与体系结构:Ch5 Software Architecture Styles_第2页
软件系统设计与体系结构:Ch5 Software Architecture Styles_第3页
软件系统设计与体系结构:Ch5 Software Architecture Styles_第4页
软件系统设计与体系结构:Ch5 Software Architecture Styles_第5页
已阅读5页,还剩112页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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)逻辑设计是严格层次的物理包不是严格层次的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逻辑设计是严格层次的物理设计是非层次的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分别使用主程序-子路径、面向对象式、分层、MVC 风格实现销售功能的概要设计:收银员输入会员标识,系统显示会员信息收银员输入商品标识,系统记录商品

46、,并显示商品信息,商品信息包括系统显示已购入的商品清单,商品清单包括收银员重复2-3步,直到完成所有商品的输入收银员结束输入,系统计算并显示总价,计算根据总额特价策略进行收银员请顾客支付账单顾客支付,收银员输入收取的现金数额系统给出应找的余额,收银员找零系统记录销售信息、商品清单、赠送清单和账单信息,并更新库存和会员信息系统打印收据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 并发控制;数据资源保护(3) Complex Logic: Adapter, Delegator or MediatorWith Configure and IO Replication 逻辑上Filter之间

54、完全独立物理上,并不一定独立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之间完全独立, 物理上不一定Repository (Blackboard) StyleComponents:A central data structure representin

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论