<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Notes.Net</title>
	<atom:link href="http://notesdotnet.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://notesdotnet.wordpress.com</link>
	<description>Personal notes on software development (in France and England)</description>
	<lastBuildDate>Mon, 28 Nov 2011 13:01:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='notesdotnet.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Notes.Net</title>
		<link>http://notesdotnet.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://notesdotnet.wordpress.com/osd.xml" title="Notes.Net" />
	<atom:link rel='hub' href='http://notesdotnet.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Feed Moved</title>
		<link>http://notesdotnet.wordpress.com/2011/05/21/feed-moved/</link>
		<comments>http://notesdotnet.wordpress.com/2011/05/21/feed-moved/#comments</comments>
		<pubDate>Sat, 21 May 2011 20:55:07 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
		
		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=125</guid>
		<description><![CDATA[Yeah, and after moving to heroku, I also moved my feed to feedburner. Hope to get you following me there&#8230;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=125&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yeah, and after moving to heroku, I also moved my feed to <a title="my new feed" href="http://feeds.feedburner.com/SnowingCode">feedburner</a>. Hope to get you following me there&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=125&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2011/05/21/feed-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>Moving to heroku</title>
		<link>http://notesdotnet.wordpress.com/2011/03/20/moving-to-heroku/</link>
		<comments>http://notesdotnet.wordpress.com/2011/03/20/moving-to-heroku/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 12:24:25 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
		
		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=122</guid>
		<description><![CDATA[As part of my growing interest in the Ruby language, I&#8217;ve decided to write my own blog engine and continue my blog on heroku. Even though the site is not fully operational yet, you can already find new content and continue following me on http://nieve.heroku.com/ See you there!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=122&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As part of my growing interest in the Ruby language, I&#8217;ve decided to write my own blog engine and continue my blog on heroku.</p>
<p>Even though the site is not fully operational yet, you can already find new content and continue following me on <a title="Snowing Code" href="http://nieve.heroku.com/">http://nieve.heroku.com/</a></p>
<p>See you there!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=122&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2011/03/20/moving-to-heroku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>Functional DI and breaking language boundaries</title>
		<link>http://notesdotnet.wordpress.com/2010/09/16/functional-di-and-breaking-language-boundaries/</link>
		<comments>http://notesdotnet.wordpress.com/2010/09/16/functional-di-and-breaking-language-boundaries/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 23:24:55 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[Software craftsmanship]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=110</guid>
		<description><![CDATA[Today I received a priceless lesson on design, testability, Ioc and the way the boundaries of the development language we know may shape our thinking. It all started with a post by Derick Bailey on design and testability which lit a lively and truly interesting discussion. Derick was basically asking why people tend to demonise [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=110&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I received a priceless lesson on design, testability, Ioc and the way the boundaries of the development language we know may shape our thinking.  It all started with a post by Derick Bailey on design and testability which lit a lively and truly interesting discussion. Derick was basically asking why people tend to demonise TypeMock even though it bares strong similarities to ruby mocking frameworks which are usually hailed by the same people, giving an example of how we tend to abstract dependencies in c# through interfaces, like so:</p>
<p><pre class="brush: csharp;"> public class Foo
{
private doSomething;

public Foo(IDoSomething doSomething)
{
this.doSomething = doSomething;
}

public void Bar()
{
doSomething.DoSomething();
}
}</pre></p>
<p>It appears that with TypeMock we don&#8217;t have to have this abstraction<br />
if we wish to test the DoSomething method is being called inside Bar;<br />
we can just new up our IDoSomething implementation. This lead to a<br />
wave of comments from people saying that this abstraction isn&#8217;t there<br />
just for enabling testability, but quite simply functions as a better code design (ie dependency injection).</p>
<p>However, the main difference between the two platform, as it was put by Joshua Flanagan and Scott Bellware lays in the fact that all classes in ruby are open hence support for testability is provided in ruby within the language itself.</p>
<p>I was thinking about this question, trying to find another way to express  DI in c#, whilst attempting to reduce the superfluous abstractions, when the usage of delegations came to my mind, and I offered this solution:</p>
<p><pre class="brush: csharp;">public class Foo

{

 Baz _baz;

 public Foo(Baz baz){

 _baz = baz;

 }

 public void Bar()

 {

 _baz.DoSomething();

 }

}

public class Baz

{

 private Action _doSomething = () =&gt; Console.Write(&quot;doing something&quot;);

 //or throw NotImplemented...

 public Baz(){}

 public Baz (Action doSomething)

 {

 _doSomething = doSomething;

 }

 public void DoSomething(){

 _doSomething();

 }

}
</pre></p>
<p>And this is exactly where I&#8217;ve learned the most valuable lesson- Scott Bellware kindly enough provided a better solution to mine, in which he simply took out the redundant and, well, superfluous abstraction that was the Baz class and put the Action delegate directly in Foo. As obvious and trivial as it may seem, with a bit of refactoring or even stopping myself and taking the time to reflect a bit more on my solution I would have arrived to the same conclusion- no brain surgery. However, what I could see is that I still came up first with <em>this</em> solution rather than the other one. Even if I would have thought of the other only a minute after, still my mind reacted in this knee-jerk manner and spat out first this way of doing things. Bellware described it better:</p>
<p>&#8220;With the advent of callable objects in C# (Action, Predicate, and friends), command patterns can also be implemented using callable objects. However, there are years of habit-forming class-oriented implementation of command patterns backed up in idiomatic C#, and often command patterns fall back to the class-oriented habit even though there are now callable object alternatives.&#8221;</p>
<p>My mind is driven by the way I&#8217;m used to think in the language I use each and every day (c#) and in order to be able to break these language boundaries I will need to learn a new language, at least to be able to have different perspectives on issues I face on daily basis as a developer.</p>
<p>This fascinating <a href="http://www.nytimes.com/2010/08/29/magazine/29language-t.html?_r=1">nytimes article</a> discusses the way our mother tongue may shape our way of thinking. One of the most example the article brings is that of &#8216;geographical languages&#8217;, where directions are given only by geographical coordinates (north, south&#8230;). The concept of behind, infront etc&#8217; do not exist. The side-effect of speaking such a language can be quite far reaching- when put in a complete strange and unknown environment, geo-language speakers may lose their sense of orientation completely.</p>
<p>Learning new languages can help us get a new perspective on how we see things, how we perceive our surrounding and how we understand our reality. Sounds like a pretty cool thing to me <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Read more: <a href="http://www.lostechies.com/blogs/derickbailey/archive/2010/09/10/design-and-testability.aspx">On Design and Testability- Derick Bailey</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=110&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/09/16/functional-di-and-breaking-language-boundaries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>What can TDD do for your SRP?</title>
		<link>http://notesdotnet.wordpress.com/2010/06/04/what-can-tdd-do-for-your-srp/</link>
		<comments>http://notesdotnet.wordpress.com/2010/06/04/what-can-tdd-do-for-your-srp/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 21:03:55 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[PPP]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[SRP]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=106</guid>
		<description><![CDATA[A while ago I had the opportunity to do an MVC pagination kata, which proved to be a real educational and inspirational experience. One of the bits I had written was a class that created the pagination part as an html string, Pager.ToString(), using a StringBuilder it went through a chain of condition and added [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=106&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while ago I had the opportunity to do an MVC pagination kata, which proved to be a real educational and inspirational experience.</p>
<p>One of the bits I had written was a class that created the pagination part as an html string, Pager.ToString(), using a StringBuilder it went through a chain of condition and added some parts accordingly. for example I created a page number link for certain condition, or added the first, previous, next and last page links. These became methods inside my Pager class, so that my ToString() method won&#8217;t get too big. For example:</p>
<p><pre class="brush: csharp;">private void GetPageLink(int page)
 {
 string url = _linkProvider.GetCurrentLinkWithPageQuery(page);
_builder.Append(&quot;&lt;a class=\&quot;pageLink\&quot; href=\&quot;&quot; + url + &quot;\&quot; &gt;&quot; + page + &quot;&lt;/a&gt;&quot;);
}</pre></p>
<p>Now came the unit test trying to see whether the StringBuilder was called for each bit that was supposed to be added to our pager. Then, having my mind set to think Mocking-wise, I told myself if I get an interface to replace all these private &#8220;builder&#8221; methods, my code would become a lot more testable:</p>
<p><pre class="brush: csharp;">public interface IPagerBuilder
 {
 void AddLinkToLast();
 void AddLinkToNext();
 void SetPageNumberLink(int i);
 void AddLinkToPrev();
 void AddLinkToFirst();
 void SetPageLocationTitle(int pageIndex, int pageCount);
 string Build();
 }
</pre></p>
<p>And my tests like so (for example):</p>
<p><pre class="brush: csharp;">[Test]
 public void should_have_next_and_last_links()
 {
 paginatedList.Stub(l =&gt; l.IsPageCountLessThanRange).Return(false);
 paginatedList.PageIndex = 2;
 paginatedList.Stub(l =&gt; l.IsWithinStartingRange).Return(false);
 paginatedList.Stub(l =&gt; l.PageCount).Return(5);

 pager.ToString();

 pagerBuilder.AssertWasCalled(b=&gt;b.AddLinkToNext());
 pagerBuilder.AssertWasCalled(b =&gt; b.AddLinkToLast());
 }
</pre></p>
<p>But hang on, what&#8217;s been happening here was quite simply a separation of concerns, my pager class is now responsible for building my pager according to the conditions:</p>
<p><pre class="brush: csharp;">public override string ToString()
 {
 int halfRange = _paginatedList.Range / 2;

 _pagerBuilder.SetPageLocationTitle(_paginatedList.PageIndex, _paginatedList.PageCount);

 if (_paginatedList.IsPageCountLessThanRange)
 for (int i = 1; i &lt;= _paginatedList.PageCount; i++)
 _pagerBuilder.SetPageNumberLink(i);
 else
 {
 if (_paginatedList.PageIndex &gt; 1)
 {
 _pagerBuilder.AddLinkToFirst();
 _pagerBuilder.AddLinkToPrev();
 }

 if (_paginatedList.IsWithinStartingRange)
 for (int i = 1; i &lt;= _paginatedList.Range; i++)
 _pagerBuilder.SetPageNumberLink(i);
 else if (_paginatedList.IsWithinEndRange)
 {
 int startPage = (_paginatedList.PageCount - _paginatedList.Range) + 1;
 for (int i = startPage; i &lt;= _paginatedList.PageCount; i++)
 _pagerBuilder.SetPageNumberLink(i);
 }
 else
 {
 int startPage = _paginatedList.PageIndex - halfRange;
 for (int i = startPage; i &lt; startPage + _paginatedList.Range; i++)
 _pagerBuilder.SetPageNumberLink(i);
 }

 if (_paginatedList.PageIndex &lt; _paginatedList.PageCount)
 {
 _pagerBuilder.AddLinkToNext();
 _pagerBuilder.AddLinkToLast();
 }
 }

 return _pagerBuilder.Build();
}</pre></p>
<p>And the PagerBuilder class is a simple strategy that adds up html strings to a one big happy html string pager, without having to know a thing about when to add this or that bit, why and in what order. Did anyone say Single Responsibility Principal?</p>
<p>Funny thing is, a week after a colleague of mine came to me with the following question: He had a method in a service class that was validating some input from a view, only he had to use some repositories, and he asked me how could he test it. Needless to say, the answer here was a validator interface&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=106&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/06/04/what-can-tdd-do-for-your-srp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>FubuMVC Behaviours II</title>
		<link>http://notesdotnet.wordpress.com/2010/05/09/fubumvc-behaviours-ii/</link>
		<comments>http://notesdotnet.wordpress.com/2010/05/09/fubumvc-behaviours-ii/#comments</comments>
		<pubDate>Sun, 09 May 2010 13:25:46 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[Fubu]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[FubuMvc]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=101</guid>
		<description><![CDATA[In an older post I wrote about Behaviours in FubuMVC and tried to show how fubu can handle different concerns of your website. Now, while the post still is a good example of what we can do with fubu, especially regarding scenarios where mutual concerns of several pages (across the application) can be handled through one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=101&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In an older post I wrote about <a href="http://notesdotnet.wordpress.com/2010/02/21/fubumvc-behaviours/">Behaviours in FubuMVC</a> and tried to show how fubu can handle different concerns of your website. Now, while the post <em>still is</em> a good example of what we can do with fubu, especially regarding scenarios where mutual concerns of several pages (across the application) can be handled through one sole class (thus encouraging SRP), the solution I suggested in the post to the problem I&#8217;ve discussed was <em>far</em> too complex and inefficient compared to what can be achieved by the following way simpler solution.</p>
<p>Let&#8217;s work our way from bottom to top. First we&#8217;ll have a view model for our Site.master page, a class that will contain all that we want to display on each and every page having this master page:</p>
<p><pre class="brush: csharp;">public class SiteMasterModel
 {
 public IList&lt;Post&gt; History { get; set; }
 }
</pre></p>
<p>In our Site.master page we&#8217;ll have access to the model by having such a class the from which our master view will inherit:</p>
<p><pre class="brush: csharp;">public class SiteMasterView : FubuMasterPage&lt;SiteMasterModel&gt;
 {

}</pre></p>
<p>What&#8217;s left to do now is to create the Behavior that will take care of populating our blog posts History property of the SiteMasterModel, or for that matter any other master page concern.</p>
<p><pre class="brush: csharp;">public class MasterPageBehavior : BasicBehavior
 {
 private readonly IFubuRequest _request;
 private readonly IPostRepository _repository;

 public MasterPageBehavior(IFubuRequest request, IPostRepository repository)
 : base(PartialBehavior.Executes)
 {
 _request = request;
 _repository = repository;
 }

 protected override DoNext performInvoke()
 {
 _request.Set(new SiteMasterModel { History = _repository.GetHistory() });
 return base.performInvoke();
 }
}</pre></p>
<p>StructureMap would take care of injecting the IFubuRequest and IPostRepository (or IPostService or whatever you want to have) interfaces implementations you&#8217;ve got. How simple and elegant is that? What&#8217;s left after that would be to simply register our Behavior:</p>
<p><pre class="brush: csharp;">Policies.WrapBehaviorChainsWith&lt;MasterPageBehavior&gt;(); </pre></p>
<p>Not only the behaviour registration procedure is less complex, with this solution the display would be handled from within the master page, rather than from each and every view.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=101&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/05/09/fubumvc-behaviours-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>Composition vs Inheritance vs High Cohesion</title>
		<link>http://notesdotnet.wordpress.com/2010/04/25/composition-vs-inheritance-vs-high-cohesio/</link>
		<comments>http://notesdotnet.wordpress.com/2010/04/25/composition-vs-inheritance-vs-high-cohesio/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 09:14:23 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[PPP]]></category>
		<category><![CDATA[Software craftsmanship]]></category>
		<category><![CDATA[FubuMvc]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=91</guid>
		<description><![CDATA[A couple of months ago Chad Myers has posted a great post about the importance of using composition and its advantages over inheritance, in which he makes the case for (amongst others) using IoC container in order to minimize inheritance. He ends the post by saying that : Favoring object composition over class inheritance helps [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=91&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A couple of months ago Chad Myers has posted a <a href="http://www.lostechies.com/blogs/chad_myers/archive/2010/02/12/composition-versus-inheritance.aspx"><em><strong>great </strong></em>post</a> about the importance of using composition and its advantages over inheritance, in which he makes the case for (amongst others) using IoC container in order to minimize inheritance. He ends the post by saying that :</p>
<blockquote><p>Favoring object composition over class inheritance helps you keep each class encapsulated and focused on one task.  <em><strong>Your classes and class hierarchies will remain small and will be less likely to grow into unmanageable monsters</strong></em>.</p></blockquote>
<p>Now, the point I wanted to make is that the key to his post, or in other words to clean, small, easily maintained classes that would respect the single responsibility principle, would be found in the sentence just before the highlighted one- &#8221;object composition [...] <strong><em>helps you</em></strong> keep each class encapsulated&#8221;.</p>
<p>The project that we&#8217;re currently working on uses StructureMap as IoC container (and just for the record, not a day passes without me saying thanks to Jebus and Jeremy for providing us with StructureMap! ). The orders we&#8217;ve received from our project manager at the beginning of the project were very clear: each controller should depend on one service only, while services should remain as small as possible. Soon after our project manager was high-jacked to other projects and we were left on our own. Now, even though I understood very well what he meant by &#8220;don&#8217;t let your service to grow too big&#8221;, and remembered him showing me a service class from his preceding project that was more than a thousand lines long, I still struggle up to this day with services I&#8217;ve written myself, trying to find the time to refactor/split them into several different services. So where did it all go wrong?</p>
<p>So, yes, object composition indeed <em>helps you</em>, but it won&#8217;t do the job for you obviously. Personally, from what my experience have taught me, I could have really got it right the first time had I understood and grasped the idea of high cohesion. The first example that pops to my mind is a controller I&#8217;ve written for the creation of one of our bigger entities. I used composition when I&#8217;ve written the entity itself, seeing that it was too big and that it demanded a wizard-like user interface, so that each wizard step was encapsulated into an entity. However, I have failed to split the service into several ones, thus ended up <em>little by little</em> with an ever growing, massive class with far too many dependencies. Thing is, in this case the separation was needed in every layer,  so that my controller and the service dragged one another- since I had one controller only to take care of the entire creation process, and the controller was dependant on one service only, I found myself with a service class that is a nightmare to maintain.</p>
<p><a href="http://en.wikipedia.org/wiki/Cohesion_(computer_science)">From Wikipedia</a>:</p>
<blockquote><p>cohesion is a measure of how strongly-related or focused the responsibilities of a single module are. [...] If the methods that serve the given class tend to be similar in many aspects, then the class is said to have high cohesion. In a highly-cohesive system, code readability and the likelihood of reuse is increased, while complexity is kept manageable.</p>
<p>Cohesion is decreased if:[...]</p>
<ul>
<li>Methods carry out many varied activities</li>
</ul>
</blockquote>
<p>Clearly, the whole creation process of this complex entity wasn&#8217;t supposed to  be contained in a sole controller/service.</p>
<p>Failing to understand all that, I managed to bloat one of the layers of our application, while using DI. Some of our services more than 15 dependencies in their constructors!</p>
<p>On top of that, using MSMVC&#8217;s magic strings everywhere made the refactoring and splitting of controllers (and thus of services) an extremely difficult task. This is a case where the advantage of FubuMVC over MSMVC is very clear <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=91&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/04/25/composition-vs-inheritance-vs-high-cohesio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>On SRP and staying DRY</title>
		<link>http://notesdotnet.wordpress.com/2010/04/04/on-srp-and-staying-dry/</link>
		<comments>http://notesdotnet.wordpress.com/2010/04/04/on-srp-and-staying-dry/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 09:44:53 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Fubu]]></category>
		<category><![CDATA[PPP]]></category>
		<category><![CDATA[Software craftsmanship]]></category>
		<category><![CDATA[FubuMvc]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=84</guid>
		<description><![CDATA[A couple of weeks ago Chad Myers posted a message on the Fubu group explaining the difference between Fubu and MS MVC. This was definitely an Eureka moment for me- suddenly SRP made sense to me and it all clicked into place. In his message, Chad says: Front Controller is also about composing the response. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=84&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago <a href="http://www.lostechies.com/blogs/chad_myers/">Chad Myers</a> posted a <a href="http://groups.google.com/group/fubumvc-devel/msg/f2293b575efbc4c8?hl=en">message</a> on the Fubu group explaining the difference between Fubu and MS MVC. This was definitely an Eureka moment for me- suddenly SRP made sense to me and it all clicked into place. In his message, Chad says:</p>
<blockquote><p>Front Controller is also<br />
about composing the response.  Sometimes  the view needs more information<br />
than what is relevant to the &#8220;meat&#8221;  of the request (i.e. displaying the<br />
login page may involve  displaying advertisements or notifications, etc that<br />
are not  necessarily the responsibility of the Login action).</p></blockquote>
<p>The first thing that popped into my mind was the parent controller Uber class we&#8217;ve got in the project I&#8217;m working on currently. In it we deal with security and authentication issues, we deal with requests for downloading help files for each and every page in the web site, we deal with maintenance scenarios when the site would need to be down and so on. Needless to say, the number of ifs we&#8217;ve got there is starting to get rather unhealthy and the thought of making any changes to any of these responsibilities/logics makes me shudder; with fubu, we could have had a Behaviour for each concern/responsibility. Although this might be a rather extreme example of the Single Responsibility Principle (1 method &#8211; 1 responsibility), it is usually clear cut examples that make you grasp the idea fully and understand what were you doing wrong all that time.</p>
<p>From what I&#8217;ve experienced up until now, the first sign that makes me look for SRP violations is a forced application of the DRY principle, attempting to mutualise code/logic that seems to be similar and treating the same sort of a scenario. A great example for that scenario was a little feature I had to add a week ago, in which I was supposed to allow the users to subscribe people, while creating their program. We already had a very similar feature that allows the users of the application to subscribe people on their program after the latter has been created. My colleague thought we could simply reuse the views and actions we already created. That was a good enough sign for me to get some more explanations about the process of subscribing someone to your program while creating it, and needless to say it turned out that &#8220;it would be exactly the same thing, only&#8230;&#8221; and this &#8216;but&#8217; made changes to some data access logic we had and the way we use NHibernate to get this data. We ended up separating these two scenarios and the best thing is that we&#8217;ve gained a lot in doing so in terms of maintainability <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=84&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/04/04/on-srp-and-staying-dry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>My DSL experience</title>
		<link>http://notesdotnet.wordpress.com/2010/03/20/my-dsl-experience/</link>
		<comments>http://notesdotnet.wordpress.com/2010/03/20/my-dsl-experience/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 15:50:35 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[Fubu]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[FubuMvc]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=81</guid>
		<description><![CDATA[A couple of days ago my recent pull request for FubuMVC has been accepted- a feature I&#8217;ve been working on that allows registering through conventions the partial view that would be used for a certain partial model. This meant writing some DSL which was a first time for me. In case anyone stumbles upon this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=81&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago my recent pull request for FubuMVC has been accepted- a feature I&#8217;ve been working on that allows registering through conventions the partial view that would be used for a certain partial model. This meant writing some DSL which was a first time for me.</p>
<p>In case anyone stumbles upon this entry and wants to find out more about what is DSL and how to do it properly, I will recommend you to head straight towards <a href="http://msdn.microsoft.com/en-us/magazine/ee291514.aspx">Jeremy D. Miller&#8217;s thorough article on the subject</a>.</p>
<p>My target was simply to allow the developer to write</p>
<p><pre class="brush: csharp;"> types.For&lt;MyPartialModel&gt;().Use&lt;MyPartialView&gt;();</pre></p>
<p>In order to do that I added the following:</p>
<ol>
<li>IPartialViewTypeRegistry</li>
<li>IPartialViewTypeBindingExpression</li>
<li>IPartialViewTypeRegistrationExpression</li>
</ol>
<p>The registry would register each partial model type to its partial view type, the latter being a page (implementing IFubuPage). At first I had my registry containing also the For method which passed the partial model type and returned a binding expression which contains only the Use method so that the user could only tell the registry to use the view for the model (so that the Use method was &#8216;void&#8217;).</p>
<p>Afterwards I added the registration expression in order to hide the registry interface. The registration expression contains only the For&lt;TPartialModel&gt;() method.<br />
Inside the FubuRegistry I added then the following method:</p>
<p><pre class="brush: csharp;">public void RegisterPartials(Action&lt;IPartialViewTypeRegistrationExpression&gt; registration)
 {
 var expression = new PartialViewTypeRegistrationExpression(_partialViewTypes);
 registration(expression);
}</pre></p>
<p>That way, the IPartialViewTypeRegistry instance (the _partialViewTypes field) is completely hidden.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=81&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/03/20/my-dsl-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>Redirecting in Fubu</title>
		<link>http://notesdotnet.wordpress.com/2010/03/06/redirecting-in-fubu/</link>
		<comments>http://notesdotnet.wordpress.com/2010/03/06/redirecting-in-fubu/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 23:45:14 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[Fubu]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[FubuMvc]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=71</guid>
		<description><![CDATA[This is a very straight forward post, just a reminder of how do you redirect and transfer in FubuMVC. Using the FubuDinner example, we have a registration page, and its GET action: Now, in our POST method we&#8217;d like to log on the user and redirect to our Home page if the registration went ok [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=71&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a very straight forward post, just a reminder of how do you redirect and transfer in FubuMVC.</p>
<p>Using the FubuDinner example, we have a registration page, and its GET action:</p>
<p><pre class="brush: csharp;">public RegisterModel Query(RegisterModel input)
 {
 input.PasswordLength = _settings.MinPasswordLength;
return input;
}</pre></p>
<p>Now, in our POST method we&#8217;d like to log on the user and redirect to our Home page if the registration went ok (validated and persisted); however, if the registration wasn&#8217;t validated, we&#8217;d like to get back to our registration page, display the error messages and keep the data the user has entered.</p>
<p>This is how the POST method would look like than:</p>
<p><pre class="brush: csharp;">public FubuContinuation Command(RegisterForm input)
 {
 var errors = _validator.Validate(input);

 //TODO: need unique username validation

 if( input.Nerd.Password != input.ConfirmPassword )
 {
 errors.RegisterFailure(&quot;ConfirmPassword&quot;, &quot;Confirm password must match password exactly.&quot;);
 }

 if( errors.IsValid())
 {
 _repository.Save(input.Nerd);
 _authContext.ThisUserHasBeenAuthenticated(input.Nerd.Username, false);
 return FubuContinuation.RedirectTo(new HomeModel());
 }

 return FubuContinuation.TransferTo(new RegisterModel { Errors = errors, Nerd = input.Nerd, ConfirmPassword = input.ConfirmPassword });
}</pre></p>
<p>Simples!</p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:91px;width:1px;height:1px;">﻿</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=71&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/03/06/redirecting-in-fubu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
		<item>
		<title>FubuMVC Behaviours</title>
		<link>http://notesdotnet.wordpress.com/2010/02/21/fubumvc-behaviours/</link>
		<comments>http://notesdotnet.wordpress.com/2010/02/21/fubumvc-behaviours/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 14:27:37 +0000</pubDate>
		<dc:creator>Nieve</dc:creator>
				<category><![CDATA[Fubu]]></category>
		<category><![CDATA[FubuMvc]]></category>

		<guid isPermaLink="false">http://notesdotnet.wordpress.com/?p=66</guid>
		<description><![CDATA[In an old post Mark Nijhof talked about the way Fubu can handle different concerns of your website. He explains that with Fubu we can add &#8216;behaviours&#8217; in order to get certain data that needs to be displayed on certain pages in certain contexts; in other words different concerns could be treated in different places. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=66&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In an old post Mark Nijhof talked about <a href="http://blog.fohjin.com/blog/2009/5/31/FubuMVC_NNUG_Presentation">the way Fubu can handle different concerns of your website</a>. He explains that with Fubu we can add &#8216;behaviours&#8217; in order to get certain data that needs to be displayed on certain pages in certain contexts; in other words different concerns could be treated in different places.</p>
<p>Suppose we want to display the list of the most recent posts of our blog. First, we should have an interface for all of our ViewModels that would have to render the recent posts list:</p>
<p><pre class="brush: csharp;">public interface IRecentPostsModelBase
 {
IList&lt;Post&gt; RecentPosts { get; set; }
}</pre></p>
<p>and each view model that would need to display these posts would implement our interface.</p>
<p><pre class="brush: csharp;"> public class OutputBehaviour : BasicBehavior
 {
 private readonly IFubuRequest _request;
 private readonly IPostRepository _postRepository;

 public OutputBehaviour(IFubuRequest request) : base(PartialBehavior.Ignored)
 {
_request = request;
 }

 protected override DoNext performInvoke()
 {
IRecentPostsModel recentPostsModel = null;
foreach (IRecentPostsModel model in _request.Find&lt;IRecentPostsModel&gt;())
recentPostsModel = model;
if (recentPostsModel != null)
{
recentPostsModel.RecentPosts = _postRepository.GetRecentPosts();
_request.SetObject(recentPostsModel);
}
return base.performInvoke();
 }
}</pre></p>
<p>Now, we are going to insert our behaviour directly after the OneInOneOutActionInvoker default fubu behaviour that sets the output view model in the current FubuRequest. That way, our behaviour will be able to add/inject the recent posts into the output model view after it has been initialised, after the controller action has been invoked, but before the view has been rendered and the output model has been used:</p>
<p><pre class="brush: csharp;">public class MyPolicy : IConfigurationAction
 {
 public void Configure(BehaviorGraph graph)
 {
graph.Behaviors.Where(c =&gt; c.ContainsCall(a=&gt;a.OutputType().GetInterfaces().Contains(typeof(IRecentPostsModelBase))))
 .Each(InsertBehaviours);
 }

 private void InsertBehaviours(BehaviorChain c)
 {
Wrapper node = new Wrapper(typeof (OutputBehaviour));
c.Top.InsertDirectlyAfter(node);
node.InsertDirectlyAfter(new Wrapper(typeof(MyBehaviour)));
 }
}</pre></p>
<p>Inside the Configure method we&#8217;re filtering the behaviours with an ActionCall having an output type implementing IRecentPostsModelBase. The graph.Behaviors property contains a behaviour per action (ie if you have only two pages with two corresponding actions, the Behaviors property would have two chains).</p>
<p>Last thing we need to do would be registering our behaviour in our FubuRegistry, like so:</p>
<p><pre class="brush: csharp;">Policies.Add(new MyPolicy());</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/notesdotnet.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/notesdotnet.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/notesdotnet.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/notesdotnet.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/notesdotnet.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/notesdotnet.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/notesdotnet.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/notesdotnet.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/notesdotnet.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/notesdotnet.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/notesdotnet.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/notesdotnet.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/notesdotnet.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/notesdotnet.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=notesdotnet.wordpress.com&amp;blog=11039557&amp;post=66&amp;subd=notesdotnet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://notesdotnet.wordpress.com/2010/02/21/fubumvc-behaviours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3ad29b70efd8dfcc6466ce23ce6ba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">suburbia</media:title>
		</media:content>
	</item>
	</channel>
</rss>
