Articles

Design by Contract is Most Requested Feature?

Thanks to Alex Potanin for pointing this out to me … it seems that [[Design by Contract]] is the most requested enhancement to the Java language.  You can find the list of the top 25 RFEs here.  A nice quote from the feature description:

I find it a shame that all the requests for DBC support were considered satisfied/closed by the addition of this “simple assertion facility”. We don’t want a “simple assertion facility”, we want full support for DBC : a software reliability mechanism that is both extremely powerful and incredibly elegant.

Obviously, this is good news from my perspective, since this is exactly what I’m trying to tackle with Whiley!

However, I also find this news quite surprising.  I suppose my reasoning is that, since there are so few languages that support DBC, I would have thought most people would be skeptical of the benefits.  Indeed, there remains significant disagreement over the benefit even from static typing, and I would expect many to argue for testing over DBC.

Still, this is an interesting — albeit surprising — turn of events …

6 comments to Design by Contract is Most Requested Feature?

  • jkenoyer

    With .Net 4.0 Contracts were the most looked forward to feature that really didn’t seem to offer much benefit. Its a really good idea to study the theory behind them but the actual implementation was clunky. I didn’t feel I was gaining much over your standard ArgumentException assert type code. I also ran into problems with my unit tests.

    I would think Java needs something like Linq about a 1000 times more. That is by far the thing I miss the most when switching from C#.

  • JC

    The thing is that Java is used for building very large enterprise software, for example one of the application-level modules of the beast I work on is almost 3 million lines of Java code, split into ~150 modules (production code and test modules). There are 10 other large modules which on average are the same size (some larger, some smaller).
    When you build software of that magnitude, testing is not enough, all the help that you can get from the compiler is welcome, even if sometimes slows you down.

  • Ralph

    >all the help that you can get from the compiler is welcome, even if sometimes slows you down.

    JC, sound like you’re a good candidate for Scala.

  • > Its a really good idea to study the theory behind them but the actual implementation was clunky

    It definitely seems to me that adding them retrospectively to an already complex language is something of a challenge …

    Dave

  • JC

    Ralph: True, I would love to use Scala, but as usual with large projects, switching languages is very difficult (just from a training point of view). An incremental addition is an easier sell.

  • jkenoyer

    The Microsoft Research language had a way to check for null arguments built in.

    void function(MyObject? object) // the question mark means nulls are not accepted.

    I really wish that would find main stream acceptance since most of my asserts seem to be making sure I’m not passed a null object and if I am giving a meaningful exception.

    I am a professional C# programmer, not Java, so its possible Java already has something like this.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>