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:
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?
I would like instead to implement:
- pre/post constraints for interface and class methods with proper rules for inheritance
- invariants
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
Sort by
Date
Votes
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.