[aspectc-user] AspectC++ and DBC
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Feb 25 09:54:01 CET 2003
Hi Mohammed,
On Monday 03 February 2003 23:49, iad929 wrote:
> Hi...
>
> After looking at AspectC++ quick reference, an impression came to my mind
> that we can use AspectC++ to implement Meyer's Design By Contract. Is that
> true? If so, how we can do this?
>
>
> Mohammed
I am not an expert in design by contract, but from my point of view that
makes very much sense. This is true not only for DBC, but also for UML
constraints, which is a related concept.
Pre-conditions, post-conditions, and invariants for functions and classes can
be checked very well with before and after advice at runtime. With an
aspect-oriented implementation like this it becomes very simple to turn these
checks on and off, because they are encapsulated in a single or a few modular
units. Often these checks are crosscutting, which means that the same test
must be executed at different positions in the code. Then you will also save
a lot of lines of code. As an example, imagine that you have a general policy
that no method should be called on an object with an address that is NULL.
With an aspect this is simple, but without aspects it would be unavoidable to
manipulate the code of every function.
Yours,
Olaf
More information about the aspectc-user
mailing list