<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments for Ben Hughes</title>
	<atom:link href="http://www.benrhughes.com/blog/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benrhughes.com/blog</link>
	<description>Photography, Programming and other things beginning with P</description>
	<pubDate>Thu, 11 Mar 2010 13:29:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on A fork in the road by Ben Hughes » Refactoring Life</title>
		<link>http://www.benrhughes.com/blog/2009/12/a-fork-in-the-road/comment-page-1/#comment-716</link>
		<dc:creator>Ben Hughes » Refactoring Life</dc:creator>
		<pubDate>Sat, 26 Dec 2009 11:33:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=453#comment-716</guid>
		<description>[...] creating an elegant life I need to clearly define what I want to achieve, which obviously has been rattling around in my head a little [...]</description>
		<content:encoded><![CDATA[<p>[...] creating an elegant life I need to clearly define what I want to achieve, which obviously has been rattling around in my head a little [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Surfacing ABS data as XML by ben</title>
		<link>http://www.benrhughes.com/blog/2009/11/surfacing-abs-data-as-xml/comment-page-1/#comment-650</link>
		<dc:creator>ben</dc:creator>
		<pubDate>Thu, 12 Nov 2009 09:35:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=427#comment-650</guid>
		<description>The pre-Excel XML is apparently pretty horrendous and not really fit for public consumption. I agree though, it sounds like it should be relatively trivial.</description>
		<content:encoded><![CDATA[<p>The pre-Excel XML is apparently pretty horrendous and not really fit for public consumption. I agree though, it sounds like it should be relatively trivial.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Surfacing ABS data as XML by Aquila</title>
		<link>http://www.benrhughes.com/blog/2009/11/surfacing-abs-data-as-xml/comment-page-1/#comment-648</link>
		<dc:creator>Aquila</dc:creator>
		<pubDate>Wed, 11 Nov 2009 12:01:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=427#comment-648</guid>
		<description>Been pushing for ages to release time series as XML ...  ffs the Excel spreadsheets you are referencing start life as XML before being converted to Excel and them pumped out to the website.  Why not make both formats available? It would be so easy to do technically.</description>
		<content:encoded><![CDATA[<p>Been pushing for ages to release time series as XML &#8230;  ffs the Excel spreadsheets you are referencing start life as XML before being converted to Excel and them pumped out to the website.  Why not make both formats available? It would be so easy to do technically.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Surfacing ABS data as XML by Adam Kennedy</title>
		<link>http://www.benrhughes.com/blog/2009/11/surfacing-abs-data-as-xml/comment-page-1/#comment-646</link>
		<dc:creator>Adam Kennedy</dc:creator>
		<pubDate>Tue, 10 Nov 2009 13:33:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=427#comment-646</guid>
		<description>Veeeery interesting, I must say.</description>
		<content:encoded><![CDATA[<p>Veeeery interesting, I must say.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on DBC vs TDD: A response by Glenn</title>
		<link>http://www.benrhughes.com/blog/2008/11/dbc-vs-tdd-a-response/comment-page-1/#comment-405</link>
		<dc:creator>Glenn</dc:creator>
		<pubDate>Tue, 01 Sep 2009 00:48:51 +0000</pubDate>
		<guid isPermaLink="false">http://benhughes.freehostia.com/blog/?p=125#comment-405</guid>
		<description>Hi Ben,

I'm here at home in bed, off sick today, so I'll say first up that anything stupid I say is because I am delirious ;)
Anyway, I just read your post on this, and Chris's, and thought I'd put in my 2c worth :)

And of course, I can only speak for myself, not Meyer :)

But anyway, first up, I think there's some confusion about the whole thing of checking or not checking contracts. You say that programmatically checking them "boggles" you, and yet, in your preferred way of working, you say in point 1, that you "Define the pre and post-conditions in a block at the start of the module ".

Well, I think they can be 1 and the same thing !
And I think (again, just my take on what Meyer is getting at, I could be completely wrong) that this is exactly the kind of thing that Meyer was getting at - what you say agrees with what he was saying.

ie, the contracts are defined "separately" from the actual code of the module. However, they are still programmatic, and are not intertwined into the main part of the code, with if conditions etc. They are totally separated from the main code, so that the main code remains very clear as to what is happening. The main code does not cater for any broken contracts - it assumes the contracts hold.

Remember, Meyer was defining a whole new language, and environment - he wasn't specifically talking about how to do things in Java, or .Net etc. In the end, he was really talking about a new system that he was devising, called Eiffel. We can emulate some of the ideas in some other languages, but as yet, it doesn't all come across as he envisioned it in OOSC, for Eiffel.

So, where you have points 1 and 3 - defining the contracts separately, and then do not check them - well, in his Eiffel system, defining them is (or can be) pretty much the same as checking them. All you have to do is set a switch to check or not to check - you keep your main code unpolluted with defensive checking.

His system allows you to view the code, with the contracts hidden - so all you see is the main code. Or, alternatively, you can view only the contracts, and not the code.

In short, don't get caught up in the whole thing about to check or not to check. What you have said you want to do, is what DbC lets you do. To check or not to check is largely irrelevant, and whether you do or not, makes no difference to what your code actually looks like (in Meyer's Eiffel system !!! Remember, if other systems have poorly implemented DbC, then this is not what Meyer was talking about !!! Java still doesn't have any good, supported, DbC - I have recently been looking. There's a number of attempts, and they all seem to die out...)

So, write your contracts in a separate block, and if you want to check them, then flick the switch, without changing your "real" code. If your system doesn't allow you to do this, then recognize that this is not Meyer's vision of how things should be, and is not his fault :)

Ok....but that's a very minor point in comparison to the real debate, as far as I'm concerned.
My position, much to Chris's horror, is that in fact they ARE complementary :)
And I think that those who write off DbC in favor of TDD don't realise the full potential of DbC, and how it can interact with testing.
(Or perhaps they write tests which are in fact contracts !)

The big difference between tests and contracts is that tests are specific, and contracts are general.
The first big problem with saying one is "better" than the other, is....PEOPLE.
People are different, and for whatever reason, some prefer one way, others prefer another. So, you simply can't necessarily please everyone, with any one approach.

Here's what to me is a very clear demonstration of the difference between them - in terms of my own personal experience.
Sometimes, when I'm reading a manual, I'll be reading, reading...thinking, "ok ok, just show me an example so I can see what it really looks like !!!"
I want to see a specific example, or in our situation, a test ! A specific situation of how the rules are applied. So, in this kind of situation, I like specific examples, or tests.

There is another well known case, where specific examples are presented, and which shows that it can actually be hard to know what is really going on when presented with specific examples.
Such cases like :-

What is the next number in the sequence 3, 7, 13, 21, 31... ?

Here we have some specific examples, but, it still requires some thinking to know what's "really going on".
After a little while, you'll realize that the sequence can be defined by the formula, n^2 + n + 1, and you think, I actually UNDERSTAND it now.
Specifics are great, but a formula, (or contract !) can actually lead to true understanding.

So, both specifics (tests) and general formulae (contracts) are both more useful at different times.

Of course, you can write generalized tests - which take in parameters, and use some "contract" to work out whether the result is correct...but I would argue, that in doing this, you are actually writing contracts, and are in fact doing DbC, even though you may think you're doing TDD or some unit testing.
The mechanism may be slightly different to using annotations etc to write contracts...but it's still DbC in my book ! :)

Chris argues that TDD offers advantages at all level, whereas DbC doesn't ...I'm not sure I see this at all. If you can write a test for any level, then I don't see why you can't think about a contract for that level as well.

Ok, but what I see as the real advantage of DbC that you guys are ignoring, is that DbC solves the "oracle" problem for you, ie how to come up with the correct results for tests. How do you write your tests ? You ...somehow...come up with the "answers", the correct results that are to be expected. How do you do that ? Mostly...by hand, right ?
This means that writing unit tests is hard work ! You want 100 tests ? then you have to work out 100 answers... And so, ...you end up NOT writing 100 tests. EVen something as simple as say, an addition routine, you might try a few inputs like, zero, or some negative numbers, or some big ones... and then you stop.
You're confident that it works (and probably rightly so, given that it's so simple ! ;) and so you stop. However, even in something so simple, being human, we can miss things. Maybe we don't realise what happens in Java when you add 2 really big numbers...and so don't even think to check for it...

But, here's the beauty of DbC. IF you turn the contracts on (don't get upset, this is pre-release ok ! :) ....then EVERY run of the program, is in fact a TEST.
What this means, is that if you can generate massive amounts of test data, you can run this through the program...and just see what happens. If you get a postcondition violation (or a precondition violation not directly caused by the test data) then you know there is a bug. You can set up a system to generate test data, and run your program, and have it running continuously - checking zillions of combinations of input data, checking all paths through your code....all at no cost to you, except for the thought you put in to come up with contracts, which I would argue, is time well spent, regardless of whether you end up implementing them programmatically or not.


So, in summary, I would just say :-

- thinking up general contracts can give you a deeper, truer understanding of your system, than just handling specific instances
- actually implementing them can allow for massively automating your tests
- hence... DbC and TDD (or unit testing in general) are complementary. If it's too hard to think up a useful, checkable contract, write some tests. If tests don't give you true understanding, write some contracts. If you really want to expand your test coverage, then write some contracts.</description>
		<content:encoded><![CDATA[<p>Hi Ben,</p>
<p>I&#8217;m here at home in bed, off sick today, so I&#8217;ll say first up that anything stupid I say is because I am delirious <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Anyway, I just read your post on this, and Chris&#8217;s, and thought I&#8217;d put in my 2c worth <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And of course, I can only speak for myself, not Meyer <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But anyway, first up, I think there&#8217;s some confusion about the whole thing of checking or not checking contracts. You say that programmatically checking them &#8220;boggles&#8221; you, and yet, in your preferred way of working, you say in point 1, that you &#8220;Define the pre and post-conditions in a block at the start of the module &#8220;.</p>
<p>Well, I think they can be 1 and the same thing !<br />
And I think (again, just my take on what Meyer is getting at, I could be completely wrong) that this is exactly the kind of thing that Meyer was getting at - what you say agrees with what he was saying.</p>
<p>ie, the contracts are defined &#8220;separately&#8221; from the actual code of the module. However, they are still programmatic, and are not intertwined into the main part of the code, with if conditions etc. They are totally separated from the main code, so that the main code remains very clear as to what is happening. The main code does not cater for any broken contracts - it assumes the contracts hold.</p>
<p>Remember, Meyer was defining a whole new language, and environment - he wasn&#8217;t specifically talking about how to do things in Java, or .Net etc. In the end, he was really talking about a new system that he was devising, called Eiffel. We can emulate some of the ideas in some other languages, but as yet, it doesn&#8217;t all come across as he envisioned it in OOSC, for Eiffel.</p>
<p>So, where you have points 1 and 3 - defining the contracts separately, and then do not check them - well, in his Eiffel system, defining them is (or can be) pretty much the same as checking them. All you have to do is set a switch to check or not to check - you keep your main code unpolluted with defensive checking.</p>
<p>His system allows you to view the code, with the contracts hidden - so all you see is the main code. Or, alternatively, you can view only the contracts, and not the code.</p>
<p>In short, don&#8217;t get caught up in the whole thing about to check or not to check. What you have said you want to do, is what DbC lets you do. To check or not to check is largely irrelevant, and whether you do or not, makes no difference to what your code actually looks like (in Meyer&#8217;s Eiffel system !!! Remember, if other systems have poorly implemented DbC, then this is not what Meyer was talking about !!! Java still doesn&#8217;t have any good, supported, DbC - I have recently been looking. There&#8217;s a number of attempts, and they all seem to die out&#8230;)</p>
<p>So, write your contracts in a separate block, and if you want to check them, then flick the switch, without changing your &#8220;real&#8221; code. If your system doesn&#8217;t allow you to do this, then recognize that this is not Meyer&#8217;s vision of how things should be, and is not his fault <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Ok&#8230;.but that&#8217;s a very minor point in comparison to the real debate, as far as I&#8217;m concerned.<br />
My position, much to Chris&#8217;s horror, is that in fact they ARE complementary <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
And I think that those who write off DbC in favor of TDD don&#8217;t realise the full potential of DbC, and how it can interact with testing.<br />
(Or perhaps they write tests which are in fact contracts !)</p>
<p>The big difference between tests and contracts is that tests are specific, and contracts are general.<br />
The first big problem with saying one is &#8220;better&#8221; than the other, is&#8230;.PEOPLE.<br />
People are different, and for whatever reason, some prefer one way, others prefer another. So, you simply can&#8217;t necessarily please everyone, with any one approach.</p>
<p>Here&#8217;s what to me is a very clear demonstration of the difference between them - in terms of my own personal experience.<br />
Sometimes, when I&#8217;m reading a manual, I&#8217;ll be reading, reading&#8230;thinking, &#8220;ok ok, just show me an example so I can see what it really looks like !!!&#8221;<br />
I want to see a specific example, or in our situation, a test ! A specific situation of how the rules are applied. So, in this kind of situation, I like specific examples, or tests.</p>
<p>There is another well known case, where specific examples are presented, and which shows that it can actually be hard to know what is really going on when presented with specific examples.<br />
Such cases like :-</p>
<p>What is the next number in the sequence 3, 7, 13, 21, 31&#8230; ?</p>
<p>Here we have some specific examples, but, it still requires some thinking to know what&#8217;s &#8220;really going on&#8221;.<br />
After a little while, you&#8217;ll realize that the sequence can be defined by the formula, n^2 + n + 1, and you think, I actually UNDERSTAND it now.<br />
Specifics are great, but a formula, (or contract !) can actually lead to true understanding.</p>
<p>So, both specifics (tests) and general formulae (contracts) are both more useful at different times.</p>
<p>Of course, you can write generalized tests - which take in parameters, and use some &#8220;contract&#8221; to work out whether the result is correct&#8230;but I would argue, that in doing this, you are actually writing contracts, and are in fact doing DbC, even though you may think you&#8217;re doing TDD or some unit testing.<br />
The mechanism may be slightly different to using annotations etc to write contracts&#8230;but it&#8217;s still DbC in my book ! <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Chris argues that TDD offers advantages at all level, whereas DbC doesn&#8217;t &#8230;I&#8217;m not sure I see this at all. If you can write a test for any level, then I don&#8217;t see why you can&#8217;t think about a contract for that level as well.</p>
<p>Ok, but what I see as the real advantage of DbC that you guys are ignoring, is that DbC solves the &#8220;oracle&#8221; problem for you, ie how to come up with the correct results for tests. How do you write your tests ? You &#8230;somehow&#8230;come up with the &#8220;answers&#8221;, the correct results that are to be expected. How do you do that ? Mostly&#8230;by hand, right ?<br />
This means that writing unit tests is hard work ! You want 100 tests ? then you have to work out 100 answers&#8230; And so, &#8230;you end up NOT writing 100 tests. EVen something as simple as say, an addition routine, you might try a few inputs like, zero, or some negative numbers, or some big ones&#8230; and then you stop.<br />
You&#8217;re confident that it works (and probably rightly so, given that it&#8217;s so simple ! <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> and so you stop. However, even in something so simple, being human, we can miss things. Maybe we don&#8217;t realise what happens in Java when you add 2 really big numbers&#8230;and so don&#8217;t even think to check for it&#8230;</p>
<p>But, here&#8217;s the beauty of DbC. IF you turn the contracts on (don&#8217;t get upset, this is pre-release ok ! <img src='http://www.benrhughes.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8230;.then EVERY run of the program, is in fact a TEST.<br />
What this means, is that if you can generate massive amounts of test data, you can run this through the program&#8230;and just see what happens. If you get a postcondition violation (or a precondition violation not directly caused by the test data) then you know there is a bug. You can set up a system to generate test data, and run your program, and have it running continuously - checking zillions of combinations of input data, checking all paths through your code&#8230;.all at no cost to you, except for the thought you put in to come up with contracts, which I would argue, is time well spent, regardless of whether you end up implementing them programmatically or not.</p>
<p>So, in summary, I would just say :-</p>
<p>- thinking up general contracts can give you a deeper, truer understanding of your system, than just handling specific instances<br />
- actually implementing them can allow for massively automating your tests<br />
- hence&#8230; DbC and TDD (or unit testing in general) are complementary. If it&#8217;s too hard to think up a useful, checkable contract, write some tests. If tests don&#8217;t give you true understanding, write some contracts. If you really want to expand your test coverage, then write some contracts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Zoo Photos by James</title>
		<link>http://www.benrhughes.com/blog/2009/07/zoo-photos/comment-page-1/#comment-304</link>
		<dc:creator>James</dc:creator>
		<pubDate>Mon, 10 Aug 2009 21:07:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=410#comment-304</guid>
		<description>Great pictures! The red panda looks so cute. I wish I could have one as a pet, but they aren't domesticated animals. </description>
		<content:encoded><![CDATA[<p>Great pictures! The red panda looks so cute. I wish I could have one as a pet, but they aren&#8217;t domesticated animals.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Driving DT880s by ben</title>
		<link>http://www.benrhughes.com/blog/2009/04/driving-dt880s/comment-page-1/#comment-229</link>
		<dc:creator>ben</dc:creator>
		<pubDate>Mon, 06 Jul 2009 06:04:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=343#comment-229</guid>
		<description>A brief followup here - I've since come to realise that the headphone out of the 5th gen iPod video has pretty bad stereo crosstalk, which accounts for most of the differences I've heard between it and other amps. My wife's 6th gen classic does not have this problem, so at some stage I may re-run these tests and see how things pan out.</description>
		<content:encoded><![CDATA[<p>A brief followup here - I&#8217;ve since come to realise that the headphone out of the 5th gen iPod video has pretty bad stereo crosstalk, which accounts for most of the differences I&#8217;ve heard between it and other amps. My wife&#8217;s 6th gen classic does not have this problem, so at some stage I may re-run these tests and see how things pan out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ASDoc - javaDoc for Flex by Kelly Brown</title>
		<link>http://www.benrhughes.com/blog/2009/05/asdoc-javadoc-for-flex/comment-page-1/#comment-177</link>
		<dc:creator>Kelly Brown</dc:creator>
		<pubDate>Fri, 12 Jun 2009 19:12:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=375#comment-177</guid>
		<description>The best information i have found exactly here. Keep going Thank you</description>
		<content:encoded><![CDATA[<p>The best information i have found exactly here. Keep going Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on eeePC 900HA mini-review by Ben Hughes » Installing Ubuntu on an EeePC 900HA</title>
		<link>http://www.benrhughes.com/blog/2009/01/eeepc-900ha-mini-review/comment-page-1/#comment-121</link>
		<dc:creator>Ben Hughes » Installing Ubuntu on an EeePC 900HA</dc:creator>
		<pubDate>Sun, 10 May 2009 01:46:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=257#comment-121</guid>
		<description>[...] &#171;&#160;eeePC 900HA mini-review Trees at Sunset, revisited&#160;&#187;      Feb 03 2009 [...]</description>
		<content:encoded><![CDATA[<p>[...] &laquo;&nbsp;eeePC 900HA mini-review Trees at Sunset, revisited&nbsp;&raquo;      Feb 03 2009 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Rediscovering P-mode by bazz</title>
		<link>http://www.benrhughes.com/blog/2009/03/rediscovering-p-mode/comment-page-1/#comment-36</link>
		<dc:creator>bazz</dc:creator>
		<pubDate>Sun, 08 Mar 2009 04:24:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.benrhughes.com/blog/?p=322#comment-36</guid>
		<description>Hey Ben,

Good read.  I'll be checking your exif data a little closer from now on. :p

I'm sure you know but in addition to the above you can also set P(rogram) mode to different program lines within the custom settings.  ie. hi-speed proity, dof priority or MTF priority.

MTF Priority is an interesting one as it interrogates the lens for information on the best MTF  data and favours those apertures.  Handy feature if you're looking for max performance from a given lens.</description>
		<content:encoded><![CDATA[<p>Hey Ben,</p>
<p>Good read.  I&#8217;ll be checking your exif data a little closer from now on. :p</p>
<p>I&#8217;m sure you know but in addition to the above you can also set P(rogram) mode to different program lines within the custom settings.  ie. hi-speed proity, dof priority or MTF priority.</p>
<p>MTF Priority is an interesting one as it interrogates the lens for information on the best MTF  data and favours those apertures.  Handy feature if you&#8217;re looking for max performance from a given lens.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
