1、1,Chapter 9,Architectural Design,Software Engineering: A Practitioners Approach, 7/e by Roger S. Pressman,2,Why Architecture?,The architecture is not the operational software. Rather, it is a representation that enables a software engineer to: (1) analyze the effectiveness of the design in meeting i
2、ts stated requirements, (2) reduce the risks associated with the construction of the software. (3) representations of software architecture are an enabler for communication between all parties (stakeholders) interested in the development of a computer-based system. (4) the architecture highlights ea
3、rly design decisions that will have an impact on all software engineering.,3,What Is Architecture?,The software architecture of a program or system is the structure of the system, which comprise software components, the external visible properties of those components, and the relationships among the
4、m.,4,Architectural Descriptions,The IEEE Computer Society has proposed IEEE-Std-1471-2000, Recommended Practice for Architectural Description of Software-Intensive System, IEE00 to establish a conceptual framework and vocabulary for use during the design of software architecture, to provide detailed
5、 guidelines for representing an architectural description The IEEE Standard defines an architectural description (AD) as a “a collection of products to document an architecture.”,5,Architectural Styles,Data-centered architectures Data flow architectures Call and return architectures Object-oriented
6、architectures Layered architectures,6,Data-Centered Architecture,7,Data Flow Architecture,8,Call and Return Architecture,9,Layered Architecture,10,Architectural Descriptions-Example,分层技术架构,11,Architectural Descriptions-Example,平台功能架构,12,Architectural Design,The software must be placed into context(环
7、境) the design should define the external entities (other systems, devices, people) that the software interacts with and the nature of the interaction A set of architectural archetypes(原型) should be identified An archetype is an abstraction (similar to a class) that represents one element of system b
8、ehavior The designer specifies the structure of the system by defining and refining(精炼) software components that implement each archetype,13,Architectural Context,14,Define Archetype,15,Component Structure,16,Refined Component Structure,17,ADL,Architectural description language (ADL) provides a sema
9、ntics and syntax for describing a software architecture Provide the designer with the ability to: decompose architectural components compose individual components into larger architectural blocks and represent interfaces (connection mechanisms) between components.,18,An Architectural Design Method,表
10、示层,业务逻辑层,数据存储层,客户管理模块,表示层,业务逻辑层,数据存储层,订单管理模块,表示层,业务逻辑层,数据存储层,库存管理模块,1、垂直方向功能分解块,2、水平方向服务分层层,19,An Architectural Design Method,20,An Architectural Design Method,“four bedrooms, three baths,”,customer requirements,architectural design,21,Deriving Program Architecture,22,Partitioning the Architecture,“
11、horizontal” and “vertical” partitioning are required,23,Vertical(垂直) Partitioning,define separate branches of the module hierarchy for each major function use control modules to coordinate communication between functions,24,Horizontal(水平) Partitioning,design so that decision making and work are stra
12、tified(分层) decision making modules should reside at the top of the architecture,25,Why Partitioned Architecture?,results in software that is easier to test leads to software that is easier to maintain results in propagation(传播) of fewer side effects results in software that is easier to extend,26,St
13、ructured Design,objective: to derive a program architecture approach: a DFD is mapped into a program architecture the PSPEC and STD are used to indicate the content of each module notation: structure chart,27,Flow Characteristics,Transform flow(变换中心),Transaction,Flow(事务中心),This edition of SEPA does
14、not cover transaction mapping. For a detailed discussion see the SEPA website,28,General Mapping Approach,isolate incoming and outgoing flow,boundaries; for transform/transaction flows, isolate,the transform/transaction center,working from the boundary outward, map,DFD transform/transforms into corr
15、esponding modules,add control modules as required,refine the resultant program structure,using effective modularity concepts,29,General Mapping Approach,Isolate the transform/transform center by specifying incoming and outgoing flow boundaries Perform “first-level factoring.” The program architectur
16、e derived using this mapping results in a top-down distribution of control. Factoring leads to a program structure in which top-level components perform decision-making and low-level components perform most input, computation, and output work. Middle-level components perform some control and do mode
17、rate amounts of work. Perform “second-level factoring.“,30,First Level Factoring(变换中心),main,program,controller,input,controller,processing,controller,output,controller,31,Factoring,32,Transform Mapping,33,Second Level Mapping,First Level Factoring-事务中心,35,Factoring,监控传感器,36,First Level Factoring,37,
18、Second Level Mapping,38,Refining the Architectural Design,2018/10/10,39,结构图SC知识小结,SC的组成符号 矩形:表示模块 带箭头的连线:表示模块间的调用关系 SC允许的6种模块 (下图未画源模块和漏模块):传入、传出、加工、控制、源、漏,2018/10/10,40,结构图的6种模块,传入模块:从下属模块取得数据,经过某些处理,再将其传送给上级模块。 传出模块:从上级模块获得数据,进行某些处理,再将其传送给下属模块。 源模块:不调用其他模块的传入模块,用于始端; 漏模块:不调用其他模块的传出模块,用于传出部分的末端; 变换
19、模块(即加工模块):它从上级模块取得数据,进行特定处理,再传送回上级模块。 控制模块:对所有下属模块进行协调和管理。在系统的输入输出部分或数据加工部分可以找到这样的模块。,2018/10/10,41,结构图的三种调用表示,简单调用,选择调用和循环调用,2018/10/10,42,从DFD到SC映射的3个步骤,鉴别DFD的结构特征,确定它是变换中心还是事务中心。 按照SD的规则把DFD转换为初始的SC图。 按优化指导原则改进初始SC,获得最终SC。,2018/10/10,43,变换映射步骤1:划分变换边界,区分输入流、输出流和变换中心部分。不同设计人员可能选择不同的流边界,导致不同的结构图。,2
20、018/10/10,44,变换映射步骤2:建立初始SC,设计顶层和第一层模块。第一层模块与主模块之间传送的数据应与数据流图相对应。,2018/10/10,45,变换映射步骤3:分解结构图,输入模块:向它的上级模块提供数据,因而它必须有两个下属模块:一个接收数据;另一个把这些数据变换成它的上级模块所需的数据。 输出模块:从调用它的上级模块接收数据,用以输出,因而也应当有两个下属模块:一个将上级模块提供的数据变换成输出的形式;另一个将它们输出。 中心变换模块:其下层模块没有通用的设计方法,一般应参照数据流图的中心变换部分和功能分解的原则来考虑如何对中心变换模块进行分解。,2018/10/10,46
21、,变换映射图例,2018/10/10,47,变换映射图例,2018/10/10,48,事务映射步骤1: 确定事务中心,在DFD上划分3个部分 (事务中心、接受部分、发送部分),2018/10/10,49,事务映射步骤2:画出结构图框架,事务流映射到包含一个输入分支和一个分类事务处理分支结构(包含调度模块和所控制下属模块。,2018/10/10,50,事务映射步骤3:分解动作分支,分解和细化事务结构和每条操作路径的结构。每条操作路径的数据流图有它自己的信息流特征,可以是变换流也可以是事务流。与每条操作路径相关的子结构可以依照前面介绍的设计步骤进行设计。,2018/10/10,51,结构化设计优化
22、原则,由变换得到的初始结构图需要进一步细化和改进。优化原则如下:,规则1: 高模块独立性的原则:通过模块分割、合并和修改调用关系,提高内聚、降低耦合、简化接口。,2018/10/10,52,原则2:高扇入/低扇出的原则,扇入:调用一个给定模块的模块个数。 扇出:一个模块直接调用的模块个数。,扇入高则上级模块多,能增加模块的利用率;扇出低意味着需要控制和协调下属模块少,可减少模块调用和控制的复杂程度。,2018/10/10,53,原则3:深而窄结构的原则,2018/10/10,54,原则4:瓮型结构原则,好的软件系统具有两头小、中间大的结构。,2018/10/10,55,SD实例:教材购销系统,
23、销售子系统DFD,2018/10/10,56,教材购销系统例子(续),采购子系统的DFD,2018/10/10,57,教材购销系统例子(续),1、鉴别DFD的类型 图5.27的2个加工(1.1和1.6)是传入,2个(1.3和1.7)是传出,该图整体上属于事务型结构,但它的两个分支都具有变换型图结构。 5.28也是具有两个动作分支的事务型结构。,2018/10/10,58,教材购销系统例子(续),2、画出结构图的框架(只画到事务层),2018/10/10,59,教材购销系统例子(续),3、分解动作分支,补充动作层和细节层,2018/10/10,60,教材购销系统例子(续),2018/10/10,61,教材购销系统例子(续),4、改进结构图,获得最终结构图: 改进系统的上层框架(合并了两个事务层),2018/10/10,62,教材购销系统例子(续),改进“获得购/售书单”分支(细化有效性审查),2018/10/10,63,教材购销系统例子(续),合并子图,