<?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 on: DesignByContract with Fluent Interfaces</title>
	<atom:link href="http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Thu, 13 Sep 2012 07:11:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Nestor</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-91</link>
		<dc:creator>Nestor</dc:creator>
		<pubDate>Fri, 13 Feb 2009 17:43:27 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-91</guid>
		<description>I have been seen PostSharp from some time ago, and wondering if I could have attributes that get validation code injected in the class, avoiding errors and space on the source code.
Finally I used Billy&#039;s library as a base runtime and got a PostSharp post compilation process that get validation automagically applied to all parameters, including options as defining a whole namespace defaulted to not null or thing like that out of the box, many thanks to Gael for his PostSharp library, its rock!.

Regards  </description>
		<content:encoded><![CDATA[<p>I have been seen PostSharp from some time ago, and wondering if I could have attributes that get validation code injected in the class, avoiding errors and space on the source code.<br />
Finally I used Billy&#8217;s library as a base runtime and got a PostSharp post compilation process that get validation automagically applied to all parameters, including options as defining a whole namespace defaulted to not null or thing like that out of the box, many thanks to Gael for his PostSharp library, its rock!.</p>
<p>Regards  </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: colinjack</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-90</link>
		<dc:creator>colinjack</dc:creator>
		<pubDate>Tue, 13 Jan 2009 14:45:18 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-90</guid>
		<description>You might also want to give this a look: 
http://rabdullin.com/journal/2008/12/22/better-c-design-contracts-in-lokad-shared-libraries.html

You can download it here:
http://rabdullin.com/shared-libraries/</description>
		<content:encoded><![CDATA[<p>You might also want to give this a look:<br />
<a href="http://rabdullin.com/journal/2008/12/22/better-c-design-contracts-in-lokad-shared-libraries.html" rel="nofollow">http://rabdullin.com/journal/2008/12/22/better-c-design-contracts-in-lokad-shared-libraries.html</a></p>
<p>You can download it here:<br />
<a href="http://rabdullin.com/shared-libraries/" rel="nofollow">http://rabdullin.com/shared-libraries/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Ocampo</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-89</link>
		<dc:creator>Joe Ocampo</dc:creator>
		<pubDate>Fri, 19 Oct 2007 19:47:33 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-89</guid>
		<description>It is important to note that method chaining and fluent interfaces differ significantly.  

Fluent interfaces compliment an internal DSL&#039;s behavior an the interaction between the language constructs that form the DSL.

Method chaining is simply returning the same instance out of the given method that you are invoking against that object.

Fluent interfaces enforce DSL&#039;s through class delegation upon the architecture.  Meaning I can&#039;t invoke the addProduct() Method unless I have created an Order with a customer. 

Make sense?</description>
		<content:encoded><![CDATA[<p>It is important to note that method chaining and fluent interfaces differ significantly.  </p>
<p>Fluent interfaces compliment an internal DSL&#8217;s behavior an the interaction between the language constructs that form the DSL.</p>
<p>Method chaining is simply returning the same instance out of the given method that you are invoking against that object.</p>
<p>Fluent interfaces enforce DSL&#8217;s through class delegation upon the architecture.  Meaning I can&#8217;t invoke the addProduct() Method unless I have created an Order with a customer. </p>
<p>Make sense?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Chambers</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-88</link>
		<dc:creator>Sean Chambers</dc:creator>
		<pubDate>Fri, 19 Oct 2007 13:47:56 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-88</guid>
		<description>AJ,

Fair enough.

I do agree that a fluent interface is difficult to read from the actual classes that make it possible. You really need to use the fluent interface to see how it works. Once you do that, then it&#039;s easy to dive in and understand how the code is actually setup.

Whether or not this is an ample situation for fluent interfaces or not is actually a good question. With the original article by Bill, you had to do tricky assertions as my example above states. This is what motivated me to use a fluent interface. I suppose it was more of an example than anyhting else.

I wanted for the assertion to read more like a sentance than an assertion to make the code more soluable which is why I made it that way. I felt it was more concise than not using it.

Good points!</description>
		<content:encoded><![CDATA[<p>AJ,</p>
<p>Fair enough.</p>
<p>I do agree that a fluent interface is difficult to read from the actual classes that make it possible. You really need to use the fluent interface to see how it works. Once you do that, then it&#8217;s easy to dive in and understand how the code is actually setup.</p>
<p>Whether or not this is an ample situation for fluent interfaces or not is actually a good question. With the original article by Bill, you had to do tricky assertions as my example above states. This is what motivated me to use a fluent interface. I suppose it was more of an example than anyhting else.</p>
<p>I wanted for the assertion to read more like a sentance than an assertion to make the code more soluable which is why I made it that way. I felt it was more concise than not using it.</p>
<p>Good points!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aj.net</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-87</link>
		<dc:creator>aj.net</dc:creator>
		<pubDate>Fri, 19 Oct 2007 05:09:33 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-87</guid>
		<description>Two comments:
#1: fluent interfaces 
I actually don&#039;t quite understand what all that talk about fluent interfaces is about! Granted, the term has been formally introduced by Fowler in Dec 07, but it is not that new. It was a common pattern with C++ to return a reference to itself from a method rather than declaring it void. E.g. one could write:
   CString s= &quot;fluent interface&quot;;
   s.MakeUpper().MakerReverse().Delete(0, 99);

What I don&#039;t like about fluent interfaces is that you don&#039;t know from the looks of the code, what you are dealing with. It might include &quot;fluent interface calls&quot; as well as simple method calls on returned objects. Is it a reference to the object itself, a copy, another object? Or null? Which leads to the questing how one will track down a NullReferenceException (or other) in such a call chain.

Fowler (http://martinfowler.com/bliki/FluentInterface.html) had the folowing example of a fluent interface:

   private void makeFluent(Customer customer) {
        customer.newOrder()
                .with(6, &quot;TAL&quot;)
                .with(5, &quot;HPK&quot;).skippable()
                .with(3, &quot;LGV&quot;)
                .priorityRush();
    }

This was a rewrite of some ugly sample code. That ugly code could have been improved by simply cleaning it up a bit. Some small helper methods could further help, e.g. the following fragment is just as clean as the above code:

  private void makeBetter(Customer customer) {
        Order o1 = CreateNewRushedOrder(customer);
	AddLine(o1, 6, &quot;TAL&quot;);

        AddLine(o1, 5, &quot;HPK&quot;, Options.Skippable);
        AddLine(o1, 3, &quot;LGV&quot;);

    }

No fluent interfaces needed. So why introduce a new pattern, thus add complexity, if it does not provide some additional value?


#2: Check class
Why rewrite
   Check.Require(!string.IsNullOrEmpty(username), &quot;username is required&quot;);
to 
   Check.Parameter(username).WithMessage(&quot;username is required&quot;).IsNotNullOrEmpty();
?

What happened to 
   Guard.AssertNotEmpty(username, &quot;username&quot;, &quot;username is required&quot;);
?
Readable, concise, and consistent exceptions

Just my 0,02€.
AJ.NET</description>
		<content:encoded><![CDATA[<p>Two comments:<br />
#1: fluent interfaces<br />
I actually don&#8217;t quite understand what all that talk about fluent interfaces is about! Granted, the term has been formally introduced by Fowler in Dec 07, but it is not that new. It was a common pattern with C++ to return a reference to itself from a method rather than declaring it void. E.g. one could write:<br />
   CString s= &#8220;fluent interface&#8221;;<br />
   s.MakeUpper().MakerReverse().Delete(0, 99);</p>
<p>What I don&#8217;t like about fluent interfaces is that you don&#8217;t know from the looks of the code, what you are dealing with. It might include &#8220;fluent interface calls&#8221; as well as simple method calls on returned objects. Is it a reference to the object itself, a copy, another object? Or null? Which leads to the questing how one will track down a NullReferenceException (or other) in such a call chain.</p>
<p>Fowler (<a href="http://martinfowler.com/bliki/FluentInterface.html" rel="nofollow">http://martinfowler.com/bliki/FluentInterface.html</a>) had the folowing example of a fluent interface:</p>
<p>   private void makeFluent(Customer customer) {<br />
        customer.newOrder()<br />
                .with(6, &#8220;TAL&#8221;)<br />
                .with(5, &#8220;HPK&#8221;).skippable()<br />
                .with(3, &#8220;LGV&#8221;)<br />
                .priorityRush();<br />
    }</p>
<p>This was a rewrite of some ugly sample code. That ugly code could have been improved by simply cleaning it up a bit. Some small helper methods could further help, e.g. the following fragment is just as clean as the above code:</p>
<p>  private void makeBetter(Customer customer) {<br />
        Order o1 = CreateNewRushedOrder(customer);<br />
	AddLine(o1, 6, &#8220;TAL&#8221;);</p>
<p>        AddLine(o1, 5, &#8220;HPK&#8221;, Options.Skippable);<br />
        AddLine(o1, 3, &#8220;LGV&#8221;);</p>
<p>    }</p>
<p>No fluent interfaces needed. So why introduce a new pattern, thus add complexity, if it does not provide some additional value?</p>
<p>#2: Check class<br />
Why rewrite<br />
   Check.Require(!string.IsNullOrEmpty(username), &#8220;username is required&#8221;);<br />
to<br />
   Check.Parameter(username).WithMessage(&#8220;username is required&#8221;).IsNotNullOrEmpty();<br />
?</p>
<p>What happened to<br />
   Guard.AssertNotEmpty(username, &#8220;username&#8221;, &#8220;username is required&#8221;);<br />
?<br />
Readable, concise, and consistent exceptions</p>
<p>Just my 0,02€.<br />
AJ.NET</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jlockwood</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-86</link>
		<dc:creator>jlockwood</dc:creator>
		<pubDate>Thu, 18 Oct 2007 21:27:26 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-86</guid>
		<description>I forgot my logon for AlamoCoders, I put the file here for the time being:
http://www.lostechies.com/files/folders/examplesource/entry1052.aspx
</description>
		<content:encoded><![CDATA[<p>I forgot my logon for AlamoCoders, I put the file here for the time being:<br />
<a href="http://www.lostechies.com/files/folders/examplesource/entry1052.aspx" rel="nofollow">http://www.lostechies.com/files/folders/examplesource/entry1052.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Chambers</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-85</link>
		<dc:creator>Sean Chambers</dc:creator>
		<pubDate>Thu, 18 Oct 2007 18:58:28 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-85</guid>
		<description>Lets use the alamo coders forum. That would be cool.

I will see about setting up a seperate Google Code repository for just this project. This way it isn&#039;t tied specifically to my code repository.

I have a couple of things to do this afternoon so I may not get to this stuff till tomorrow anyways.

ttyl!</description>
		<content:encoded><![CDATA[<p>Lets use the alamo coders forum. That would be cool.</p>
<p>I will see about setting up a seperate Google Code repository for just this project. This way it isn&#8217;t tied specifically to my code repository.</p>
<p>I have a couple of things to do this afternoon so I may not get to this stuff till tomorrow anyways.</p>
<p>ttyl!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jlockwood</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-84</link>
		<dc:creator>jlockwood</dc:creator>
		<pubDate>Thu, 18 Oct 2007 18:13:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-84</guid>
		<description>@Sean 
Tell us when and where...we could also use the AlamoCoders forum (the web nazis are less likely to block that).

I can get you my classes later today if you wish, I&#039;m in the middle of something right now.  </description>
		<content:encoded><![CDATA[<p>@Sean<br />
Tell us when and where&#8230;we could also use the AlamoCoders forum (the web nazis are less likely to block that).</p>
<p>I can get you my classes later today if you wish, I&#8217;m in the middle of something right now.  </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Ocampo</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-83</link>
		<dc:creator>Joe Ocampo</dc:creator>
		<pubDate>Thu, 18 Oct 2007 17:28:34 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-83</guid>
		<description>Sounds like a Plan.  Personally I was see how far we could take CS 2007. :-)</description>
		<content:encoded><![CDATA[<p>Sounds like a Plan.  Personally I was see how far we could take CS 2007. <img src='http://lostechies.com/seanchambers/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Chambers</title>
		<link>http://lostechies.com/seanchambers/2007/10/07/designbycontract-with-fluent-interfaces/#comment-82</link>
		<dc:creator>Sean Chambers</dc:creator>
		<pubDate>Thu, 18 Oct 2007 15:21:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2007/10/06/designbycontract-with-fluent-interfaces.aspx#comment-82</guid>
		<description>Wow, great points guys.

Josh, Can you supply the classes you have been using so we can take a look? I would like to expand my classes a little more when I have a chance.

I think I am going to start a FluentDBC google group so we can move the discussion there perhaps? The comments on this thread are getting a little long. 

What does everyone else think?</description>
		<content:encoded><![CDATA[<p>Wow, great points guys.</p>
<p>Josh, Can you supply the classes you have been using so we can take a look? I would like to expand my classes a little more when I have a chance.</p>
<p>I think I am going to start a FluentDBC google group so we can move the discussion there perhaps? The comments on this thread are getting a little long. </p>
<p>What does everyone else think?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
