Design by Contract is a formal method of the Object-Oriented software engineering, which can raise the reliability of software system. But main-stream programming languages don't provide the language level support for Design by Contract. To provide a convenient way of using Design by Contract, the support of Design by Contract at language level is needed.First, the discussion is started with several methods of realizing Design by Contract on the Java platform. Most solutions have adopted the declarative-programming style for the contract declaration. In the methods of contract verification, there is delegate of the classic static tools such as JML. And also there is Contract4J which based on the AOP and JSR-175 Annotation. The latter one provides more convenient and extensibilities. So the studies are focused on the latter one.According to the studies of Contract4J, some problems of Contract4J in automatic processing the contract in a type hierarchy and in save the"old-state"which are used in the contract verification has bean discovered. Also, it lacks the dynamic management features.Focusing on the solutions of these problems, with AOP and the JSR-175 Annotation, a new Design by Contract framework named EasyDbC is designed and implemented. In the implementation of EasyDbC, by taking the advantage of AspectJ and JSR-175, a solution named"additional inheritance"is achieved to solve the problem of auto-processing the inheritance of contracts. And the object serialization technology is used to save the"old-state"of an object. By using JMX to provide some management functions, the developers and the maintainers can adopt Design by Contract more efficiently.With these improvements, EasyDbC can provide a seamless migration from the developing phase to the after-releasing phase. And can widen the usage of Design by Contract. |