What are Crosscuting Contracts? What is the relationship with Design by Contract?

Asked

Viewed 119 times

4

What are crosscuting Contracts? What is the relationship with Design by Contract?

1 answer

4


Design by Contract (Dbc) is an approach to design of software providing for the formalisation of contracts (i.e, pre-conditions, post-conditions and invariants) between customers and suppliers.

Languages such as Eiffel (created by Professor Bertrand Meyer, which also coined the term Dbc) have native support for Dbc. In Eiffel we can specify contracts for routines and classes through clauses such as require, ensure and invariant (for more information see Eiffel Software: Building bug-free O-O software: An Introduction to Design by Contract™). In languages such as Java, native support is limited to assertions.

Techniques of Aspect-oriented programming (AOP) aim to decouple crosscuting Concerns (transverse characteristics) of the main system functionality. For example, application aspects such as logs, transactional control and security can be moduralized with AOP, thus decreasing the amount of code required to ensure these features through the application.

There are several libraries that try to emulate the notion of contracts through AOP, for example the Oval tries to emulate contracts in Java through Aspectj.

In academic circles there are open discussions about the nature of contracts. One of them concerns crosscuting Contracts, that is contracts that encompass various methods / classes. There is of course an intersection between AOP and Dbc.

Several respected authors admit the existence of crosscuting Contracts. This is one of the lines of research, for example, from Professor Henrique Rebêlo who created the tool Aspectjml for the specification of crosscuting Contracts.

Crosscuting Contracts allow, in theory, greater reuse of code. That said, there are controversies on the adequacy of aspects for the implementation of Dbc. For example, that 2005 publication co-authored by Meyer puts the marriage between Dbc and AOP in check. In turn, this 2014 publication (whose first author is Rebêlo), tries to reconcile trade-offs between languages with native Dbc and AOP support.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.