Re: Comparing design by contract with defensive development



Tony Johansson wrote:

> I'm reading a paper that compare defensive development and design by
> contract.
> The author is in favour for defensive development.
>
> What is your opinion between defensive development and design by
> contract.?
> What kind of development strategy is the java API using is it defensive
> development or design by contract.?
> As you might know is the defensive development checking all the
> preconditions on the receiver object and
> if the precondition is violated will an exeption be thrown.

Google for "test-driven development" and JUnit.

The ability to pull assertions out of the code, and put them into test
cases, has a unique and incredibly powerful effect on design, rigorously
decoupling your tested code.

Put another way, code with lots of assertions (and possibly even DbC code)
has less mandate to decouple. But test cases should be able to construct the
minimum objects before testing one's method.

In turn, this makes new tests very easy to write, leading to a vicious cycle
of cleaning and verifying code between adding features. Test cases have many
more options to provide spike data than internal assertions do.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


.



Relevant Pages