The computer software system has been more and more popular and important today, so the quality of software has been a significant and hot issue. In order to improve software quality, DBC (Design By Contract) has been developed. Contracts describe properties, expectations and guarantees of a program. Program invariant, which includes class invariants, pre-condition and post-condition, is a common kind of contracts.In this paper, a theory model for dynamically generating program invariant is built. Based on the model, the dynamical generating technique of program invariant, both function dependent invariant and non- function dependent invariant, is discussed. Furthermore, a new method of dynamically generating non- functional dependent program invariant is presented. The method, which comprises of series of detecting measures of specific non-functional dependent program invariants by using SQL query, takes the advantage of database. So, we can dynamically discover any kind of non-function dependent program invariants by giving the query conditions.Finally, a prototype system for dynamically generating program invariant is implemented. Comparing with other tools, e.g. Daikon, the system has two excellent features. First, it is expansible; second, it can detect program invariants in a nimble way. |