OCL for Java |
||
| Last update: 2005-12-28 | ||
|
Home - Example - OCL - Usage - Eclipse - FAQ |
OverviewOCL4Java is made for Java developer that want to increase the code quality by utilizing the Design-By-Contract principles. Quality means in this context code that
By testing method parameters and return values against the specification (during runtime) a more robust application can be achieved, as invalid values are systematically avoided. OCL4Java evaluates OCL expressions in the source code and enhances the code by
Which type of code enhancement actually is generated - the so called Assertion-Style - can be determined on project and method level. The following small examples shows a method with a constraint (lines 1 and 2). OCL4Java generates to given an example an assertion method (lines 9-21) and the call of this new method on the original method (lines 4 and 5). The generated code is marked with gray background.
1 @Constraint("context TestClassPerson::setAge(anAge:Integer)\n " +
4 assert assertPreCondition_45ae89dd_for_method_setAge(anAge) :
6 age = anAge;
9 * This method checks the OCL Precondition <b/>However, not the original source code is changed, but for each source file a second enhanced source file is generated. A discussion and justification for this design you can find in the chapter "Technology->Remarks". |
|