版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、软件体系结构及应用软件体系结构及应用 5 5 过程调用体系结构风格过程调用体系结构风格 主要内容 主要内容 n5.1 5.1 主程序主程序- -子过程风格子过程风格 n5.2 5.2 面向对象风格面向对象风格 n5.3 5.3 数据流风格与调用返回风格的对比分析数据流风格与调用返回风格的对比分析 5.1 主程序-子过程风格 Main program and subroutine 主程序-子过程风格的直观表示 结构化软件设计中的“结构图(Structure Chart, SC)” 简化的结构图(SC) n你对此应该很熟悉 结构树or菜单树 n结构图(Structure Chart):用来表达软
2、件的组成模块及其之 间的“调用-返回” 关系。 SC中的基本要素 n模块模块(module)(module):是软件空间的术语,实现特定的功能,:是软件空间的术语,实现特定的功能, 有明确的输入、内部处理逻辑、输出。有明确的输入、内部处理逻辑、输出。 形式:返回值类型函数名(参数类型1 参数名1,参数类型2 参数 名2, ) n调用关系调用关系(invocation)(invocation):模块之间如何通过:模块之间如何通过“函数调用函数调用” 的方式建立连接。的方式建立连接。 形式:g() rtn = f(p1,p2,); n数据流:模块之间相互调用时所传递的业务类数据,分数据流:模块之间
3、相互调用时所传递的业务类数据,分 为两类为两类( (输入数据输入数据- -参数;输出数据参数;输出数据- -返回值返回值) )。 形式:简单数据类型、复杂数据类型(结构体); n标志流:模块之间相互调用时所传递的标志性数据标志流:模块之间相互调用时所传递的标志性数据 形式:“Y”/“N”、“T”/“F”、状态标志、循环变量等; 结构图(SC)中的模块类型 n越底层的模块,越接近系统边界(软件使用者、其他 软件、其他硬件、操作系统、文件、数据库、用户界 面),模块的粒度越小。 n越高层的模块,越接近系统的核心处理逻辑,模块的 粒度越大。 结构图(SC)中的模块类型(1):传入模块 n传入模块:
4、从下属模块取得数据,经过某些处理, 再将其传送给上级模块。 它传送的数据流叫做逻辑输入数据流。 void k () . int d = f(); . int f() . int d = g(); int d = HelloWorld (d); return d 结构图(SC)中的模块类型(2):传出模块 n 传出模块: 从上级模块获得数据,进行某些处理, 再将其传送给下属模块。 它传送的数据流叫做逻辑输出数据流。 void k () . int d = ; f(d); . void f(int d) . int d = HelloWorld (d); g(d); 结构图(SC)中的模块类型(3
5、):变换模块 n变换模块: 从上级模块取得数据,进行特定的处理,转换成其它形 式,再传送回上级模块。 它加工的数据流叫做变换数据流。 void k () . int d = ; int d = f(d); . int f(int d) . int d = HelloWorld (d); return d; 结构图(SC)中的模块类型(4):协调(控制) 模块 n协调(控制)模块: 对所有下属模块进行协调和管理。 void f () . int d1 = k1(); int d2 = HelloWorld1 (d1); int d3 = k2(d2); int d4 = HelloWorld2
6、(d2, d3); k3(d4); . 结构图(SC)中的模块类型(5):源模型和漏 模块 n源模块: 不调用其他模块的传入模块, 只适用于传入部分的开始端; void k () . int d = f(); . n漏模块: 不调用其它模块的传出模块, 只适用于传出部分的末端。 void k () . f(d); . SC图中的模块调用(连接件) n简单调用 n选择调用 n循环调用 SC图中的模块调用 n选择调用 void A () if (condition1 = TRUE) B(); if (condition2 = TRUE) C(); else D(); n循环调用 void A ()
7、 while (condition = TRUE) B(); C(); 回顾:非结构化的程序 nAll the program code written in a single All the program code written in a single continuous main program (continuous main program (所有的程序代码均包含所有的程序代码均包含 在一个主程序文件中在一个主程序文件中). ). nDisadvantages for large programs (Disadvantages for large programs (缺陷缺陷):
8、 ): difficult to follow logic (逻辑不清) if something needs to be done more than once must be re-typed (无法复用) hard to incorporate other code (难以与其他代码合并) not easily modified (难于修改) difficult to test particular portions of the code (难以测 试特定部分的代码) 结构化程序:自上而下的设计(TOP- DOWN DESIGN) 结构化程序:逐层分解(HIERARCHICAL DEC
9、OMPOSITION) nThe system is designed from a functional viewpoint, The system is designed from a functional viewpoint, starting with a high-level view and progressively refining starting with a high-level view and progressively refining this into a more detailed design (this into a more detailed desig
10、n (从功能的观点设计系统从功能的观点设计系统) ) nThis methodology is exemplified by Structured Design and This methodology is exemplified by Structured Design and stepwise refinement (stepwise refinement (结构化设计与逐步细化结构化设计与逐步细化) ) nHierarchical decomposition (Hierarchical decomposition (逐步分解逐步分解): ): Based on definition-u
11、se relationship (基于“定义使用”关 系) Uses procedure call as interaction mechanism (用过程调用作 为交互机制) Correctness of a subroutine depend on the correctness of the subroutines it calls (主程序的正确性依赖于它所调用的子 程序的正确性) 主程序-子过程风格的基本构成 nComponent (Component (构件:主程序、子程序构件:主程序、子程序) ) Main program and subroutines, hierarchic
12、ally decomposing a program nConnector(Connector(连接器:调用连接器:调用- -返回机制返回机制) ) Call-return mechanism, each component get control and data from its parent and pass it to children. nTopology(Topology(拓扑结构:层次化结构拓扑结构:层次化结构) ) Hierarchical structure n本质:将大系统分解为若干模块(模块化),主程序调 用这些模块实现完整的系统功能。 主程序-子过程风格的优点与缺点 n
13、Advantage:Advantage: This has proved to be a highly successful design methodology. It has allowed the development of large programs (100,000 lines or more of source code). (已被证明 是成功的设计方法,可以被用于较大程序) nDisadvantages:Disadvantages: However, as program size increases beyond this point (100,000 lines), th
14、e approach performs poorly. (程序超过10 万行,表现不好) We observe that code development becomes too slow and that it becomes increasingly difficult to test the software and guarantee its reliability. (程序太大,开发太慢,测试越 来越困难) 关键问题:如何对系统进行分解 n主程序-子过程风格的基本构件是一个个大小不一的子程 序; n那么, 如何将一个大系统分解为若干个子程序? 分解的标准是什么? 子程序如何聚合为模块
15、? n四大原则: 模块独立性:高内聚、低耦合(high cohesion and low coupling) 模块规模要适中:过大:分解不充分,难理解;太小: 开销过大、接口复杂 模块复用度要好:高扇入、低扇出; 作用域与控制域原则:模块的作用域要包含在控制域之 中。 5.2 面向对象风格 OO SYSTEMS OBJECT-ORIENTED STYLE The system is viewed as a collection of objects rather than as functions with messages passed from object to object. (系统被
16、看作对象的集合) Each object has its own set of associated operations (每个对象都有一个它自己的功能集合。 数据及作用在数据上的操作被封装成抽象数据类型 对象) 主程序-子过程VS. 面向对象:二者的本 质区别 n面向过程的结构化系统= 功能+ 数据 n面向对象的系统= 对象+ 消息 主程序-子过程VS. 面向对象:二者的本 质区别 OO的基本原理:ABSTRACT DATA TYPE (ADT) nAbstract data types (ADTs) are a mathematical specification of a set of
17、 data and the set of operations that can be performed on the data. (ADT:一种数学规约, 包含一组数据以及作用于这组数据上的操作) ADT is a kind of data abstraction. (ADT是一种对数据的抽 象) The actual implementation is not defined, and does not affect the use of the ADT. (虽然ADT具体的实现并没有被定义, 但不会影响ADT的使用) ADT的优点 nThe implementation is hidd
18、en from the user. (ADT的实现 对用户隐藏) nOnly the interface is published. (仅有接口被发布) nThis means that the ADT can be implemented in various ways, but as long as it adheres to the interface, user programs are unaffected. (ADT可有多种实现方式,只 要与接口一致,用户程序可不受影响) DATA ABSTRACTION OR OBJECT- ORIENTED ELEMENTS OF OBJECT
19、 ARCHITECTURES nEncapsulation: Restrict access to certain information (封装:限制对 某些信息的访问) nInteraction: Via procedure calls or similar protocol (交互:通过过程 调用或类似的协议) nPolymorphism: Choose the method at run-time (多态:在运行时选 择具体的操作) nInheritance: Keep one definition of shared functionality (继承:对共 享的功能保持唯一的接口)
20、 nDynamic binding: Determine actual operation to call at runtime(动态 绑定:运行时决定实际调用的操作) nReuse and maintenance: Exploit capsulation and locality (复用和维护) CHARACTERISTICS OF OBJECT ARCHITECTURES nInformation hidding (Information hidding (信息隐藏信息隐藏) ) encapsulation based on hiding of design “secrets” (只通过接
21、 口与外界交互,内部的设计决策则被封装起来) nHide data representation (Hide data representation (隐藏数据表示隐藏数据表示) ) ADT view: enforce boundaries of abstraction by hiding data representation (通过隐藏数据表示来增强抽象度) Maintain integrity of data representation (维护数据表达格 式的完整性) nModel the real world (Model the real world (模拟现实世界模拟现实世界)
22、) Program with nouns not verbs (对名词而不是对动词编程) Entities defined by actions it suffers and requires (每个对 象也定义了它所能执行的动作,以及可以作用在它上面的动作) OO基本构成 nComponent: classes and objects (Component: classes and objects (OOOO风格的构件是:风格的构件是: 类和对象类和对象) ) nConnectors: objects interact through function and Connectors: obj
23、ects interact through function and procedure invocations. (procedure invocations. (连接件:对象之间通过功能连接件:对象之间通过功能 与函数调用实现交互与函数调用实现交互) ) 类的内部结构:属性和操作 n属性(Attribute)(Attribute):描述对象静态特性的数据项;:描述对象静态特性的数据项; n操作(Operation)(Operation):描述对象动态特性的一个动作;:描述对象动态特性的一个动作; 类的内部结构:属性和操作 OO案例:大学选课系统 ADVANTAGES OF OO Reuse
24、 and maintenance: Exploit encapsulation and locality to increase Reuse and maintenance: Exploit encapsulation and locality to increase productivity (productivity (复用和维护:利用封装和聚合提高生产力复用和维护:利用封装和聚合提高生产力) ) Real world mapping: For some systems, there may be an obvious Real world mapping: For some system
25、s, there may be an obvious mapping from real world entities to system objects (mapping from real world entities to system objects (反映现实世界反映现实世界) ) Easy decomposition of a system: the bundling of a set of accessing Easy decomposition of a system: the bundling of a set of accessing routines with the data they manipulate allows designers to decompose routines with the data they manipulate allows designers to decompose problems into collections of interacting agents. (pr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 合成膜电位器工安全应急强化考核试卷含答案
- 啤酒糖化工安全行为模拟考核试卷含答案
- 热敏电阻红外探测器制造工操作能力强化考核试卷含答案
- 井下作业机司机安全宣教模拟考核试卷含答案
- 火工品装配工QC管理知识考核试卷含答案
- 野炊作文好开头
- 和老板请假条格式
- 2025年微信生态合作协议书
- 2026年近零碳排放园区改造项目评估报告
- 2026年燃料电池项目公司成立分析报告
- 2026年年长租公寓市场分析
- 生态环境监测数据分析报告
- 金融机构衍生品交易操作规范
- 医院检查、检验结果互认制度
- 2025年医院物价科工作总结及2026年工作计划
- 2025年下半年四川成都温江兴蓉西城市运营集团有限公司第二次招聘人力资源部副部长等岗位5人考试参考试题及答案解析
- 2025-2026学年上学期成都小学数学四年级期末典型卷1
- 八年级历史上册小论文观点及范文
- 重庆康德卷2025-2026学年高一数学第一学期期末达标检测试题含解析
- 2026年江西应用技术职业学院单招职业适应性测试必刷测试卷必考题
- 浙江省杭州市萧山区2024-2025学年六年级上学期语文期末试卷(含答案)
评论
0/150
提交评论