南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)契约式设计 Design by Contract

Design by Contract 契约式设计 Institute of Computer Software 2021/1/30 Nanjing University
契约式设计 Design by Contract 2021/1/30 Institute of Computer Software Nanjing University

最病 过摘要 2 口引言 口Efe的DbC机制 口DbC与继承 口如何应用DbC Institute of Computer Software 2021/1/30 Nanjing University
摘要 引言 Eiffel 的 DbC 机制 DbC与继承 如何应用DbC 2021/1/30 Institute of Computer Software Nanjing University 2

最病 以引言 口 Design by Contract(DbC)契约式设计 口方法学层面的思想 ■以尽可能小的代价开发出可靠性出众的软件系统 ■Eif语言的直接支持 口 Bertrand Meyer:DbC是构建面向对象软件系统方法 的核心! 口 James mckim:“只要你会写程序,你就会写契约 Institute of Computer Software 2021/1/30 Nanjing University
引言 Design by Contract (DbC) 契约式设计 方法学层面的思想 ◼ 以尽可能小的代价开发出可靠性出众的软件系统 ◼ Eiffel语言的直接支持 Bertrand Meyer:DbC是构建面向对象软件系统方法 的核心! James McKim:“只要你会写程序,你就会写契约” 2021/1/30 Institute of Computer Software Nanjing University 3

最病 以引言 o a discipline of analysis, design, implementation, management (可以贯穿于软件创建的全过程,从分析到设计,从文 档到调试,甚至可以渗透到项目管理中) a Viewing the relationship between a class and its clients as a formal agreement, expressing each party s rights and obligations. (把类和它的客户程序之间的关系看做正式的协议,描 述双方的权利和义务) Institute of Computer Software 2021/1/30 Nanjing University
引言 A discipline of analysis, design, implementation, management (可以贯穿于软件创建的全过程,从分析到设计,从文 档到调试,甚至可以渗透到项目管理中) Viewing the relationship between a class and its clients as a formal agreement, expressing each party’ s rights and obligations. (把类和它的客户程序之间的关系看做正式的协议,描 述双方的权利和义务) 2021/1/30 Institute of Computer Software Nanjing University 4

最病 以引言 5 n Every software element is intended to satisfy a certain goal, for the benefit of other software elements (and ultimately of human users) n This goal is the elements contract. a The contract of any software element should be 口 Explicit. a Part of the software element itself Institute of Computer Software 2021/1/30 Nanjing University
引言 Every software element is intended to satisfy a certain goal, for the benefit of other software elements (and ultimately of human users). This goal is the element’ s contract. The contract of any software element should be Explicit. Part of the software element itself. 2021/1/30 Institute of Computer Software Nanjing University 5

最病 E Ahuman contract 6 deliver OBLIGATIONS(义务) BENEF|TS(权益/权利) Client Satisfy precondition: From postcondition Bring package before Get package delivered 4 p. m. pay fee by 10 a.m. next day Suppli \satisfy postcondition: (From precondition Deliver package by Not required to do 10 a.m. next day anything if package delivered after 4 p. m or fee not paid Institute of Computer Software 2021/1/30 Nanjing University
A human contract 2021/1/30 Institute of Computer Software Nanjing University 6 Client Supplier (Satisfy precondition:) Bring package before 4 p.m.; pay fee. (Satisfy postcondition:) Deliver package by 10 a.m. next day. OBLIGATIONS(义务) (From postcondition:) Get package delivered by 10 a.m. next day. (From precondition:) Not required to do anything if package delivered after 4 p.m., or fee not paid. BENEFITS(权益/权利) deliver

最病 A view of software construction 7 n Constructing systems as structured collections of cooperating software elements- suppliers and clients- cooperating on the basis of clear definitions of obligations and benetits. a these definitions are the contracts Institute of Computer Software 2021/1/30 Nanjing University
A view of software construction Constructing systems as structured collections of cooperating software elements — suppliers and clients — cooperating on the basis of clear definitions of obligations and benefits. These definitions are the contracts. 2021/1/30 Institute of Computer Software Nanjing University 7

最病 A Properties of contracts 8 A contract a Binds two parties (or more): supplier, client. a Is explicit(written). a Specifies mutual obligations and benefits. a Usually maps obligation for one of the parties into benefit or the other, and conversely. a Has no hidden clauses: obligations are those specified a Often relies, implicitly or explicitly on general rules applicable to all contracts ( laws, regulations, standard practices Institute of Computer Software 2021/1/30 Nanjing University
Properties of contracts A contract: Binds two parties (or more): supplier, client. Is explicit (written). Specifies mutual obligations and benefits. Usually maps obligation for one of the parties into benefit for the other, and conversely. Has no hidden clauses: obligations are those specified. Often relies, implicitly or explicitly, on general rules applicable to all contracts (laws, regulations, standard practices). 2021/1/30 Institute of Computer Software Nanjing University 8

Contracts for analysis deferred class plane inherit AIRCRAFT Feature start take off is Precondition Initiate take-off procedures. require controls. passed i. e specified only assigned_runway. clear deferred lot implemented assigned_runway. owner =Current moving Postcondition start_landing, increase_altitude, decrease_altitude, moving altitude speed, time_since_ take_ off …,[ Other features]… Class invariant invariant (timesince_ take_off 10) 9 d en Institute of Computer Software 2021/1/30 Nanjing University
2021/1/30 Institute of Computer Software Nanjing University 9 deferred class PLANE inherit AIRCRAFT feature start_take_off is -- Initiate take-off procedures. require controls.passed assigned_runway.clear deferred ensure assigned_runway.owner = Current moving end start_landing, increase_altitude, decrease_altitude, moving, altitude, speed, time_since_take_off ... [Other features] ... invariant (time_since_take_off 10) end Contracts for analysis Precondition Class invariant -- i.e. specified only. -- not implemented. Postcondition

Contracts for analysis (cont'd) deferred class vat inherit TANK Feature in valve out valve: VALVE fill is Fill the vat Precondition require In valve open ut valve closed i.e. specified only deferred ensure in valve, closed not implemented out valvecl is full Postcondition empty, is_full, is_empty, gauge, maximum, [Other fe Class invariant invariant (gauge >=0.97*maximum) and (gauge <=1.03*maximum) end 10 Institute of Computer Software 2021/1/30 Nanjing University
2021/1/30 Institute of Computer Software Nanjing University 10 deferred class VAT inherit TANK feature in_valve, out_valve: VALVE fill is -- Fill the vat. require in_valve.open out_valve.closed deferred ensure in_valve.closed out_valve.closed is_full end empty, is_full, is_empty, gauge, maximum, ... [Other features] ... invariant is_full = (gauge >= 0.97 * maximum) and (gauge <= 1.03 * maximum) end Contracts for analysis (cont’d) Precondition Class invariant -- i.e. specified only. -- not implemented. Postcondition
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第四章 网络层.ppt
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第三章 数据链路层.ppt
- 清华大学出版社:《物流电子商务》课程教学资源(PPT课件讲稿,共八章,主编:董铁,制作:李晓新).ppt
- 《计算机组成原理》课程教学资源(PPT课件讲稿)第5章 输入输出系统.ppt
- 北京大学:未来互联网体系结构(PPT讲稿)Future Internet Architecture(Introduction).pptx
- 西华大学:《电子商务概论》课程教学资源(PPT课件讲稿)第4章 电子商务的安全问题.ppt
- 中国科学技术大学:《Linux操作系统分析》课程教学资源(PPT课件讲稿)第一章 绪论(主讲:陈香兰).ppt
- 南京大学:《计算机网络 Computer Networks》课程教学资源(PPT课件讲稿)简介、第一章 引论(谭晓阳).ppt
- 沈阳理工大学:《Visual Basic 6.0程序设计》课程教学资源(PPT课件讲稿)第三章 VB基本语言.ppt
- 《数据结构与算法分析》课程教学资源(PPT讲稿)Lists, Stacks and Queues.ppt
- 《计算机网络与通信》课程教学资源(PPT课件)Chapter 8 传输层.ppt
- 《计算机网络 Computer Networking》课程教学资源(PPT课件讲稿)Chapter 08 Network Security.ppt
- 《计算导论与程序设计》课程教学资源(PPT课件讲稿)Chap 5 函数.ppt
- 贵州大学:计算机应用基础(PPT课件讲稿)计算机基础知识.pdf
- 《计算机组装与维护》课程教学资源(PPT课件讲稿)第十一章 计算机数据恢复技术.ppt
- 《C语言程序设计》课程教学资源(PPT讲稿)第1章 程序设计和C语言.pptx
- 北京师范大学:《计算机文化基础》课程教学资源(PPT课件讲稿)08 网页制作基础知识(赵国庆).ppt
- 水平集方法与图像分割 Level set method and image segmentation.pptx
- 《计算机网络》课程教学资源(PPT讲稿)网络安全(访问控制、加密、防火墙).ppt
- 同济大学:《大数据分析与数据挖掘 Big Data Analysis and Mining》课程教学资源(PPT课件讲稿)Platforms for Big Data Mining(主讲:饶卫雄).ppt
- 《计算机网络安全》课程教学资源(PPT课件讲稿)第三章 网络防病毒.ppt
- 同济大学:《软件测试》课程教学资源(PPT课件讲稿)第5章 单元测试(朱少民).ppt
- 香港科技大学:Information-Agnostic Flow Scheduling for Commodity Data Centers.pptx
- 南京航空航天大学:《数据结构》课程教学资源(PPT课件讲稿)第九章 查找.ppt
- 《数字图像处理 Digital Image Processing》课程教学资源(PPT课件讲稿)第10章数字图像处理的应用.ppt
- 北京大学信息学院:《高级软件工程》课程教学资源(PPT课件讲稿)第五讲 新运行平台——云计算平台.pptx
- 视觉系统(PPT课件讲稿)The Visual System.ppt
- 谈模式识别方法在林业管理问题中的应用(PPT讲稿).pptx
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第十章 人机交互接口(主讲:刘忠国).ppt
- 深圳大学:《编译原理》课程教学资源(PPT课件讲稿,共四章,尹剑飞).ppt
- 《单片机原理与应用》课程教学资源(PPT课件讲稿)第2章 MCS-51单片机结构及原理.pptx
- 中国科学技术大学:《信息论与编码技术》课程教学资源(PPT课件讲稿)第6章 有噪信道编码定理.pptx
- 应用层网络(PPT课件讲稿)Application-layer Overlay Networks.ppt
- 《计算机常用工具软件》教学资源(PPT讲稿)第8章 音频工具.ppt
- 微信公众平台开发与应用(PPT讲座,谭海兵).pptx
- 河南中医药大学:《网络技术实训》课程教学资源(PPT课件讲稿)网络建设中的关键技术(主讲:路景鑫).pptx
- 同济大学:《机器学习》课程教学资源(PPT讲稿)决策树 Decision Tree.pptx
- 香港理工大学:Introduction to Matlab(PPT讲稿)Image Processing with MATLAB.pptx
- 同济大学:《软件测试》课程教学资源(PPT课件讲稿)第6章 功能测试(朱少民).ppt
- A Unified Approach to Route Planning for Shared Mobility.pptx