Design by contract

Hi, I would like to implement Design by Contract for the base language. I have seen that exists a language (baselanguage.contracts) but it seems that I can add pre/post conditions only in interfaces (am I wrong?).

I would like instead to implement:
  • pre/post constraints for interface and class methods with proper rules for inheritance
    - invariants
to do that I would need to change the generation rules also for methods which do not contains directly a pre-condition. For example in this case:

class A {
postcondition x
void foo();

class B extends A {
void foo();

while method foo in class B has no directly postconditions it should inherit postcondition x. So I would like to decorate the code normally generated for methods with the proper pre/post conditions check.

Which is the best way to do that?
1 comment
Comment actions Permalink
baselanguage.contracts is currently outdated, so the only way to support this kind of extension is to create it from scratch. I believe MPS generator should be powerful enough to handle this use case.

Please sign in to leave a comment.