📜 ⬆️ ⬇️

Google simplifies contract programming

Google has released the Contracts for Java open library, which simplifies the implementation of contract programming in Java. Using the Contracts for Java library, preconditions, postconditions, and invariants can be added to Java as Boolean expressions inside annotations.

As stated in the official announcement , the library was developed by two Google programmers in their spare time (20% for personal projects) and is based on Modern Jass and is inspired by the Eiffel language, which was first implemented using the contract programming method.

The contract programming method assumes that the designer must define formal, accurate, and verifiable interface specifications for the system components. In addition to the usual definition of abstract data types, preconditions, postconditions and invariants are also used. These specifications are called “contracts” in accordance with the conceptual metaphor of conditions and responsibilities in business contracts.

All this is necessary in order to as accurately as possible to find the place of an error in the code. Google gives the following example: if in the standard code the place of failure can be quite far from the place of the error,
')


... then in case of breach of contract, the place of error is immediately localized.



More information about contract programming can be found in the literature and the description of the methodologies used in Contracts for Java.

Source: https://habr.com/ru/post/113211/


All Articles