最新契约式设计ppt课件

上传人:无*** 文档编号:215484532 上传时间:2023-06-02 格式:PPT 页数:86 大小:1.03MB
收藏 版权申诉 举报 下载
最新契约式设计ppt课件_第1页
第1页 / 共86页
最新契约式设计ppt课件_第2页
第2页 / 共86页
最新契约式设计ppt课件_第3页
第3页 / 共86页
资源描述:

《最新契约式设计ppt课件》由会员分享,可在线阅读,更多相关《最新契约式设计ppt课件(86页珍藏版)》请在装配图网上搜索。

1、进入夏天,少不了一个热字当头,电扇空调陆续登场,每逢此时,总会想起进入夏天,少不了一个热字当头,电扇空调陆续登场,每逢此时,总会想起那一把蒲扇。蒲扇,是记忆中的农村,夏季经常用的一件物品。记忆中的故那一把蒲扇。蒲扇,是记忆中的农村,夏季经常用的一件物品。记忆中的故乡,每逢进入夏天,集市上最常见的便是蒲扇、凉席,不论男女老少,个个手持乡,每逢进入夏天,集市上最常见的便是蒲扇、凉席,不论男女老少,个个手持一把,忽闪忽闪个不停,嘴里叨叨着一把,忽闪忽闪个不停,嘴里叨叨着“怎么这么热怎么这么热”,于是三五成群,聚在大树,于是三五成群,聚在大树下,或站着,或随即坐在石头上,手持那把扇子,边唠嗑边乘凉。孩

2、子们却在周下,或站着,或随即坐在石头上,手持那把扇子,边唠嗑边乘凉。孩子们却在周围跑跑跳跳,热得满头大汗,不时听到围跑跑跳跳,热得满头大汗,不时听到“强子,别跑了,快来我给你扇扇强子,别跑了,快来我给你扇扇”。孩。孩子们才不听这一套,跑个没完,直到累气喘吁吁,这才一跑一踮地围过了,这时子们才不听这一套,跑个没完,直到累气喘吁吁,这才一跑一踮地围过了,这时母亲总是,好似生气的样子,边扇边训,母亲总是,好似生气的样子,边扇边训,“你看热的,跑什么?你看热的,跑什么?”此时这把蒲扇,此时这把蒲扇,是那么凉快,那么的温馨幸福,有母亲的味道!蒲扇是中国传统工艺品,在是那么凉快,那么的温馨幸福,有母亲的味

3、道!蒲扇是中国传统工艺品,在我国已有三千年多年的历史。取材于棕榈树,制作简单,方便携带,且蒲扇的表我国已有三千年多年的历史。取材于棕榈树,制作简单,方便携带,且蒲扇的表面光滑,因而,古人常会在上面作画。古有棕扇、葵扇、蒲扇、蕉扇诸名,实即面光滑,因而,古人常会在上面作画。古有棕扇、葵扇、蒲扇、蕉扇诸名,实即今日的蒲扇,江浙称之为芭蕉扇。六七十年代,人们最常用的就是这种,似圆非今日的蒲扇,江浙称之为芭蕉扇。六七十年代,人们最常用的就是这种,似圆非圆,轻巧又便宜的蒲扇。蒲扇流传至今,我的记忆中,它跨越了半个世纪,圆,轻巧又便宜的蒲扇。蒲扇流传至今,我的记忆中,它跨越了半个世纪,也走过了我们的半个人

4、生的轨迹,携带着特有的念想,一年年,一天天,流向长也走过了我们的半个人生的轨迹,携带着特有的念想,一年年,一天天,流向长长的时间隧道,袅长的时间隧道,袅契约式设计摘要引言Eiffel的DbC机制DbC与继承如何应用DbC2023/6/22InstituteofComputerSoftwareNanjingUniversitydeferredclass PLANEinheritAIRCRAFTfeaturestart_take_offis-Initiatetake-offprocedures.requirecontrols.passedassigned_runway.cleardeferrede

5、nsureassigned_runway.owner=Currentmovingendstart_landing,increase_altitude,decrease_altitude,moving,altitude,speed,time_since_take_off.Otherfeatures.invariant(time_since_take_off10)endContractsforanalysisPreconditionClassinvariant-i.e.specifiedonly.-notimplemented.Postcondition2023/6/29InstituteofCo

6、mputerSoftwareNanjingUniversitydeferredclass VATinheritTANKfeaturein_valve,out_valve:VALVEfillis-Fillthevat.requirein_valve.openout_valve.closeddeferredensurein_valve.closedout_valve.closedis_fullendempty,is_full,is_empty,gauge,maximum,.Otherfeatures.invariantis_full=(gauge=0.97*maximum)and(gauge5n:

7、=n+9n13Mostinterestingproperties:Strongestpostcondition(fromgivenprecondition).Weakestprecondition(fromgivenpostcondition).“PisstrongerthanorequaltoQ”means:PimpliesQQUIZ:Whatisthestrongestpossibleassertion?Theweakest?2023/6/215InstituteofComputerSoftwareNanjingUniversitySoftwarecorrectnessConsiderPA

8、QTakethisasajobadintheclassifieds.ShouldalazyemploymentcandidatehopeforaweakorstrongP?WhataboutQ?Two special offers:1.False A .2.A TrueStrongestprecond.Weakestpostcond.“WearelookingforsomeonewhoseworkwillbetostartfrominitialsituationsascharacterizedbyP,anddeliverresultsasdefinedbyQ2023/6/216Institut

9、eofComputerSoftwareNanjingUniversity摘要引言Eiffel的的 DbC机制机制DbC与继承如何应用DbC2023/6/217InstituteofComputerSoftwareNanjingUniversityDesignbyContract:TheMechanismPreconditionsandPostconditionsClassInvariantRun-timeeffect2023/6/218InstituteofComputerSoftwareNanjingUniversityAcontract(fromEiffelBase)extend(new:

10、G;key:H)-Assumingthereisnoitemofkeykey,-insertnewwithkey;setinserted.requirekey_not_present:nothas(key)ensureinsertion_done:item(key)=newkey_present:has(key)inserted:insertedone_more:count=oldcount+12023/6/219InstituteofComputerSoftwareNanjingUniversityThecontractClientSupplierPRECONDITIONPOSTCONDIT

11、IONOBLIGATIONSPOSTCONDITIONPRECONDITIONBENEFITSRoutine2023/6/220InstituteofComputerSoftwareNanjingUniversityAclasswithoutcontractsclassACCOUNTfeature-Accessbalance:INTEGER-BalanceMinimum_balance:INTEGERis1000-MinimumbalancefeatureNONE-Implementationofdepositandwithdrawaladd(sum:INTEGER)is-Addsumtoth

12、ebalance(secretprocedure).dobalance:=balance+sumend2023/6/221InstituteofComputerSoftwareNanjingUniversityWithoutcontracts(contd)feature-Depositandwithdrawaloperationsdeposit(sum:INTEGER)is-Depositsumintotheaccount.doadd(sum)endwithdraw(sum:INTEGER)is-Withdrawsumfromtheaccount.doadd(sum)endmay_withdr

13、aw(sum:INTEGER):BOOLEANis-Isitpermittedtowithdrawsumfromtheaccount?doResult:=(balance-sum=Minimum_balance)endend2023/6/222InstituteofComputerSoftwareNanjingUniversityIntroducingcontractsclassclass ACCOUNT createcreatemakefeaturefeature NONE-Initializationmake(initial_amount:INTEGER)is is-Set up acco

14、unt with initial_amount.requirerequirelarge_enough:initial_amount=Minimum_balancedodobalance:=initial_amountensureensurebalance_set:balance=initial_amountendend2023/6/223InstituteofComputerSoftwareNanjingUniversityIntroducingcontracts(contd)feature-Accessbalance:INTEGER-BalanceMinimum_balance:INTEGE

15、Ris1000-MinimumbalancefeatureNONE-Implementationofdepositandwithdrawaladd(sum:INTEGER)is-Addsumtothebalance(secretprocedure).dobalance:=balance+sumensureincreased:balance=oldbalance+sumend2023/6/224InstituteofComputerSoftwareNanjingUniversityWithcontracts(contd)feature-Depositandwithdrawaloperations

16、deposit(sum:INTEGER)is-Depositsumintotheaccount.requirenot_too_small:sum=0doadd(sum)ensureincreased:balance=oldbalance+sumend2023/6/225InstituteofComputerSoftwareNanjingUniversityWithcontracts(contd)withdraw(sum:INTEGER)is-Withdrawsumfromtheaccount.requirenot_too_small:sum=0not_too_big:sum=Minimum_b

17、alance)endinvariantnot_under_minimum:balance=Minimum_balanceend2023/6/229InstituteofComputerSoftwareNanjingUniversityTheclassinvariantConsistencyconstraintapplicabletoallinstancesofaclass.Mustbesatisfied:Aftercreation.Afterexecutionofanyfeaturebyanyclient.(Qualifiedcallsonly:a.f(.)2023/6/230Institut

18、eofComputerSoftwareNanjingUniversityThecorrectnessofaclassForeverycreationprocedurecp:precpdocppostcpandINVForeveryexportedroutiner:INVandprerdorpostrandINVTheworstpossibleerroneousrun-timesituationinobject-orientedsoftwaredevelopment:Producinganobjectthatdoesnotsatisfytheinvariantofitsownclass.a.f(

19、)a.g()a.f()createa.make()S1S2S3S42023/6/231InstituteofComputerSoftwareNanjingUniversityExamplebalance=deposits.totalwithdrawals.totaldepositswithdrawalsbalancedepositswithdrawals(A1)(A2)2023/6/232InstituteofComputerSoftwareNanjingUniversityAmoresophisticatedversionclassACCOUNTcreatemakefeatureNONE-I

20、mplementationadd(sum:INTEGER)is-Addsumtothebalance(secretprocedure).dobalance:=balance+sumensurebalance_increased:balance=oldbalance+sum enddeposits:DEPOSIT_LISTwithdrawals:WITHDRAWAL_LIST2023/6/233InstituteofComputerSoftwareNanjingUniversityNewversion(contd)featureNONE-Initializationmake(initial_am

21、ount:INTEGER)is-Setupaccountwithinitial_amount.requirelarge_enough:initial_amount=Minimum_balancedobalance:=initial_amountcreatedeposits.makecreatewithdrawals.makeensurebalance_set:balance=initial_amountendfeature-Accessbalance:INTEGER-BalanceMinimum_balance:INTEGERis1000-Minimumbalance2023/6/234New

22、version(contd)feature-Depositandwithdrawaloperationsdeposit(sum:INTEGER)is-Depositsumintotheaccount.requirenot_too_small:sum=0doadd(sum)deposits.extend(createDEPOSIT.make(sum)ensureincreased:balance=oldbalance+sumend2023/6/235InstituteofComputerSoftwareNanjingUniversityNewversion(contd)withdraw(sum:

23、INTEGER)is-Withdrawsumfromtheaccount.requirenot_too_small:sum=0not_too_big:sum=Minimum_balance)endinvariantnot_under_minimum:balance=Minimum_balanceconsistent:balance=deposits.totalwithdrawals.totalend2023/6/237InstituteofComputerSoftwareNanjingUniversityThecorrectnessofaclassForeverycreationprocedu

24、recp:precpdocppostcpandINVForeveryexportedroutiner:INVandprerdorpostrandINVa.f()a.g()a.f()createa.make()S1S2S3S42023/6/238InstituteofComputerSoftwareNanjingUniversityInitialversionfeaturefeature NONE-Initializationmake(initial_amount:INTEGER)is is-Set up account with initial_amount.requirerequire la

25、rge_enough:initial_amount=Minimum_balancedodobalance:=initial_amount createcreate deposits.makecreatecreate withdrawals.makeensureensurebalance_set:balance=initial_amount end end2023/6/239InstituteofComputerSoftwareNanjingUniversityCorrectversionfeaturefeature NONE-Initializationmake(initial_amount:

26、INTEGER)is is-Set up account with initial_amount.requirerequirelarge_enough:initial_amount=Minimum_balancedodocreatecreate deposits.makecreatecreate withdrawals.makedeposit(initial_amount)ensureensurebalance_set:balance=initial_amountendend402023/6/240InstituteofComputerSoftwareNanjingUniversityCont

27、racts:run-timeeffectCompilationoptions(perclass,inEiffel):NoassertioncheckingPreconditionsonlyPreconditionsandpostconditionsPreconditions,postconditions,classinvariantsAllassertions412023/6/241InstituteofComputerSoftwareNanjingUniversity摘要引言Eiffel的DbC机制DbC与继承与继承如何应用DbC2023/6/242InstituteofComputerSo

28、ftwareNanjingUniversity继承与 DesignbyContract问题:子类中的断言与父类中的断言是什么关系?依据子类乃父类的特化,子类的实例也是父类的合法实例。申明为父类的引用运行时可能指向子类实例因而?2023/6/243InstituteofComputerSoftwareNanjingUniversityInheritanceandassertionsCorrectcall:ifa1.thena1.r(.)else.endrisensurerisensureCABa1:Aa1.r()2023/6/244InstituteofComputerSoftwareNanji

29、ngUniversityContractClientSupplier(Satisfyprecondition:)不得要求投递超过5kg的包裹(Satisfypostcondition:)在3个工作日内投送到位OBLIGATIONS(Frompostcondition:)3个工作日内包裹到位(Fromprecondition:)不受理超过5kg的包裹BENEFITSdelivery2023/6/245InstituteofComputerSoftwareNanjingUniversityContractclass COURIER feature deliver(p:Package,d:Desti

30、nation)require -包裹重量不超过5kg ensure -3个工作日内投送到指定地点end2023/6/246InstituteofComputerSoftwareNanjingUniversityMoredesirablecontractClientSupplier(Satisfyprecondition:)不得要求投递超过8kg的包裹(Satisfypostcondition:)在2个工作日内投送到位OBLIGATIONS(Frompostcondition:)2个工作日内包裹到位(Fromprecondition:)不受理超过8kg的包裹BENEFITSdelivery202

31、3/6/247InstituteofComputerSoftwareNanjingUniversityMoredesirablecontractclass DIFFERENT_COURIERInherit COURIERredefine deliver feature deliver(p:Package,d:Destination)require -包裹重量不超过5kg require else -包裹重量不超过8kg ensure -3天内投送到指定地点ensure then -2天内投送到指定地点endrequire -包裹重量不超过8kgensure -2天内投送到指定地点2023/6/

32、248InstituteofComputerSoftwareNanjingUniversityAssertionredeclarationruleRedefinedversionmaynothaverequireorensure.Mayhavenothing(assertionskeptbydefault),orrequireelsenew_preensurethennew_postResultingassertionsare:original_preconditionor new_preoriginal_postconditionandnew_post2023/6/249Instituteo

33、fComputerSoftwareNanjingUniversityInvariantaccumulationEveryclassinheritsalltheinvariantclausesofitsparents.Theseclausesareconceptually“and”-ed.2023/6/250InstituteofComputerSoftwareNanjingUniversity简言之可以使用require else削弱先验条件可以使用ensure then加强后验条件用and把不变式子句和你所继承的不变式子句结合起来,就可以加强不变式2023/6/251InstituteofC

34、omputerSoftwareNanjingUniversity摘要引言Eiffel的DbC机制DbC与继承如何应用如何应用DbC其它2023/6/252InstituteofComputerSoftwareNanjingUniversityDesignbyContract:Howtoapply目的:构造高质量的程序理解ContractviolationDbC与QualityAssurance(QA)PreconditionDesignNotdefensiveprogrammingClassInvariantsandbusinesslogic2023/6/253InstituteofCompu

35、terSoftwareNanjingUniversityWhatarecontractsgoodfor?Writingcorrectsoftware(analysis,design,implementation,maintenance,reengineering).Documentation(the“contract”formofaclass).Effectivereuse.Controllinginheritance.Preservingtheworkofthebestdevelopers.Qualityassurance,testing,debugging(especiallyinconn

36、ectionwiththeuseoflibraries).Exceptionhandling.2023/6/254InstituteofComputerSoftwareNanjingUniversitySomebenefits:technicalDevelopmentprocessbecomesmorefocused.Writingtospec.Soundbasisforwritingreusablesoftware.Exceptionhandlingguidedbyprecisedefinitionof“normal”and“abnormal”cases.Interfacedocumenta

37、tionalwaysup-to-date,canbetrusted.Documentationgeneratedautomatically.Faultsoccurclosetotheircause.Foundfasterandmoreeasily.Guideforblack-boxtestcasegeneration.2023/6/255InstituteofComputerSoftwareNanjingUniversitySomebenefits:managerialLibraryuserscantrustdocumentation.Theycanbenefitfrompreconditio

38、nstovalidatetheirownsoftware.Testmanagercanbenefitfrommoreaccurateestimateoftesteffort.Black-boxspecificationforfree.Designerswholeavebequeathnotonlycodebutintent.Commonvocabularybetweenallactorsoftheprocess:developers,managers,potentiallycustomers.Component-baseddevelopmentpossibleonasolidbasis.202

39、3/6/256InstituteofComputerSoftwareNanjingUniversityAcontractviolationisnotaspecialcaseForspecialcases(e.g.“ifthesumisnegative,reportanerror.”)usestandardcontrolstructures(e.g.if.then.else.).Arun-timeassertionviolationissomethingelse:themanifestationofADEFECT(“BUG”)2023/6/257InstituteofComputerSoftwa

40、reNanjingUniversityContractsandqualityassurancePreconditionviolation:Bugintheclient.Postconditionviolation:Buginthesupplier.Invariantviolation:Buginthesupplier.PAQ2023/6/258InstituteofComputerSoftwareNanjingUniversityContractsandbugtypesPreconditionsareparticularlyusefultofindbugsinclientcode:YOUR A

41、PPLICATIONCOMPONENT LIBRARYyour_list.insert(y,a+b+1)i=0classLISTG2023/6/259InstituteofComputerSoftwareNanjingUniversityContractsandqualityassuranceUserun-timeassertionmonitoringforqualityassurance,testing,debugging.Compilationoptions(reminder):NoassertioncheckingPreconditionsonlyPreconditionsandpost

42、conditionsPreconditions,postconditions,classinvariantsAllassertions2023/6/260InstituteofComputerSoftwareNanjingUniversityContractsandqualityassuranceContractsenableQAactivitiestobebasedonaprecisedescriptionofwhattheyexpect.Profoundlytransformtheactivitiesoftesting,debuggingandmaintenance.“I believe

43、that the use of Eiffel-like module contracts is the most important non-practice in software world today.By that I mean there is no other candidate practice presently being urged upon us that has greater capacity to improve the quality of software produced.This sort of contract mechanism is the sine-

44、qua-non of sensible software reuse.”TomdeMarco,IEEEComputer,19972023/6/261InstituteofComputerSoftwareNanjingUniversityContractmonitoringEnabledordisabledbycompile-timeoptions.Default:preconditionsonly.Indevelopment:use“allassertions”wheneverpossible.Duringoperation:normally,shoulddisablemonitoring.B

45、uthaveanassertion-monitoringversionreadyforshipping.Resultofanassertionviolation:exception.Ideally:staticchecking(proofs)ratherthandynamicmonitoring.2023/6/262InstituteofComputerSoftwareNanjingUniversityContractsanddocumentation契约能使文档更出色更清晰的文档契约乃是类特性的公开视图中的固有成分更可靠的文档运行时要检查断言,以便保证制定的契约与程序的实际运行情况一致明确的

46、测试指导断言定义了测试的预期结果,并且由代码进行维护更精确的规范既能够获得精确规范得到的益处,同时还使得程序员继续以他们所熟悉的方式工作2023/6/263InstituteofComputerSoftwareNanjingUniversityContractform:DefinitionSimplifiedformofclasstext,retaininginterfaceelementsonly:Removeanynon-exported(private)feature.Fortheexported(public)features:Removebody(doclause).Keephead

47、ercommentifpresent.Keepcontracts:preconditions,postconditions,classinvariant.Removeanycontractclausethatreferstoasecretfeature.(Thisraisesaproblem;canyouseeit?)2023/6/264InstituteofComputerSoftwareNanjingUniversityContractformofACCOUNTclassclass interfaceclass interface ACCOUNT createcreatemakefeatu

48、refeaturebalance:INTEGER-BalanceMinimum_balance:INTEGER is is 1000-Minimum balancedeposit(sum:INTEGER)-Deposit sum into the account.requirerequirenot_too_small:sum=0ensureensureincreased:balance=oldold balance+sum2023/6/265InstituteofComputerSoftwareNanjingUniversityContractformofACCOUNTclass(contd)

49、withdraw(sum:INTEGER)-Withdraw sum from the account.requirerequirenot_too_small:sum=0not_too_big:sum=Minimum_balanceconsistent:balance=deposits.total withdrawals.totalend2023/6/266InstituteofComputerSoftwareNanjingUniversityFlat,interfaceFlatformofaclass:reconstructedclasswithallthefeaturesatthesame

50、level(immediateandinherited).Takesrenaming,redefinitionetc.intoaccount.Theflatformisaninheritance-freeclient-equivalentformoftheclass.Interfaceform:thecontractformoftheflatform.Fullinterfacedocumentation.2023/6/267InstituteofComputerSoftwareNanjingUniversityUsesofthecontractandinterfaceformsDocument

51、ation,manualsDesignCommunicationbetweendevelopersCommunicationbetweendevelopersandmanagers2023/6/268InstituteofComputerSoftwareNanjingUniversityContractsandreuse库使用者手中的优秀文档契约清楚地解释了程序库中各个类、各个例程的任务,以及使用中的限制条件对库使用者的帮助运行时的契约检查为那些学习使用别人的类的人们提供了反馈Reusewithoutacontractissheerfolly.2023/6/269InstituteofComp

52、uterSoftwareNanjingUniversityDbCvs.defensiveprogramming什么是防御性编程?防止程序接受错误的输入?防止用错误参数或者在不适当的情况下调用程序?“防御性编程是一种细致、谨慎的编程方法。为了开发可防御性编程是一种细致、谨慎的编程方法。为了开发可靠的软件,我们要设计系统中的每个组件,以使其尽可能靠的软件,我们要设计系统中的每个组件,以使其尽可能地地“保护保护”自己。我们通过明确地在代码中对设想进行检自己。我们通过明确地在代码中对设想进行检查,击碎了未记录下来的设想。这是一种努力,防止(或查,击碎了未记录下来的设想。这是一种努力,防止(或至少是观察

53、)我们的代码以将会展现错误行为的方式被调至少是观察)我们的代码以将会展现错误行为的方式被调用。用。”(Goodliffe,P:编程匠艺:编写卓越的代码编程匠艺:编写卓越的代码)2023/6/270InstituteofComputerSoftwareNanjingUniversityDbCvs.defensiveprogramming防止程序接受错误的输入“一个关键的防御性策略就是检查所有的程序输入”给程序穿上“防弹衣”placeCard(c:INTEGER,x:INTEGER,y:INTEGER)is do if(cMAXCARDS)then return endbulletproofing

54、notagoodstyle2023/6/271InstituteofComputerSoftwareNanjingUniversityDbCvsdefensiveprogramming防御性编程placeCard(c:INTEGER,x:INTEGER,y:INTEGER)is -网格(x,y)点放一张C牌do if(cMAXCARDS)then raise PRECONDITION_EXCEPTION(“Grid:placeCard:bad card number”)else end异常指明发生问题的类和程序以及问题本质2023/6/272InstituteofComputerSoftwar

55、eNanjingUniversityDbCvs.defensiveprogrammingDbC placeCard(c:INTEGER,x:INTEGER,y:INTEGER)is require valid_card_number:(c=1)and (c=0epsilon=0dodo.ensureensureabs(ResultResult 2 x)=2*epsilon*ResultResultendend2023/6/276InstituteofComputerSoftwareNanjingUniversityAtolerantstylesqrt(x,epsilon:REAL):REAL

56、is is-Square root of x,precision epsilonrequirerequireTrueTruedodoif if x 0 thenthen Do something about it(?)elseelse normal square root computation computed:=TrueTrue endendensureensurecomputed impliesimplies abs(ResultResult 2 x)=Minimum_balanceForm2invariantnot_under_minimum_if_normal:normal_stat

57、eimplies(balance=Minimum_balance)2023/6/279InstituteofComputerSoftwareNanjingUniversityDbC六条基本原则“DesignbyContractbyExample”1.区分命令(运算算子)和查询(观察算子);2.区分基本查询和派生查询;3.为每个派生查询设定一个后验条件,用一个或多个基本查询定义之;4.对于每个命令设定一个后验条件,规定每个基本查询的值;5.对于每个查询和命令,给以必要的先验条件;6.撰写不变式定义对象的恒定特性。2023/6/280InstituteofComputerSoftwareNanji

58、ngUniversity更多tips在适当地方添加物理限制(non-void?)先验条件中尽量使用高效的查询如有必要增加高效派生查询,并以后验条件保证其与原低效查询之间的等价关系用不变式限定属性为了支持特性的重定义,用相应的先验条件确保每个后验条件,这样就允许在开发子类过程中进行各种不可预见的重定义2023/6/281InstituteofComputerSoftwareNanjingUniversity更多tips框定规则(framerule):对(很多时候隐式的)不变的显式说明若有保密问题,秘密的查询可在契约中使用,而后设为私有2023/6/282InstituteofComputerSo

59、ftwareNanjingUniversity契约的一些开销和限制契约的撰写成本实践需求麻痹大意质量并不总是主要目标最好用于顺序式程序(sequentialprogram)语言不提供支持2023/6/283InstituteofComputerSoftwareNanjingUniversity小结DesignbyContract原理借鉴“契约”原理,界定模块之间的权利义务,规范软件的开发,提高软件质量。应用优势2023/6/284InstituteofComputerSoftwareNanjingUniversity作业请给出带Contract的类BoundedStack(使用Java和Contract4J5)BoundedStack:堆栈的容量受限2023/6/285InstituteofComputerSoftwareNanjingUniversity结束语结束语谢谢大家聆听!谢谢大家聆听!86

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!