Journal of Computer Applications ›› 2005, Vol. 25 ›› Issue (04): 796-798.DOI: 10.3724/SP.J.1087.2005.0796

• Software and database • Previous Articles     Next Articles

Object-oriented programming by contract

LIN Jia-yi,LIU Jin,HE Ke-qing   

  1. he State Key laboratory of Software Engineering,Wuhan University
  • Online:2005-04-01 Published:2005-04-01

面向对象的契约式程序设计

林佳一,刘进,何克清   

  1. 武汉大学计算机软件工程国家重点实验室
  • 基金资助:

    国家自然科学基金资助项目(60373086)

Abstract:

A notion of behavior subtyping and its extension was introduced.By analysing an example of Java,how to design in object-oriented programming by contract was discussed in order to keep the features of single and multiple inheritance.The effectivity of the method was demonstrated.Finally,how to assign blame when contracts were violated in dynamic enviroment was discussed. The perspective of contract used in software development was outlooked.

Key words: behavior subtyping, contract, precondition, postcondition, invariant

摘要:

运用行为子类型及扩充行为子类型的概念,通过对一个Java实例地剖析,讨论了在面向 对象的契约式程序设计中如何撰写契约,以保持面向对象的单个继承和多重继承的特性问题,并证明 了这一方法的有效性。最后探讨了动态环境下违反契约时的责任归咎,展望了契约思想在软件开发 中的运用前景。

关键词: 行为子类型, 契约, 前置条件, 后置条件, 不变式

CLC Number: