Sunburned Surveyor wrote: Hi,
> Does anyone have experience with design-by-contract programming in > Java? It seems like most of the dbc frameworks I have looked at for > Java either use Javadoc comments or some type of preproccessor to > implement dbc programming. > > It seems like you could do the same basic thing with regular Java code > in your classes. Does anyone know of a standard way to implement dbc > in Java without Javadoc comments of preprocessing? I guess I'm > thinking of a naming convention for methods that verify pre-conditions > and post-conditions, but other things, like an assertion framwork, > might be included. The problem is, that pre- and postconditions vastly interfere with subclassing. That means that special steps must be taken in order to ensure correctness. Doing that by hand beats the purpose of DbC. Of course you can specify assertions, but they are not part of the interface like DbC. Imagine the following hierarchy: class A{ // @pre: x > 10 // @post: result > 10 public int test(int x) { } } class B extends A{ // @pre: x > 11 // @post: result > 0 public int test(int x) { } } Someone using an instance of class B as an instance of class A will be surprised that the method does not accept 11 as input, or that it yields values <= 10 sometimes. In order to ensure these constraints (post conditions must be stronger in subclasses, pre conditions must be weaker) you have to generate more complex code than meets the eye. Best regards, Andreas -- l a t / l o n GmbH Aennchenstrasse 19 53177 Bonn, Germany phone ++49 +228 18496-11 fax ++49 +228 1849629 http://www.lat-lon.de http://www.deegree.org
signature.asc
Description: Digital signature
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel