面向对象技术

上传人:壹****1 文档编号:571163970 上传时间:2024-08-09 格式:PPT 页数:67 大小:1.96MB
返回 下载 相关 举报
面向对象技术_第1页
第1页 / 共67页
面向对象技术_第2页
第2页 / 共67页
面向对象技术_第3页
第3页 / 共67页
面向对象技术_第4页
第4页 / 共67页
面向对象技术_第5页
第5页 / 共67页
点击查看更多>>
资源描述

《面向对象技术》由会员分享,可在线阅读,更多相关《面向对象技术(67页珍藏版)》请在金锄头文库上搜索。

1、Institute of Computer Software, Nanjing University面向对象技术1相关信息2024/8/9Institute of Computer SoftwareNanjing University2教师:余萍Email: Office: 蒙民伟楼610A助教课程网页:http:/ of Computer SoftwareNanjing University4课程简介 “选不选这门课?”背景概述“所学内容在专业知识结构中的位置?”欢迎选修“面向对象技术”!2024/8/9Institute of Computer SoftwareNanjing Univer

2、sity5通过选修本课程,可以更深入地掌握面向对象的基本原理更广泛地了解面向对象的新兴技术更自信地面对实际开发的技术需求获取 3 个学分课程性质2024/8/9Institute of Computer SoftwareNanjing University6不是又一门语言/编程课虽然在C+/Java 之外还会提到别的语言,如Eiffel不是一般意义上的软件工程课但讲授面向对象软件开发的实用技术不属于理论计算机科学但会利用一些较成熟易用的理论工具课程目标2024/8/9Institute of Computer SoftwareNanjing University7用OOPL写代码 OOP OO

3、SC朴素的OOP 系统化的OOP传统OO技术 现代的OO技术Beyond OO课程内容2024/8/9Institute of Computer SoftwareNanjing University8主要包括但不限于:面向对象的起源及其动机面向对象技术的核心概念和基本原理Object, Class, Encapsulation, Polymorphism, Abstract Data Type, Design by Contract, Garbage Collection, Exception Handling, 面向对象技术的应用Design Patterns, Application Fr

4、ameworks 面向对象的发展并发、分布对象计算、服务计算,面向对象分析/开发/测试AOP教材与参考资料2024/8/9Institute of Computer SoftwareNanjing University9徐家福, 王志坚, 翟成祥 等,对象式程序设计语言对象式程序设计语言, 南京大学出版社,1993年2月。Bertrand Meyer, Object-Oriented Software Construction, Second Edition, Prentice Hall, 1997. 清华大学出版社影印。Jolt Award 1998教材与参考资料2024/8/9Instit

5、ute of Computer SoftwareNanjing University10Richard Mitchell and Jim Mckim. Design by Contract, by Example. Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, Design Patterns: Elements of Reusable Object-Oriented software, Addison-Wesley , 1994.Craig Larman, Applying UML and Patterns, Pren

6、tice Hall PTR, 2nd edition. 2001. Clemens Szyperski. Component Software: Beyond Object-Oriented Programming. Addison-Wesley, 2nd edition, 2002.授课方式2024/8/9Institute of Computer SoftwareNanjing University11LectureSeminar考核方式2024/8/9Institute of Computer SoftwareNanjing University12笔试 50%开卷 or 闭卷?平时 5

7、0%其中书面作业 25% (态度第一)开发练习 25% (一个月后公布具体要求)主动主动Presentation 约约 20-30 (额外加分额外加分)理论探索,学习心得,实践经验理论探索,学习心得,实践经验 均可均可有何建议2024/8/9Institute of Computer SoftwareNanjing University13课程内容?授课方式?考核方式?其他?背景概述摘要2024/8/9Institute of Computer SoftwareNanjing University15从软件到软件工程软件质量前对象时代结构化程序设计面向对象思想的兴起模块化软件复用软件2024/

8、8/9Institute of Computer SoftwareNanjing University16概念一系列按照特定顺序组织的数据和指令的集合程序+文档程序:计算任务的处理对象和处理规则的描述文档:为了便于了解程序所需的阐明性资料特点本质上是逻辑产品现实中受多方制约软件:逻辑产品2024/8/9Institute of Computer SoftwareNanjing University17基础:图灵机,1936冯诺依曼结构,1945Alan Turing: 抽象计算模型(数学逻辑机)软件:逻辑产品2024/8/9Institute of Computer SoftwareNanji

9、ng University18存储程序计算机在体系结构上主要特点有:以运算单元为中心 采用存储程序原理 存储器是按地址访问、线性编址的空间 控制流由指令流产生 指令由操作码和地址码组成 数据以二进制编码 软件:多方制约2024/8/9Institute of Computer SoftwareNanjing University19作为一种“工程”目的性资源物理运行平台工程问题质量、生产率根源:复杂性软件工程:将系统化的、规范的、可度量的方法应用于软件的开发、运行和维护的过程,即将工程化应用于软件中。1969,NATO会议软件危机软件2024/8/9Institute of Computer

10、SoftwareNanjing University20通常而言,“质量”与“生产率”是一对矛盾我们首先来考虑“质量”。有趣的是,在软件领域,对“质量”的重视有时竟然会带来“生产率”的提升!说明软件工程远未成熟,二者的“共同底线”还未达到。软件质量2024/8/9Institute of Computer SoftwareNanjing University21何谓“质量”?产品或工作的“优劣程度”何为“优”?何为“劣”?可从“外部” 和 “内部” 两个不同的侧面来考察软件产品 (Meyer, McCall)外部质量因素:用户直接感觉到的内部质量因素:用户不能直接发觉,体现在软件“文本”(源码

11、、设计报告、分析报告等)中Being modular; readable外部质量因素2024/8/9Institute of Computer Software, Nanjing University22Correctness 正确性依据规约 完成任务Robustness 鲁棒性异常情况 合理反应Integrity 完整性非法访问或修改 合理反应Extendibility 易扩展性软件产品 应 规约改变 而 改变Reusability 易复用性软件模块 用于构建多种不同应用Reliability RobustnessSPECIFICATIONCorrectnessIntegrity外部质量因素

12、2024/8/9Institute of Computer SoftwareNanjing University23Compatibility 兼容性软件模块相互组合的难易 Efficiency 高效性尽量少地使用硬件资源 处理器时间 内存 外存 网络带宽 等Portability 易移植性转换到不同的软硬件平台上Ease of use 易用性不同背景的用户学习使用软件产品解决问题的难易外部质量因素2024/8/9Institute of Computer SoftwareNanjing University24Functionality 功能Timeliness按时交付Verifiabili

13、ty, Reparability, Economy维护费用分类2024/8/9Institute of Computer SoftwareNanjing University25Lientz 198070% of the cost of software is devoted to maintenance!Tradeoffs2024/8/9Institute of Computer SoftwareNanjing University26鱼与熊掌不可得兼权衡 折中软件技术研究的常见主题:在何种条件下 以何种方式 鱼与熊掌可以得兼?在何种条件下 拿部分鱼换取更多熊掌?何时反之?Key Conce

14、rnsReliability correctness + robustness: It should be easier to build software that functions properly, and easier to guarantee what it does. Modularity reusability + extendibility: We should build less software! Software should be easier to modify. 2024/8/9Institute of Computer Software, Nanjing Un

15、iversity27应对软件危机2024/8/9Institute of Computer SoftwareNanjing University28开发的角度:分析、设计方法的研究前对象时代Structured Programming, Design, Analysis管理的角度:软件开发过程的工程化生命周期模型瀑布模型,快速原型法,螺旋模型,喷泉模型等应对复杂性的基本途径2024/8/9Institute of Computer SoftwareNanjing University29“元方法”Decomposition 分而治之Abstraction抓本质,抓重点Hierarchy 应对大

16、系统,纲举目张复杂性是软件开发过程中所固有的特质。Booch94结构化开发方法2024/8/9Institute of Computer SoftwareNanjing University30何谓“结构化”?结构化程序设计设计过程 程序组织 语句构造 结构化 结构化分析设计数据流图 数据字典 模块结构图结构化的好处科学化 可读性 模块化模块化 信息隐蔽.结构化开发方法2024/8/9Institute of Computer SoftwareNanjing University31自顶向下(Top-down) 的功能设计ABDCC1 I1C2 I2 ITopmost functional a

17、bstractionLoopConditionalSequence自顶向下,逐步求精软件生命周期模型2024/8/9Institute of Computer Software, Nanjing University32FEASIBILITY STUDYREQUIREMENTS ANALYSISSPECIFICATIONGLOBAL DESIGNDETAILED DESIGNIMPLEMENTATIONDISTRIBUTIONVALIDATION & VERIFICATION瀑布型PROJECT PROGRESSThe activities are necessary.(But: mergin

18、g of middle activities.)The order is the right one.The waterfall model of the lifecycle2024/8/9Institute of Computer Software, Nanjing University33FEASIBILITY STUDYREQUIREMENTS ANALYSISSPECIFICATIONGLOBAL DESIGNDETAILED DESIGNIMPLEMENTATIONDISTRIBUTIONVALIDATION & VERIFICATIONPROJECT TIMEDESIGN AND

19、IMPLEMENTATIONProblems with the waterfallLate appearance of actual code.Lack of support for requirements change and more generally for extendibility and reusability.Lack of support for the maintenance activity (70% of software costs).Division of labor hampering Total Quality Management.Impedance mis

20、matches.Highly synchronous model.2024/8/9Institute of Computer Software, Nanjing University34WARNING: The waterfall model is not the recommended process model for O-O developmentQuality Control?2024/8/9Institute of Computer Software, Nanjing University35AnalystsDesignersImplementersTestersCustomersI

21、mpedance mismatches36As Management requested it.As the Project Leader defined it.As Systems designed it.As Programming developed it.As Operations installed it.What the user wanted.软件模块化2024/8/9Institute of Computer SoftwareNanjing University37概念模块(module): “Self-Contained”; well-defined interfaces模块

22、化(modular): 软件构造为一组“模块”之有序组合,从而易于装配、易于修补替换模块。Extendibility 和 Reusability 的要求;模块化是上述“元方法”的推论。什么样的方法是“模块化”的?目标(Five Criteria)规则(Five Rules)原则(Five Principles)Five Criteria2024/8/9Institute of Computer SoftwareNanjing University38Decomposability 易分解性Composability 易组合性Understandability 易理解性Continuity 连续

23、性Protection 保护性易分解性 Decomposability2024/8/9Institute of Computer SoftwareNanjing University39Method helps decompose complex problems into subproblems. COROLLARY: Division of labor. Counter-example: General initialization module.易组合性 Composability2024/8/9Institute of Computer SoftwareNanjing Universi

24、ty40Method favors production of software elements that may be freely combined with each other to produce new software.Example: Unix shell conventionsProgram1 | Program2 | Program3易理解性 Understandability2024/8/9Institute of Computer SoftwareNanjing University41模块应可单独理解不能牵涉太广自描述Counter example: sequent

25、ial dependencies A|B|C连续性 Continuity2024/8/9Institute of Computer SoftwareNanjing University42Method ensures that small changes in specifications yield small changes in architecture.Design method: Specification ArchitectureExample: Principle of Uniform Access (see next) Counter example: static array

26、sThe Principle of Uniform AccessFacilities managed by a module are accessible to its clients in the same way whether implemented by computation or by storage.Definition: A client of a module is any module that uses its facilities.2024/8/9Institute of Computer SoftwareNanjing University43Uniform Acce

27、ss: An examplebalance = list_of_deposits.total list_of_withdrawals.total2024/8/9Institute of Computer SoftwareNanjing University44list_of_depositslist_of_withdrawalsbalancelist_of_depositslist_of_withdrawals(A2)(A1)Ada, Pascal, C/C+, Java, C#: Simula, Eiffel:A1: a.balancea.balanceA2: balance (a) a.b

28、alance()思考:C+和Java如何实现?模块保护 Protection2024/8/9Institute of Computer SoftwareNanjing University45异常不扩散 扩散范围有限Example: validating input at the sourceCounter example: undisciplined exceptionsProtection violationFive Rules2024/8/9Institute of Computer SoftwareNanjing University46Direct Mapping 直接映射Few I

29、nterfaces 接口要少Small Interfaces 接口要小Explicit Interfaces 接口要明确Information Hiding 信息隐蔽降低耦合度直接映射 Direct mapping2024/8/9Institute of Computer SoftwareNanjing University47Method yields software systems whose modular structure remains compatible with any modular structure devised in the process of modeling

30、 the problem domain.Structure of the problemStructure of the solutiondirect mappingmodelsoftwareFew interfaces2024/8/9Institute of Computer SoftwareNanjing University48Every module communicates with as few others as possible.(A)(B)(C)n-1n(n-1)/2n-1Small interfaces2024/8/9Institute of Computer Softwa

31、reNanjing University49If two modules communicate, they exchange as little information as possible.x, yzExplicit interfaces2024/8/9Institute of Computer SoftwareNanjing University50Whenever two modules A and B communicate, this is obvious from the text of A or B or both.Counter example: data sharingM

32、odule AModule BData itemxModifiesAccessesInformation hiding2024/8/9Institute of Computer SoftwareNanjing University51Underlying question: how does one “advertise” the capabilities of a module? Every module should be known to the outside world through an official, “public” interface. The rest of the

33、modules properties comprises its “secrets”.It should be impossible to access the secrets from the outside. Information Hiding2024/8/9Institute of Computer SoftwareNanjing University52The designer of every module must select a subset of the modules properties as the official information about the mod

34、ule, to be made available to authors of client modules.Secret partPublic partInformation hiding2024/8/9Institute of Computer SoftwareNanjing University53理由:模块连续性亦有助于 Decomposability,Composabilty, Understandability等模块用户只需关注public的部分模块2024/8/9Institute of Computer SoftwareNanjing University54模块的根本特征是“

35、相对独立,功能单一”。换言之,一个好的模块必须具有高度的独立性和相对较强的功能。“耦合度”和“内聚度”耦合度,是指模块之间相互依赖性大小的度量,耦合度越小,模块的相对独立性越大。内聚度,是指模块内各成份之间相互依赖性大小的度量,内聚度越大,模块各成份之间联系越紧密,其功能越强。在模块划分应当做到“耦合度尽量小,内聚度尽量大”。 Five PrinciplesLinguistic Modular UnitsSelf-DocumentationUniform AccessOpen-ClosedSingle-Choice2024/8/9Institute of Computer Software,

36、Nanjing University55主要是程序设计语言的设计原则软件复用2024/8/9Institute of Computer SoftwareNanjing University56为什么要复用?复用什么?问题非技术技术解决途径?为什么要“复用”2024/8/9Institute of Computer SoftwareNanjing University57“懒惰”提高生产率改善质量 复用什么2024/8/9Institute of Computer SoftwareNanjing University58人设计,规约 设计模式 体系结构 应用框架源码级复用封装模块 (抽象描述)非

37、技术障碍2024/8/9Institute of Computer SoftwareNanjing University59心理 不信任旧习惯短期利益构件检索 构件发布 与 商业模型技术问题2024/8/9Institute of Computer SoftwareNanjing University60复用的本质困难通常不能一成不变地拿来就用ReusabilityExtensibility软件的开放性要求和封闭性要求之间的冲突对象技术比传统技术有明显改善传统技术复用支持2024/8/9Institute of Computer SoftwareNanjing University61过程 R

38、outine 成功应用:数值计算函数库问题明确 规约简单问题相互独立数据结构相对简单不足:对adaption的支持弱若要一个routine支持多种variants 则需好多参数一个routine支持一种variant则没有factoring out common behaviors.传统技术复用支持2024/8/9Institute of Computer SoftwareNanjing University62包 packageLinguistic Modular UnitFeatures (变量 过程)信息隐蔽单独编译Encapsulation languages (“Object-bas

39、ed”)Ada, Modula-2, CLU. Basic idea: gather a group of routines serving a related oo-purpose, such as has, insert, remove etc., together with the appropriate data structure descriptions. Advantages: For supplier author: Get everything under one roof. Simplifies configuration management, change of imp

40、lementation, addition of new primitives. For client author: Find everything at one place. Simplifies search for existing routines, requests for extensions. 2024/8/9Institute of Computer Software, Nanjing University63传统技术复用支持包 作为 复用单元的 不足类型、模块分离多类型支持?Factoring out commonality?2024/8/9Institute of Com

41、puter Software, Nanjing University64小结2024/8/9Institute of Computer SoftwareNanjing University65构建高质量的软件系统是我们的目标随着软件的广泛应用及其规模的不断增长,软件的易扩展性和易复用性愈发关键在模块化和复用性两个方面传统技术存在不足面向对象模型提供了较好的解决方案作业1.发送邮件To: 主题: 选修面向对象技术内容:姓名和学号需不需要这门课的学分对课程内容、授课方式、考试方式等的任何建议2024/8/9Institute of Computer Software, Nanjing University66作业2024/8/9Institute of Computer SoftwareNanjing University672.使用Wikipedia,查阅以下一些词条并翻译1.Programming paradigm2.Structured Programming3.Object-Oriented Programming注意:Wikipedia是一个重要的信息源。科技类词条的可靠性很高,虽然未必详尽。但亦不可尽信,不可作为严谨学术研究的文献依据。PS: 作业提交方式:纸面或电子邮件

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 幼儿/小学教育 > 幼儿教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号