<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5858898768007132818</id><updated>2012-01-08T03:37:08.761-08:00</updated><category term='C#'/><category term='Code First'/><category term='JQuery'/><category term='Architecture'/><category term='Agile'/><category term='clean code'/><category term='BDD'/><category term='Projects'/><category term='Git-Tfs'/><category term='NUI'/><category term='DDD'/><category term='Multi-touch'/><category term='FubuMVC'/><category term='Design Patterns'/><category term='WPF'/><category term='Announcements'/><category term='ASP.NET'/><category term='Web'/><category term='Testing'/><title type='text'>WebDevLog</title><subtitle type='html'>An empassioned blog about the joys of web development. Focused on ASP.NET but with an intrigue for action anywhere in WebDev-o-sphere.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-5482219264554903</id><published>2012-01-08T03:37:00.000-08:00</published><updated>2012-01-08T03:37:08.778-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='FubuMVC'/><title type='text'>2011 Conceptual Web Framework Utopia – Part 2, Testing</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h1
 {mso-style-link:"Heading 1 Char";
 margin-top:24.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:14.0pt;
 font-family:"Cambria","serif";
 color:#365F91;}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
pre
 {mso-style-link:"HTML Preformatted Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:10.0pt;
 font-family:"Courier New";}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
 {margin:0cm;
 margin-bottom:.0001pt;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading1Char
 {mso-style-name:"Heading 1 Char";
 mso-style-link:"Heading 1";
 font-family:"Cambria","serif";
 color:#365F91;
 font-weight:bold;}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.HTMLPreformattedChar
 {mso-style-name:"HTML Preformatted Char";
 mso-style-link:"HTML Preformatted";
 font-family:"Courier New";}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;br /&gt;
&lt;div class="WordSection1"&gt;
&lt;div class="MsoNormal"&gt;
This short series of posts represents a snapshot of my
thinking at the end of 2011, in terms of how I would ideally produce web
applications using the .NET platform. In this, part 2, I’m going to cover my current testing strategy and preferences.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For this post, the plan is:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;General&amp;nbsp;
Testing &lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Endpoint
Testing, using the Endpoint Testing Pattern&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Database
Testing with RavenDb&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I won’t be talking about higher-level tests or BDD that
drive the TDD. The only variable there is the frameworks, which are generally
interchangeable. &lt;/div&gt;
&lt;h2&gt;
General Testing &lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
My unit tests need to be fast, and they need to be readable
– no interacting with databases then. See the last section for that.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
To make unit tests readable I treat them as high-importance
code. This doesn’t mean I take any longer, it means I have three simple rules
that I nearly always use:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Keep
them short (3 lines is optimal, 7 means I don’t get to eat for the day)&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Hide
assertions inside extension methods that read well (just like the GOOS boys)&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Wrap
setup code in methods too&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;Test&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Get_GivenIdForExistingBook_ShouldReturnViewModel_WithBooksDetails()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;book&amp;nbsp;=&amp;nbsp;GetRandomBookSimulatedToExist();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;viewModel&amp;nbsp;=&amp;nbsp;endpoint.Get(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;UpdateBookLinkModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;{Id&amp;nbsp;=&amp;nbsp;book.Id});&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; viewModel.ShouldHaveDetailsFor(book);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Above is an example of what I consider to be an ideal test.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Context Specifications&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
With the above preferences applied, most of the time there
are just 3 - 5 line test methods that follow like a given, when then. Sometimes,
though, it really makes sense to use a context specification. &lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;SetUp&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;WhenRequestingABookReview_AndTheSystemContainsBooks_WithDifferentGenres()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;retriever&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;MockRepository&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.GenerateMock&amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;IBookRetriever&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;endpoint&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;ViewEndpoint&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(retriever);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;book&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;BookTestingHelper&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.GetBook(rating:&amp;nbsp;4);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; retriever.Stub(r&amp;nbsp;=&amp;gt;&amp;nbsp;r.GetById(book.Id)).Return(book);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SetupBookForSameGenreIncludingReviewBook();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;    retriever.Stub(r&amp;nbsp;=&amp;gt;&amp;nbsp;r.GetReviewedBooks(book.Genre.Id)).Return(allBooksForSameGenre);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; viewModel&amp;nbsp;=&amp;nbsp;endpoint.Get(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;ViewBookLinkModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;{&amp;nbsp;Id&amp;nbsp;=&amp;nbsp;book.Id&amp;nbsp;});&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Test&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;ViewModelShouldHaveBooksTitle()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Assert&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.AreEqual(book.Title,&amp;nbsp;viewModel.Title);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Test&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;ViewModelShouldHaveBooksGenreName()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Assert&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.AreEqual(book.Genre.Name,&amp;nbsp;viewModel.GenreName);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Test&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;ViewModelShouldHaveBooksRating()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Assert&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.AreEqual(book.Rating,&amp;nbsp;viewModel.Rating);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
If you look at the &lt;a href="https://github.com/NTCoding/FubuRaven.NTCoding.com/blob/master/src/tests/Web.Tests/Books/Public/MappingBookToAViewBookViewModel.cs"&gt;full
source code&lt;/a&gt; for this class you’ll see there are another 6 tests below it. I
think in this case it was the most readable way to test.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;When Do They Run?&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Always - these are the general tests that form part of the
main suite for giving immediate feedback about any regressions.&lt;/div&gt;
&lt;h2&gt;
Endpoint Testing &lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
In &lt;a href="http://www.ntcoding.blogspot.com/2011/12/2011-conceptual-web-framework-utopia.html"&gt;part
1&lt;/a&gt; my diagram mentioned “Endpoint-specific models”. This includes link
(usually called request), view, and input models. By having them specific to
each endpoint, the models are tested as part of the endpoint tests and not
alone. I refer to this mentallly as the endpoint testing pattern, but it is not an official
term.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For example:&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;Test&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Get_GivenIdForExistingBook_ShouldReturnViewModel_WithBooksDetails()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;book&amp;nbsp;=&amp;nbsp;GetRandomBookSimulatedToExist();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;viewModel&amp;nbsp;=&amp;nbsp;endpoint.Get(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;UpdateBookLinkModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;{Id&amp;nbsp;=&amp;nbsp;book.Id});&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; viewModel.ShouldHaveDetailsFor(book);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
This test covers the endpoint and the models. There would be
no additional tests for the models – they only exist to serve one action method
on this endpoint so don’t need it.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Update Scenario&lt;/b&gt;&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Test&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;Post_GivenUpdateModel_ShouldCreateDtoAndPassToBookUpdater()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;model&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;UpdateBookInputModel&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genre&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"genres/9"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BookStatus&amp;nbsp;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;BookStatus&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.Reviewed,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Title&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Updated&amp;nbsp;title"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"books/444"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rating&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;nbsp;&amp;nbsp;3,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Description_BigText&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Updated&amp;nbsp;description"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;endpoint.Post(model);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;updater.ShouldHaveBeenCalledWithDtoMatching(model);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For these scenarios, a simple assertion is made that a
service was called. Anything more involved than that is probably logic that
doesn’t live there in an ideal world.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;When Do They Run?&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
These will be ultra-fast tests that are part of the main
suite of tests. Every time there is a change in code, these get run to check
for regressions.&lt;/div&gt;
&lt;h2&gt;
Database Testing With RavenDb&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
I’ve specifically name-dropped RavenDb because
this is my utopia. In this world, we eat, sleep and breathe RavenDb for data
access because it makes life a lot easier. You get all the benefits of
NHibernate’s session, transactions &amp;amp; POCOs, without any of the pain of the
SQL mapping or performance disasters.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Another benefit of RavenDb is the testing support. In fact,
this is fantastic. A mini Ayende sits their inside your pc spinning up an
instance of his document database &lt;b&gt;in your computer’s memory. &lt;/b&gt;As far as
I’m aware, this works exactly the same as a normal instance of the database.
None of those SQL Lite – SQL Server mismatches.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Here’s a data
access test:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Test&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;GetWishlistBooks_ShouldOnlyReturnBooks_OnTheWishlist()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PopulateSessionWithBooksOfDifferentStatus();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Session.SaveChanges();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;fromSession&amp;nbsp;=&amp;nbsp;Session.Query&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Book&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;().Where(b&amp;nbsp;=&amp;gt;&amp;nbsp;b.Status&amp;nbsp;==&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;BookStatus&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.Wishlist);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;fromRetriever&amp;nbsp;=&amp;nbsp;retriever.GetWishlistBooks();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.AreEqual(fromSession,&amp;nbsp;fromRetriever);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Here is how the session is setup for testing….&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;abstract&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;class&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;RavenTestsBase&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;IDocumentSession&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;Session;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;EmbeddableDocumentStore&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;store;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;SetUp&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;SetUp()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; store&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;EmbeddableDocumentStore&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Configuration&amp;nbsp;=&amp;nbsp;{RunInMemory&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;true&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; store.Initialize();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Session&amp;nbsp;=&amp;nbsp;store.OpenSession();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;TearDown&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;TearDown()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Session.Dispose();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
…..I agree - someone is taking the piss. This is so simple
I’m worried the cleaner will take my job.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;So You Run This With Your Main Test Suite?&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
They’re fast, but they’re no Ussain Bolt on happy pills….. I
run these when any data access code changes and before important commits.&lt;/div&gt;
&lt;h2&gt;
Conclusion&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
I hope you enjoyed reading about my testing preferences and
conventions. Whether you agree with them or not, it’s important to tell
yourself how you think the best way to do something is. This gives you a point
of reference to take on and incorporate new information – it helps you to
improve… and socialise with other developers in the pub.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The most important part is having conventions about how you
test. This lets you create consistent tests, that require less cognitive
resource to create, maintain and read. You can then put more focus on
delivering software and understanding the problem domain.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
In part 3 I’ll show you some of my other preferences for web
frameworks. Most of them have been learned by playing with FubuMVC.&lt;/div&gt;
&lt;h2&gt;
&amp;nbsp;&lt;/h2&gt;
&lt;h2&gt;
&amp;nbsp;&lt;/h2&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-5482219264554903?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/5482219264554903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2012/01/2011-conceptual-web-framework-utopia.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/5482219264554903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/5482219264554903'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2012/01/2011-conceptual-web-framework-utopia.html' title='2011 Conceptual Web Framework Utopia – Part 2, Testing'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-5171882916618224677</id><published>2012-01-01T10:14:00.000-08:00</published><updated>2012-01-01T10:14:55.142-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 8</title><content type='html'>&lt;b&gt;Chapter 15 - Distillation&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Identify the core domain and make it small&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Identity of the core domain should evolve through iterations&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Create a short domain vision statement and revise it as you gain new insights&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;A domain vision statement gives the team shared direction&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Different forms of highlighted core are useful for easily representing the important parts of the core domain eg. distillation document, flagged core&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Make it effortless for a developer to know what is in or out of the core&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Domain vision statements work in synergy e.g. with a segregated core&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 16 - Large Scale Structures&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Large systems that have well grouped modules and bounded contexts can still become unintelligible when there are many of them&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Be prepared to drop a system metaphor if it gives poor guidance&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Combine layered architecture with responsibility-driven design to achieve responsibility layers&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Knowledge models may be appropriate when the roles and responsibilities in a domain can change at runtime&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Pluggable component frameworks don't easily allow constant refactoring of the core domain&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Large scale structures must enter the ubiquitous language&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 17 - Bringing the Strategy Together&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;The three basic principles of strategic design are complementary&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Context&lt;/li&gt;
&lt;li&gt;Distillation&lt;/li&gt;
&lt;li&gt;Large-scale structure&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;When tackling strategic design:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Draw a context map&lt;/li&gt;
&lt;li&gt;Verify ubiquitous language is correctly in use&lt;/li&gt;
&lt;li&gt;Verify there is a core domain and vision statement&lt;/li&gt;
&lt;li&gt;Does the technology choice work for model driven design?&lt;/li&gt;
&lt;li&gt;Does dev team have the skills?&lt;/li&gt;
&lt;li&gt;Does dev team have knowledge and interest in the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Design decisions must reach the entire team
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-5171882916618224677?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/5171882916618224677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2012/01/ddd-notes-from-big-blue-book-part-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/5171882916618224677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/5171882916618224677'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2012/01/ddd-notes-from-big-blue-book-part-8.html' title='DDD - Notes from the big blue book. Part 8'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-5284216654978687873</id><published>2011-12-18T06:22:00.000-08:00</published><updated>2011-12-18T06:22:20.175-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><category scheme='http://www.blogger.com/atom/ns#' term='Design Patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='Architecture'/><category scheme='http://www.blogger.com/atom/ns#' term='FubuMVC'/><title type='text'>2011 Conceptual Web Framework Utopia – Part 1, “Architecture”</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Tahoma;
 panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
h3
 {mso-style-link:"Heading 3 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:11.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
h4
 {mso-style-link:"Heading 4 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:11.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-style:italic;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
pre
 {mso-style-link:"HTML Preformatted Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:10.0pt;
 font-family:"Courier New";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 {mso-style-link:"Balloon Text Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:8.0pt;
 font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.Heading3Char
 {mso-style-name:"Heading 3 Char";
 mso-style-link:"Heading 3";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.Heading4Char
 {mso-style-name:"Heading 4 Char";
 mso-style-link:"Heading 4";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;
 font-style:italic;}
span.HTMLPreformattedChar
 {mso-style-name:"HTML Preformatted Char";
 mso-style-link:"HTML Preformatted";
 font-family:"Courier New";}
span.BalloonTextChar
 {mso-style-name:"Balloon Text Char";
 mso-style-link:"Balloon Text";
 font-family:"Tahoma","sans-serif";}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;br /&gt;
&lt;div class="WordSection1"&gt;
Bad experiences scar us - forcing us to learn for our own
survival. This evolutionary theory can also be applied to software. If you don’t
learn from your mistakes, you’ll soon be on this guy’s plate:
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-58aUYZqTZj0/Tu301SG2bXI/AAAAAAAAAEY/HymuEsaRKNM/s1600/sabre.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-58aUYZqTZj0/Tu301SG2bXI/AAAAAAAAAEY/HymuEsaRKNM/s1600/sabre.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So when creating web apps, what have my survival instincts
really taught me?&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
They’ve taught me that almost nothing applies universally. Since
I generally create larger-scale web apps, this article applies primarily to
that context. Even in this context, though, trade-off benefits will vary for
specific circumstances.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
They’ve also taught me to isolate the domain, keep the web
layer thin and listen to the wise words of people of like Uncle Bob, Udi Dahan
&amp;amp; Eric Evans. They’ve even taught me (via Udi Dahan) to “justify why the
simplest possible thing isn’t enough” – so expect lots of that too.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
In this series of blog posts - &lt;b&gt;&lt;i&gt;reflecting my current
thinking&lt;/i&gt;&lt;/b&gt; - I will be showing:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;The
“Architecture” (clarify the quotes the later)&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;My
unit testing strategy&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;A
few other preferred patterns &lt;/div&gt;
&lt;h2&gt;



What Does it Look Like?&lt;/h2&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-COkekqyp89s/Tu31KiUZ6FI/AAAAAAAAAEg/3snmujNfcPs/s1600/Arch_SingleDomainCropped.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="312" src="http://4.bp.blogspot.com/-COkekqyp89s/Tu31KiUZ6FI/AAAAAAAAAEg/3snmujNfcPs/s640/Arch_SingleDomainCropped.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
First, when I talk about architecture, I apply it generally
and mean any component of the system as a whole – not just the domain. This
contradicts Uncle Bob and may be wrong, but I couldn’t think of another phrase
that would be understood that encompassed domain and delivery mechanism(s).&lt;/div&gt;
&lt;h3&gt;



One Model In One Model Out &amp;amp; Endpoint-specific Models&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
A recent addition I picked up is the OMIOMO (one model in
one model out) convention from fubumvc – each action receives a request or
input model and returns a view model (or some other model). &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
By making these models specific to each action, they are
very simple data structures – keeping cognitive load to a minimum. It also
saves you from having shared view models that introduce bugs when they change
for one view and cause another to break.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Endpoint-specific models facilitate the &lt;b&gt;Endpoint Testing
Pattern&lt;/b&gt; – discussed in part 2.&lt;/div&gt;
&lt;h3&gt;



Endpoints Talk to Domain Services in DTO Language&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Transfer of information between endpoints/controllers and
domain services is through simple DTO data structures.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Here’s an example:&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Endpoint using a query service&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;CreateBookViewModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Get(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;CreateBookLinkModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;model)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IEnumerable&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;GenreDto&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;gt;&amp;nbsp;genres&amp;nbsp;=&amp;nbsp;genreRetriever.GetAllOrderedByName();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;CreateBookViewModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;(genres);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Implementation of query service&lt;/b&gt;&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;GenreDto&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&amp;nbsp;GetAllOrderedByName()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;genres&amp;nbsp;=&amp;nbsp;session&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Query&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Genre&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .OrderBy(g&amp;nbsp;=&amp;gt;&amp;nbsp;g.Name);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;genres.Select(g&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;GenreDto&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;{Id&amp;nbsp;=&amp;nbsp;g.Id,&amp;nbsp;Name&amp;nbsp;=&amp;nbsp;g.Name});&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;bool&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;CanFindGenreWith(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;string&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;id)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;session.Query&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Genre&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;().Count(g&amp;nbsp;=&amp;gt;&amp;nbsp;g.Id&amp;nbsp;==&amp;nbsp;id)&amp;nbsp;&amp;gt;&amp;nbsp;0;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;



Why Bother with DTOs?&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Critically, the use of DTOs protects the domain &lt;i&gt;and &lt;/i&gt;your
application – the contract between your application and domain is a lightweight
data structure. With this loose contract, the domain model is free to evolve –
and when you’re applying DDD, with the need to refactor often and sometimes aggressively
– your domain model has no outside concerns to worry about.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
When you do apply domain refactorings, as long as you still
meet the contract – the DTO – your application remains unaffected.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I won’t explain the &lt;b&gt;business value &lt;/b&gt;&amp;nbsp;of DDD.&lt;/div&gt;
&lt;h3&gt;



Why Separate Services to Query and Command?&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
A philosophy in CQRS is to separate reads and writes for architectural
flexibility. At the heart it is a simple pattern. Generally it appears to be
used when reads and writes have a separate data model – but in my case, the domain
data model is hidden – so it could be the same or different – we have the
flexibility. But what about the cost……&lt;/div&gt;
&lt;h3&gt;



Isn’t Hiding Your Data Access Bad?&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
In &lt;a href="http://ayende.com/blog/4786/the-wages-of-sin-over-architecture-in-the-real-world"&gt;some&lt;/a&gt;
cases – yes. But for my example, I’d argue – no….domain isolation is worth it.
It is a very thin layer, two mouse clicks away and one interface agreement.
Data access needs to know domain entities and the underlying data model – to gain
the benefits of DDD we don’t want to expose that to the application layers.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I think a thin layer of domain service implementations (not
interfaces) that take a dependency on the data access is ok. Some people put
them in a separate project, some people chuck it all in the controller – I like
this middle ground.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Data access is a tricky, context-specific beast that this is
probably the least prescriptive of my ideals.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Using this pattern and RavenDb also gives rise to a good
strategy for comprehensive testing of data access – you’ll see that in part 2
as well.&lt;/div&gt;
&lt;h4&gt;



An Example From the Wild&lt;/h4&gt;
&lt;div class="MsoNormal"&gt;
You start out with a synchronous N-Tier application, but your
domain model rapidly evolves – with the DTOs being passed between boundaries
this is no more difficult than necessary because the domain is isolated.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Suddenly you have multiple bounded contexts, sharing aspects
of what once was a single domain entity - so you want to switch to an
asynchronous messaging based architecture. As long as you have a separate
service for queries and commands, with your data model hidden, you can focus
totally on the domain and its contract to the outside world – DTOs.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For those thinking this doesn’t happen – it is the exact
situation I am in with the contract I am working on, and appears not uncommon
from what I hear elsewhere. If the application followed these principles,
changes would be isolated to the domain and we’d only have to worry about
meeting service interface criteria – unfortunately there are swathes of
inter-twined spaghetti code all through the application &lt;i&gt;and&lt;/i&gt; domain that
are affected – &lt;b&gt;there’s your business value, son&lt;/b&gt;.&lt;/div&gt;
&lt;h2&gt;



So…..&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Cowboys have their opinion, those in ivory towers voice
quite another. But experience and practice are crucial in finding out what really
works and the contexts in which the arguments put forward by each are
favourable.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Reflecting on experiences, using personal projects to test
assumptions and try new ideas is a great way to get closer to that firm-footing
of reality. If you keep doing the same – you’ll keep getting the same. I was
pretty bored of those domain entity model binding issues and domain refactorings
causing crippling breakages in my web layer - so here’s a small conceptual
step, less destined for failure.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Also when you write posts like these, you force yourself to
double-check blog posts and podcasts – just to make sure you correctly
understood the topic. This reinforces what you’ve learnt, also saving you from
any false assumptions you may be carrying on your sleeve.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Tune in for part 2.&lt;/div&gt;
&lt;h2&gt;



Related Shizz&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Martin Fowler, CQRS - &lt;a href="http://martinfowler.com/bliki/CQRS.html"&gt;http://martinfowler.com/bliki/CQRS.html&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Uncle Bob, Web Architecture&amp;nbsp; - &lt;a href="http://www.cleancoders.com/codecast/clean-code-episode-7/show"&gt;http://www.cleancoders.com/codecast/clean-code-episode-7/show&lt;/a&gt;
AND &lt;a href="http://skillsmatter.com/podcast/design-architecture/uncle-bob-web-architecture"&gt;http://skillsmatter.com/podcast/design-architecture/uncle-bob-web-architecture&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Udi Dahan talk on SOA - &lt;a href="http://skillsmatter.com/podcast/open-source-dot-net/qa-with-udi-dahan"&gt;http://skillsmatter.com/podcast/open-source-dot-net/qa-with-udi-dahan&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-5284216654978687873?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/5284216654978687873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/12/2011-conceptual-web-framework-utopia.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/5284216654978687873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/5284216654978687873'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/12/2011-conceptual-web-framework-utopia.html' title='2011 Conceptual Web Framework Utopia – Part 1, “Architecture”'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-58aUYZqTZj0/Tu301SG2bXI/AAAAAAAAAEY/HymuEsaRKNM/s72-c/sabre.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-4938294875052994540</id><published>2011-12-14T14:33:00.000-08:00</published><updated>2011-12-14T14:33:29.573-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 7</title><content type='html'>&lt;b&gt;Chapter 13 - Refactoring Toward Deeper Insight&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Refactoring toward deeper insight may be a response to a problem or awkwardness in the design, where the root of the problem is sensed to be the domain model&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;May come even when the code looks tidy - but the language just doesn't fit the model&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Domain refactorings involve multiple people and are extensively designed and deliberated over&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Could be a refinement of ubiquitious language which is then expressed in the code&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;"If you wait until you can make a complete justification for a change - you've waited too long. Your project is already incurring heavy costs"&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Refactor when:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Design does not express current understanding&lt;/li&gt;
&lt;li&gt;Implicit concepts can be made explicit&lt;/li&gt;
&lt;li&gt;Opportunity to make important parts of the domain more supple&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Chapter 14 - Maintaining Model Integrity&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Total unification of the domain model will not be feasible or cost-effective&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;When inside a context, ignore terminology from outside - focus on keeping that context pure&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Important to understand the bounds of a context&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Duplicate concepts = 2 implementations of the same concept&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;False cognates = 2 concepts under the same name&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Create a visual diagram of all the bounded contexts and translations on a project&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Names of bounded contexts should enter the ubiquitous language&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Shared kernel, conformist, open host service, published language&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Anticorruption layers can be used with external systems or legacy code&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Hard for multiple teams to work on one bounded context&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;For an existing project, draw up the bounded contexts AS THEY ARE&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-4938294875052994540?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/4938294875052994540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/12/ddd-notes-from-big-blue-book-part-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/4938294875052994540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/4938294875052994540'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/12/ddd-notes-from-big-blue-book-part-7.html' title='DDD - Notes from the big blue book. Part 7'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-7684666764449274428</id><published>2011-12-04T06:28:00.000-08:00</published><updated>2011-12-04T06:28:26.629-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 6</title><content type='html'>&lt;b&gt;Chapter 11 - Applying Analysis Patterns&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Have to make calculated compromises to the design to allow for good implementation&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Parts of the program we don't suspect can benefit from a domain model - they can be uncovered with analysis patters&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Example in this chapter was the nightly script that was run&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Analysis patterns are more guiding than prescriptive&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 12 - Relating Design Patterns to the Model&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Design patterns can be applied to domain models by thinking about them in a different way - from a domain logic perspective&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;When applying a design pattern in the domain, first check whether it is a good fit for the domain concept&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Example used in this chapter was the composite pattern with nodes representing shipment routes&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-7684666764449274428?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/7684666764449274428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/12/ddd-notes-from-big-blue-book-part-6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/7684666764449274428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/7684666764449274428'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/12/ddd-notes-from-big-blue-book-part-6.html' title='DDD - Notes from the big blue book. Part 6'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-1359663450575449225</id><published>2011-12-04T06:19:00.000-08:00</published><updated>2011-12-04T06:19:45.546-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 5</title><content type='html'>&lt;b&gt;Chapter 9&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;To find implicit concepts&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;be aware of hints in the design&lt;/li&gt;
&lt;li&gt;search them out&lt;/li&gt;
&lt;li&gt;listen to language used and learn&lt;/li&gt;
&lt;li&gt;Scrutinise awkwardness of design&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Scrutinise code that does awkward things and is hard to explain&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Domain experts may be inconsistent - this may indicate an implicit concept&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Make constraints explicit&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Look at analysis models/patterns&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Ideally do not want to make procedures a part of the domain model - unless they are spoken about&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 10&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;State post conditions of operations and invariants of classes and aggregates - ** maybe as unit test? **&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Models are awkward because they are missing pieces - successive refactorings lead to conceptual contours which clarify the model&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Decompose design elements consistently with the domain&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;A requirement that forces extensive change is a sign that the model does not fit&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;** Closure of operations **&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Carve off sub-domains&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-1359663450575449225?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/1359663450575449225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/12/ddd-notes-from-big-blue-book-part-5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1359663450575449225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1359663450575449225'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/12/ddd-notes-from-big-blue-book-part-5.html' title='DDD - Notes from the big blue book. Part 5'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-2895292166945207530</id><published>2011-11-19T08:39:00.000-08:00</published><updated>2011-12-14T14:23:04.031-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='FubuMVC'/><title type='text'>Fun with Fubu's Html Conventions</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
h3
 {mso-style-link:"Heading 3 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:11.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
pre
 {mso-style-link:"HTML Preformatted Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:10.0pt;
 font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.HTMLPreformattedChar
 {mso-style-name:"HTML Preformatted Char";
 mso-style-link:"HTML Preformatted";
 font-family:"Courier New";}
span.Heading3Char
 {mso-style-name:"Heading 3 Char";
 mso-style-link:"Heading 3";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;br /&gt;
&lt;div class="WordSection1"&gt;
&lt;div class="MsoNormal"&gt;
I recently blogged about being impressed with conventions in
Fubu MVC that let you decide the rules that govern how actions are discovered,
how routes are constructed and displayed, and how output/view selection occurs.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Whilst on my travels in fubu land, the next feature that
left me in awe (of the fanboy variety [of awe]) were the html conventions. Read
on to learn how they out-muscle and bully ASP.NET MVC ’s display/editor
templates for all their dinner money.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
As a quick caveat: I am not an expert – these are just my
initial findings.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The following example comes from one of my current &lt;a href="https://github.com/NTCoding/FubuRaven.NTCoding.com"&gt;personal projects&lt;/a&gt;.&lt;/div&gt;
&lt;h2&gt;



Establish Context () =&amp;gt;&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
My first opportunity to apply html conventions came on the
create book page hidden in site administration. Take a look at the CreateBookInputModel’s
public properties:&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;class&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;CreateBookInputModel&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Title&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Genre&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Description_BigText&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10pt;"&gt;BookStatus&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;BookStatus&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10pt;"&gt;IList&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;StringWrapper&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;gt;&amp;nbsp;Authors&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;HttpPostedFileBase&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Image&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
This public interface would make an excellent contrived
example, as it demonstrates a number of different opportunities which get
progressively more interesting. But this is a naturally-occurring story.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
My goal is to keep the corresponding Spark view very simple –
here’s an idyllic vision minus the fluff:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.LabelFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Title)}&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.InputFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Title)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.LabelFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Description_BigText)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.InputFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Description_BigText).Attr("rows",&amp;nbsp;"5")}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.LabelFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.BookStatus)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.InputFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.BookStatus)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.LabelFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Genre)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.InputFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Genres)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.LabelFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Authors)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.InputFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Authors)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.LabelFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Image)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ${this.InputFor(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Image)}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;p&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;



Let’s start at the Top and Work Down&amp;nbsp;&lt;/h2&gt;
&lt;h3&gt;



Strings&lt;/h3&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;Title&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;Genre&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
Simple – strings work straight out of the box with a
nicely-named html input as you would expect.&lt;/div&gt;
&lt;h3&gt;



Special Strings&lt;/h3&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;Description_BigText&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;
Question: When is a string not a string?&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Answer: When I suffix the property name with “_BigText”. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So what is it now then? It’s…..a big blob of text that needs
to be represented by a text area – not a text box. To make this happen, head
over to my &lt;a href="https://github.com/NTCoding/FubuRaven.NTCoding.com/blob/master/src/app/Web/Configuration/NTCodingFubuRegistry.cs"&gt;FubuRegistry&lt;/a&gt;.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
First we need a label:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;HtmlConvention(x&amp;nbsp;=&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x.Labels&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;.If(e&amp;nbsp;=&amp;gt;&amp;nbsp;e.Accessor.Name.EndsWith(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"_BigText"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;))&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.BuildBy(er&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"label"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;).Text(er.Accessor.Name.Replace(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"_BigText"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;""&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)        ))&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Here, the variable x is the registry, which I’m adding a new
label convention to. What I’m saying is, if the property name ends with “_BigText”,
build the view portion by using a html label whose text will be the property
name, minus the “_BigText” marker (e.g. “Description”).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Now we need an editor to go with the label:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;HtmlConvention(x&amp;nbsp;=&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x.Editors&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  .If(e&amp;nbsp;=&amp;gt;&amp;nbsp;e.Accessor.Name.EndsWith(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"_BigText"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;))&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .BuildBy(er&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"textarea"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;))&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Pretty simple, eh? I’ve just told it to return a text area
when the property name ends with our special marker – it is smart enough to
give the text area the correct name so you can post values.&lt;/div&gt;
&lt;h3&gt;



Enums&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Here’s a favourite, and something I dreamt of doing with
ASP.NET MVC, but was not possible with editor templates.&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;BookStatus&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;BookStatus&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Dear gods of web programming, every time you see an enum to
be posted back please be so kind and give me a drop down with each enum member.&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;HtmlConvention(x&amp;nbsp;=&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.Editors&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .If(e&amp;nbsp;=&amp;gt;&amp;nbsp;e.Accessor.PropertyType.IsEnum)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .BuildBy(er&amp;nbsp;=&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;tag&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"select"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;enumValues&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Enum&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.GetValues(er.Accessor.PropertyType);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;foreach&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;enumValue&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;in&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;enumValues)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tag.Children.Add(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"option"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;).Text(enumValue.ToString()));&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;tag;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Once you work out which variables correspond to the property
type (er.Accessor.PropertyType) it’s pretty simple to get all the values and
make a drop down. Again, the tag you return will automatically have the
property name applied, so you can bind the selected value to it nicely.&lt;/div&gt;
&lt;h3&gt;



String Collections&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Caveat: fubu mvc doesn’t support binding to a collection of
strings yet or IEnumerables (you can add your own, but it’s a bit of work). I
just use StringWrapper &amp;nbsp;– which has one string property, “Text”; and
ILIst&amp;lt;T&amp;gt; which is supported for binding collections to.&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10pt;"&gt;IList&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;StringWrapper&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;gt;&amp;nbsp;Authors&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;
Whenever I see a collection of strings I always want a text
box and add button, down which lets you type in text items and build up a list to be
posted back. By using some class-name conventions, you can write the JQuery
once and it works wherever you use the class name.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
But by using fubu-mvc conventions – I write the JQuery once &lt;i&gt;and&lt;/i&gt;
the class once – the rest is taken care of:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;HtmlConvention(x&amp;nbsp;=&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x.Editors&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .If(e&amp;nbsp;=&amp;gt;&amp;nbsp;e.Accessor.PropertyType.IsAssignableFrom(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;typeof&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;IList&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;StringWrapper&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;)))&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .BuildBy(er&amp;nbsp;=&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;tag&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"div"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;).AddClass(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"hasHiddenGroup"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tag.Children.Add(&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;             &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"input"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .Attr(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"type"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"text"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .Attr(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"name"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&amp;nbsp;er.Accessor.Name)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tag.Children.Add(&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"a"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Attr(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"href"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"#"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .Text(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"add"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .AddClass(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"addItem"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tag.Children.Add(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"ul"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;));&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;tag;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }));&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;
Start with a div – and give it the magic sauce – “hasHiddenGroup”
class (don’t know why I called it that – blame the magic sauce) – then add a
text box with the property’s name. Next to that text box, add a link called add.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
To clarify, the conventions will build this:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;div&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;class&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;=&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;hasHiddenGroup&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;input&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;type&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;=&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;text&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;name&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;=&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;Authors&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;a&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;href&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;=&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;#&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;class&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;=&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;addItem&lt;/span&gt;&lt;span style="color: #cddc18; font-family: Consolas;"&gt;"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;add&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;a&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;ul&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;ul&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;div&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;
..which means that dash of JQuery can be applied site-wide to
wire up the add button - allowing that empty to list to be built up. It then
renames each item in the list so they are posted back and can be used to
model-bind to.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
You can see the simple JQuery code &lt;a href="https://github.com/NTCoding/FubuRaven.NTCoding.com/blob/master/src/app/Web/Public/js/site.js"&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;h3&gt;



File Uploads&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Here’s an easy one:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;HtmlConvention(x&amp;nbsp;=&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x.Editors&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .If(e&amp;nbsp;=&amp;gt;&amp;nbsp;e.Accessor.PropertyType.IsAssignableFrom(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;typeof&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HttpPostedFileBase&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)))&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .BuildBy(er&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;HtmlTag&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"input"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;).Attr(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"type"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"file"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;))&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;



Closing Thoughts&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
No doubt about it, the Fubu MVC html conventions go a lot deeper,
and are less than brittle than ASP.NET MVC’s Display/Editor templates. When
applied to a real world project, the time-savings and bug-reduction have
massive potential.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
But that’s a production app - this example was based on a
small toy project. What may happen in the wild is a mystery&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="margin-left: 38.7pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;What happens if the markup is complex and is not so easily
created in code? &lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 38.7pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;What happens if need to apply specific classes? &lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="margin-left: 38.7pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;What about when I want to override conventions – what pitfalls
await me?&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I look forward to finding out the answer to these questions,
and striving to maintain my intellectually-crippled views.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
On a final note you can also use &lt;a href="http://cannibalcode.blogspot.com/2010/03/using-fubumvcui-in-aspnet-mvc-getting.html"&gt;fubu
mvc’s html conventions in ASP.NET MVC&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-2895292166945207530?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/2895292166945207530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/11/fun-with-fubus-html-conventions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2895292166945207530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2895292166945207530'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/11/fun-with-fubus-html-conventions.html' title='Fun with Fubu&apos;s Html Conventions'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-2642336992546959819</id><published>2011-11-13T10:32:00.000-08:00</published><updated>2011-11-13T10:32:20.141-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 4</title><content type='html'>Notes from chapters 7 &amp;amp; 8&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chapter 7&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;When implementing the model- first work out the entities&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Association traversal direction represents insight into the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Transactional boundaries are allowed to influence the domain model a little&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Create modules based on domain relevance&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Use anti-corruption layer to translate external systems to ubiquitous language&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Don't let domain rules creep into the app layer&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 8&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Objects in the domain are not immediately obvious e.g. ship and container were implementation details of a more abstract concept&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Example explains how an incoherent model was wrestled into a model driven design&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Embrace knowledge breakthroughs and radically change the domain model to reflect it&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;The breakthrough may cause short term delay - but will most likely be massively worthwhile&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Breakthroughs may come after many small refactorings toward deeper insight&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Breakthroughs can be the most important part of improving the model design&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Breakthroughs can lead to other breakthroughs - this causes development speed to pick up where normally it would drop off&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-2642336992546959819?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/2642336992546959819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/11/ddd-notes-from-big-blue-book-part-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2642336992546959819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2642336992546959819'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/11/ddd-notes-from-big-blue-book-part-4.html' title='DDD - Notes from the big blue book. Part 4'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-4251354617039506375</id><published>2011-11-13T09:35:00.000-08:00</published><updated>2011-11-13T09:35:14.283-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 3</title><content type='html'>Here's what I've cherry-picked from chapters 5 &amp;amp; 6&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chatper 5&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Implementing associations between entities in the design can be difficult&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;3 types of object&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Entities&lt;/li&gt;
&lt;li&gt;Value types&lt;/li&gt;
&lt;li&gt;Services&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Modules are part of the model and should reflect concepts in the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;For every traversable association in the model there is a mechanism in the software with the same properties&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Constrain relationships&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;1-to-many is easier than many-to-many&lt;/li&gt;
&lt;li&gt;Ultimate simplification is to remove relationship&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Strip entities down to the most common characteristics&amp;nbsp;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Gear them up to be totally about identity&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Don't give identity to value types&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Parameters and results of services should be domain objects - e.g. money not decimal&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Don't let services strip behaviour from entities or value types&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Careful use of domain services is key to keeping domain logic in the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Use well-defined modules to aid comprehension of the logical groupings of the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Modules and entities should co-evolve -- ** they are not fixed **&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Don't let frameworks constrain how the model is chunked&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 6&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Factories and repositories are allowed in the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Aggregate root is responsible for checking invariants&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Root may pass reference of nested entity, but receiving object may not keep the reference&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Delete the root - and the entire aggregate should go at the same time&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Use factories to create entire aggregates as a piece&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Consider a coding standard for factory failures&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;A factory can delegate invariant checking to the aggregate - but not always&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Database schema should update to reflect changes in the model&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-4251354617039506375?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/4251354617039506375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/11/ddd-notes-from-big-blue-book-part-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/4251354617039506375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/4251354617039506375'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/11/ddd-notes-from-big-blue-book-part-3.html' title='DDD - Notes from the big blue book. Part 3'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-1112825230944722612</id><published>2011-10-30T06:32:00.000-07:00</published><updated>2011-10-30T06:32:10.874-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 2</title><content type='html'>Today's notes cover chapter 3 and 4.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Chapter 3&lt;/span&gt;&lt;span style="font-size: large;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Model must work well as analysis and design&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;based on domain&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;but is also solid code that plays well with technology choices&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/span&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;If the model doesn't fit the practical implementations - find a new one&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Start with the domain - then make the code fit&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Simple application features can be exposed as important domain features&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Example of the scripts for the net rules&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Reveal the "bones" of the software so users can make the most benefit of the technology&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt; So just have one model&lt;/li&gt;
&lt;li&gt;Example was IE favourites&lt;/li&gt;
&lt;li&gt;*** Discuss this point ***&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Domain modellers have to be coders. This is important for quick feedback and keeping the model consistent with the domain. The book talks about it being impossible to work otherwise&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Chapter 4&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: large;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Responsibility driven design is used in the book as part of domain modelling&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Use layered architecture to separate concerns&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;** Important step is to isolate the domain model **&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Don't allow other layers, eg ui, to influence the design of the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Put logic like email sending in the infrastructure layer and expose interfaces to the other layers&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Important to minimise framework dependencies from the domain model &lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-1112825230944722612?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/1112825230944722612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/10/ddd-notes-from-big-blue-book-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1112825230944722612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1112825230944722612'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/10/ddd-notes-from-big-blue-book-part-2.html' title='DDD - Notes from the big blue book. Part 2'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-6364408921225580956</id><published>2011-10-23T12:17:00.000-07:00</published><updated>2011-10-23T12:17:09.170-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><title type='text'>DDD - Notes from the big blue book. Part 1</title><content type='html'>&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
At Wiggle we have just begun a new developer initiative to
collectively become better domain modellers. It consists of reading two
chapters of the DDD book a week and then having a discussion about them on
Friday afternoon.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
My homework is now complete – I’ve read the first two
chapters…. but I’ve also taken some notes about what I think are the key
features. This should give me plenty to talk about on Friday. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
A secondary benefit to my notes is that instead of reading
the whole book again, I can just go over my notes at regular intervals to help
commit the knowledge to long term memory (I’m a fan of brain science so I know
a few tricks here).&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Anyway, here are my notes for up to the end of chapter 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;

Preface&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;A domain model’s ultimate benefit is that it
allows successive versions of systems to be built on the existing ones. Eric
Evans shows an example of teams not getting to release 2 because they weren’t
domain driven.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Domain model is the most complicated aspect of
some systems – not database etc&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;DDD must be used with an iterative process (eg. a
flavour of agile). There must be close communication between developers and
business people/domain experts&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;DDD is best applied by a whole team
collaboratively, using a shared language&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;A domain model is &lt;b&gt;NOT&lt;/b&gt; about being “as realistic as possible”. It should loosely
represent reality to a &lt;b&gt;particular
purpose&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast"&gt;
&lt;/div&gt;
&lt;h2&gt;

Chapter 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;3 rules determine the choice of a model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Model and heart of the design shape each other&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Model is the backbone of language used by all
team members&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Model is distilled knowledge&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;The best developers should also model domains –
not working on databases or frameworks&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Effective modelling techniques taken from the
PCB example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Bind model and implementation&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Cultivate language based on the model&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Knowledge rich domain model&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Distilling the model&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Brainstorming and experimenting&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Knowledge crunching – working towards a simple
view that makes sense of the mass&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Models are tried and rejected&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Collaboration between devs and domain experts&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Developers should understand the principles
behind the software -&amp;nbsp; not just what it
should do&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;PCB example was eventually dropped – but those
early sessions were the start of the knowledge crunching process that facilitated
the later improvements the domain model&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Business activities and rules are as important
as the entities&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;The maximum booking rule was hidden as a guard
clause, but later transformed into a policy. Express domain rules clearly&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;

Chapter 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="mso-list: l2 level1 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;b&gt;Ubiquitous
language&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l2 level2 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Spoken by all developers and domain experts – &lt;b&gt;AND &lt;/b&gt;expressed in code&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l2 level2 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Bottlenecks occur if only certain developers are
“bilingual”&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l2 level2 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;All people must use the same terms to describe
the same things&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l2 level2 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Domain models can provide the ubiquitous
language&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto; mso-list: l2 level2 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Incorrect use of ubiquitous language will cause
developers to clarify true meaning of domain terminology&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; mso-add-space: auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l2 level1 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Crucial to play around when formulating a
ubiquitous language – just like sketching drawings&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l2 level1 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Reframe requirements in ubiquitous language as
it evolves&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l2 level1 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Have only minimal documentation that feels
sketchy and disposable to complement the domain model&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="mso-list: l2 level1 lfo3; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Explanatory models of alternative views of the
domain can be used as education tools – in no way related to code, though&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;See you next week
suckers&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-6364408921225580956?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/6364408921225580956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/10/ddd-notes-from-big-blue-book-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/6364408921225580956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/6364408921225580956'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/10/ddd-notes-from-big-blue-book-part-1.html' title='DDD - Notes from the big blue book. Part 1'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-4723491477694458900</id><published>2011-09-24T09:49:00.000-07:00</published><updated>2011-09-24T09:49:22.398-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Git-Tfs'/><title type='text'>Git-Tfs: Step-by-Step</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Tahoma;
 panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;&lt;div class="separator" style="clear: both; text-align: center;"&gt;




&lt;a href="http://2.bp.blogspot.com/-eL_DxeOeuVE/Tn4IE9gyU9I/AAAAAAAAAEI/ZGBzqDj59aQ/s1600/PathVariable.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="320" width="215" src="http://2.bp.blogspot.com/-eL_DxeOeuVE/Tn4IE9gyU9I/AAAAAAAAAEI/ZGBzqDj59aQ/s320/PathVariable.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;




&lt;a href="http://2.bp.blogspot.com/-rEoBGcHxUBk/Tn4IEhf7z8I/AAAAAAAAAD4/0qNuHRmxORs/s1600/REN.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="38" width="320" src="http://2.bp.blogspot.com/-rEoBGcHxUBk/Tn4IEhf7z8I/AAAAAAAAAD4/0qNuHRmxORs/s320/REN.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;




&lt;a href="http://4.bp.blogspot.com/-DgOoUXpZ9dQ/Tn4IE6MkKTI/AAAAAAAAAEA/wqmhr2QRDV4/s1600/Servers.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="68" width="320" src="http://4.bp.blogspot.com/-DgOoUXpZ9dQ/Tn4IE6MkKTI/AAAAAAAAAEA/wqmhr2QRDV4/s320/Servers.png" /&gt;&lt;/a&gt;&lt;/div&gt;
margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h1
 {mso-style-link:"Heading 1 Char";
 margin-top:24.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:14.0pt;
 font-family:"Cambria","serif";
 color:#365F91;}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 {mso-style-link:"Balloon Text Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:8.0pt;
 font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading1Char
 {mso-style-name:"Heading 1 Char";
 mso-style-link:"Heading 1";
 font-family:"Cambria","serif";
 color:#365F91;
 font-weight:bold;}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.BalloonTextChar
 {mso-style-name:"Balloon Text Char";
 mso-style-link:"Balloon Text";
 font-family:"Tahoma","sans-serif";}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;div class="WordSection1"&gt;
&lt;div class="MsoNormal"&gt;
I’ve recently had the pleasure of setting up git-tfs to
minimise my daily contact with Tfs to an absolute minimum. While the process is
quite easy, a few minor things tripped me up and took a bit of faffing and “stackoverflowing”
to figure out.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I would hate for other people who don’t have as much time to
persevere to just accept tfs. So I made this simple step-by-step guide that is
foolproof (VB drag and drop experts excluded).&lt;/div&gt;
&lt;h2&gt;



Install Git for Windows&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Head over to the &lt;a href="http://code.google.com/p/msysgit/downloads/list?can=3&amp;amp;q=official+Git"&gt;download
page for msysgit&lt;/a&gt; and pick the latest full installer version. When
downloaded, install the application.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
You will be asked to select components in a dialog almost
immediately. At this point, check the boxes next to “Git Bash Here” and “Git
GUI Here” underneath Windows Explorer integration.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
After that just keep clicking next and accept the defaults.&lt;/div&gt;
&lt;h2&gt;



Download Git-Tfs&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Now make your way to the &lt;a href="https://github.com/spraints/git-tfs"&gt;git-tfs github page&lt;/a&gt;. Click the “downloads”
button and select the latest &lt;b&gt;package &lt;/b&gt;(specifically not the full source
code download)&lt;b&gt;.&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Then extract this package to C:\git-tfs. If you don’t like
this location just stick with it for now so you can follow the example. You can
move it later on and update things accordingly.&lt;/div&gt;
&lt;h2&gt;



Wire-up Git-Tfs&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
At this point, git-tfs is not integrated with git. To
confirm this, right-click a folder in Windows Explorer and choose “Git Bash
here”. If you then type “git-tfs” you will see the command is not found.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Fixing this is easy – you just need to append the path to
git-tfs to your “path” environment variable:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Click start/windows icon&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Right-click on “Computer” and select “Properties”&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Select “Advanced System Settings”&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Click the “Environment Variables” button&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Edit the “Path” System variable – append it with “;C:\git-tfs”&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-tqw1hd6DJ8c/Tn4IQydBjpI/AAAAAAAAAEM/023e16R3iow/s1600/PathVariable.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-tqw1hd6DJ8c/Tn4IQydBjpI/AAAAAAAAAEM/023e16R3iow/s1600/PathVariable.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
You can confirm this worked by opening up the bash again (on
any folder) and trying the “git-tfs” command and observing the available options&lt;/div&gt;
&lt;h2&gt;



Cloning a Repository&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Here we have to make contact with the Tfs server. But first,
we need to find the path to it. The easiest way to do this is to:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Open
visual studio&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Click
the “Team” drop down menu&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
3.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Select&amp;nbsp;
“Connect to team foundation server”&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
4.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Click
the “Servers” button&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
5.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Note
down the url of the server you want to access&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-CmbWAtt9f8U/Tn4IRoFZiOI/AAAAAAAAAEU/L8wuMzCMWdU/s1600/Servers.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="85" src="http://1.bp.blogspot.com/-CmbWAtt9f8U/Tn4IRoFZiOI/AAAAAAAAAEU/L8wuMzCMWdU/s400/Servers.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Now you need need to suffix the Tfs path with the name of
the collection that contains the repository you want to checkout and work on &amp;nbsp;–
quickest way to find this is right at the top of the “Team Explorer” floating
menu in Visual studio. You can also see them on the image above (e.g.
DefaultCollection).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For example: http://Tfs:1000/DefaultCollection&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The last bit of required information is the name of the
branch you want to work on (clone). If you select a branch inside Tfs’s “Source
Control Explorer” tab, it will give you this, starting with “$” in the “Source
Location” text box right at the top. E.g. $/this/is/my/branch&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
With all the information available, click on a folder in
windows explorer where you’d like to check out your branch and create a git
repository. Select “Git Bash here”, then the command: &lt;b&gt;&lt;i&gt;git clone &amp;lt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;tfsurl
/collection name&lt;b&gt;&amp;gt; &amp;lt;&lt;/b&gt;name of branch, starting with $&lt;b&gt;&amp;gt;&lt;/b&gt;&lt;/i&gt;.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Git will now do its magic and you’re ready to go.&lt;/div&gt;
&lt;h2&gt;



Ignoring Files&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Setting up a global ignore file is something you’ll want to
do to avoid committing all those ReSharper and debug files. This is quite
simple to achieve:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Navigate to your user directory e.g. c:/Users/YourMom&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Create a file called “.gitignore_global.txt”&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Shift+right-click inside the window and “open a command window
here”&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Type the command “REN .gitignore_global.txt .gitignore_global”&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-l4Y27DgAw38/Tn4IRYeFrII/AAAAAAAAAEQ/kj-c8HoFbag/s1600/REN.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="46" src="http://2.bp.blogspot.com/-l4Y27DgAw38/Tn4IRYeFrII/AAAAAAAAAEQ/kj-c8HoFbag/s400/REN.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Now you need to register this file with git: bring up a bash
anywhere and type: &lt;b&gt;&lt;i&gt;git config --global core.excludesfile ~/.gitignore_global&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
To confirm it worked, in the bash type: &lt;b&gt;&lt;i&gt;git config --global
core.excludesfile&lt;/i&gt;&lt;/b&gt;&lt;i&gt;. &lt;/i&gt;It should echo back the full path to the
ignore file.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
To get you started with some exclusion rules, try opening
the .gitignore_global file with notepad and add these lines:&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
*ReSharper*/&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
*bin*&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
.gitignore&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Google and the phrase “gitignore” will teach you the rest.&lt;/div&gt;
&lt;h2&gt;



&amp;nbsp;&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-4723491477694458900?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/4723491477694458900/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/09/git-tfs-step-by-step.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/4723491477694458900'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/4723491477694458900'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/09/git-tfs-step-by-step.html' title='Git-Tfs: Step-by-Step'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-tqw1hd6DJ8c/Tn4IQydBjpI/AAAAAAAAAEM/023e16R3iow/s72-c/PathVariable.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-1686725670644786610</id><published>2011-09-11T09:58:00.000-07:00</published><updated>2011-09-11T09:58:18.100-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='FubuMVC'/><title type='text'>FubuMVC - My Starting Conventions</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Tahoma;
 panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h1
 {mso-style-link:"Heading 1 Char";
 margin-top:24.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:14.0pt;
 font-family:"Cambria","serif";
 color:#365F91;}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
pre
 {mso-style-link:"HTML Preformatted Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:10.0pt;
 font-family:"Courier New";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 {mso-style-link:"Balloon Text Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:8.0pt;
 font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading1Char
 {mso-style-name:"Heading 1 Char";
 mso-style-link:"Heading 1";
 font-family:"Cambria","serif";
 color:#365F91;
 font-weight:bold;}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.HTMLPreformattedChar
 {mso-style-name:"HTML Preformatted Char";
 mso-style-link:"HTML Preformatted";
 font-family:"Courier New";}
span.BalloonTextChar
 {mso-style-name:"Balloon Text Char";
 mso-style-link:"Balloon Text";
 font-family:"Tahoma","sans-serif";}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;


&lt;br /&gt;
&lt;div class="WordSection1"&gt;
&lt;div class="MsoNormal"&gt;
I finally had to scratch the itch and put my other toy
projects on hold to have a play with RavenDB and FubuMVC. Immediately, I found
my first point of interest – and one of FubuMVC’s selling points – pluggable conventions.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
In a minute I’ll show you the conventions I have chosen as a
starting point – I’ve taken inspiration from elsewhere, and myself imagined
what works theoretically. These conventions relate to defining actions – which methods
in code are accessible to the web; and basic url patterns. Finally I’ll show my
starting convention for view-location as well.&lt;/div&gt;
&lt;h2&gt;

Action Per-Controller&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
It seems as fashionable as coding in Node.js at the moment,
but actually, when you’ve worked on an ASP.NET MVC project with bloated
controllers – a ridiculous amount of actions, and insane number of injected
dependencies – having one action per-controller is rather practical. Because we
define our own url policy, we’re not constrained by the framework where code
has to live.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
My implementation will mean the name of the controller is
the name of action, while the name of the method is the http verb it responds
to. Here’s an example:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;class&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;PiggyBankEndpoint&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;PiggyBankViewModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;Get()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;PiggyBankViewModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;Post(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;DepositInputModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;model)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;//&amp;nbsp;do&amp;nbsp;some&amp;nbsp;stuff&amp;nbsp;with&amp;nbsp;the&amp;nbsp;model&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Pennies&amp;nbsp;in&amp;nbsp;the&amp;nbsp;piggy"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Oh, and by the way, I think I’m cool, so I don’t use the
word controller – I copy the cool kids and call them endpoints (although WCF
isn’t cool).&lt;/div&gt;
&lt;h2&gt;

Here’s where you’ll Find All the Action&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Inside the constructor of my Fubu Registry, where I declare
my basic conventions for deciding what an action is, I have this little
snippet:&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;Actions&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.IncludeTypes(t&amp;nbsp;=&amp;gt;&amp;nbsp;t.Namespace.Contains(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas; font-size: 10pt;"&gt;"Web.Endpoints"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;)&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;t.Name.EndsWith(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas; font-size: 10pt;"&gt;"Endpoint"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
No, I won’t patronise you – I’m not a Microsoft MVP (joke). &lt;/div&gt;
&lt;h2&gt;

I Bet Those Url’s Look Messy&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Before I applied my conventions – yes, yes they rather did.
After my convention, though, now I’m cool again.&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;Routes&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .IgnoreNamespaceText(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Endpoints"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .IgnoreClassSuffix(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Endpoint"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .IgnoreMethodsNamed(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"get"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .IgnoreMethodsNamed(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"post"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .ConstrainToHttpMethod(x&amp;nbsp;=&amp;gt;&amp;nbsp;x.Method.Name.Equals(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Get"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;),&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Get"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;.ConstrainToHttpMethod(x&amp;nbsp;=&amp;gt;&amp;nbsp;x.Method.Name.Equals(&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Post"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;),&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Post"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.RootAtAssemblyNamespace();&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
This time I will patronise you – because I want to be an MVP
now.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So FubuMVC is going to use the namespace, the type of the
controller and the name of the action. I’ve decided that doesn’t fit with my
desired url conventions. So instead, I’m saying:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Do attempt that Mr FubuMVC&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;But strip out the word Endpoints from the url if it appears in a
type’s namespace&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Again, if a type’s name ends with Endpoint (which my convention
says they all will), then don’t put this in the url either&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;If there is a method called get or post – remove the name of the
method from the url and only allow access for the http method with the same
name&lt;/div&gt;
&lt;h2&gt;

Shut Up and Show Me&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Here are my endpoints:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-hZ5CfB_2ftg/TmznTt4IeqI/AAAAAAAAADs/U7cX5STSTxs/s1600/EndPoints.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-hZ5CfB_2ftg/TmznTt4IeqI/AAAAAAAAADs/U7cX5STSTxs/s1600/EndPoints.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Their type names ends with “Endpoint” and their namespace
contains “Web.EndPoints” (oops – I patronised you &lt;span style="font-family: Wingdings;"&gt;J&lt;/span&gt;), so public methods for these types are my actions.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&amp;nbsp;Using another selling point of Fubu, the basic diagnostics,
we can now check what actions are available and the constraints that are
applied to them:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-Ku8RGwfadsE/TmznY4jqE8I/AAAAAAAAADw/PnoXdx2asvU/s1600/diagnostics.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="120" src="http://4.bp.blogspot.com/-Ku8RGwfadsE/TmznY4jqE8I/AAAAAAAAADw/PnoXdx2asvU/s640/diagnostics.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Excellent – yes, FubuMVC is using the namespaces and type
names to determine url structure. But with a few simple fluent configuration
options, I’ve tweaked it to my liking.&lt;/div&gt;
&lt;h2&gt;

Take Me to Your Views&lt;/h2&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;Views&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TryToAttach(x&amp;nbsp;=&amp;gt;&amp;nbsp;x.by_ViewModel());&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;this&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.UseSpark();&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Simple again – look for the view whose view model matches
the return type of the action – they can live anywhere (for now). Below that I’ve
said I’m using the spark view engine – NuGet: Install-Package FubuMVC.Spark. &lt;/div&gt;
&lt;h2&gt;

What Am I Thinking?&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
I’m thinking it can seem overwhelming to have to define your
own conventions…but actually, it’s not. With the diagnostics to fall back on,
at this early stage (approx. 30 lines of my own code), everything is definitely
under control – jus make one small change at a time and observe how things
change in the diagnostics.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Have I seen anything here that gives me confidence FubuMVC
is an alternative – maybe even a better one – to ASP.NET MVC? Why yes, yes I
have. &amp;nbsp;“FubuMVC – the web framework that get’s out of your way” – it actually
does.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
It’s very early days, though, and I’m a bit of a fan boy –
take me with a pinch of salt.&lt;/div&gt;
&lt;div class="MsoListParagraph"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-1686725670644786610?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/1686725670644786610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/09/fubumvc-my-starting-conventions.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1686725670644786610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1686725670644786610'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/09/fubumvc-my-starting-conventions.html' title='FubuMVC - My Starting Conventions'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-hZ5CfB_2ftg/TmznTt4IeqI/AAAAAAAAADs/U7cX5STSTxs/s72-c/EndPoints.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-1803010765550232448</id><published>2011-08-20T03:52:00.000-07:00</published><updated>2011-08-20T04:04:29.847-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>WPF DataGrid DataDialogs</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:Cambria;
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:10.0pt;
	margin-left:0cm;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
h1
	{mso-style-link:"Heading 1 Char";
	margin-top:24.0pt;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:0cm;
	margin-bottom:.0001pt;
	line-height:115%;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:"Cambria","serif";
	color:#365F91;}
h2
	{mso-style-link:"Heading 2 Char";
	margin-top:10.0pt;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:0cm;
	margin-bottom:.0001pt;
	line-height:115%;
	page-break-after:avoid;
	font-size:13.0pt;
	font-family:"Cambria","serif";
	color:#4F81BD;}
h3
	{mso-style-link:"Heading 3 Char";
	margin-top:10.0pt;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:0cm;
	margin-bottom:.0001pt;
	line-height:115%;
	page-break-after:avoid;
	font-size:11.0pt;
	font-family:"Cambria","serif";
	color:#4F81BD;}
pre
	{mso-style-link:"HTML Preformatted Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-link:"Balloon Text Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:"Tahoma","sans-serif";}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:10.0pt;
	margin-left:36.0pt;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:10.0pt;
	margin-left:36.0pt;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
span.Heading1Char
	{mso-style-name:"Heading 1 Char";
	mso-style-link:"Heading 1";
	font-family:"Cambria","serif";
	color:#365F91;
	font-weight:bold;}
span.Heading2Char
	{mso-style-name:"Heading 2 Char";
	mso-style-link:"Heading 2";
	font-family:"Cambria","serif";
	color:#4F81BD;
	font-weight:bold;}
span.BalloonTextChar
	{mso-style-name:"Balloon Text Char";
	mso-style-link:"Balloon Text";
	font-family:"Tahoma","sans-serif";}
span.Heading3Char
	{mso-style-name:"Heading 3 Char";
	mso-style-link:"Heading 3";
	font-family:"Cambria","serif";
	color:#4F81BD;
	font-weight:bold;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-link:"HTML Preformatted";
	font-family:"Courier New";}
.MsoChpDefault
	{font-family:"Calibri","sans-serif";}
.MsoPapDefault
	{margin-bottom:10.0pt;
	line-height:115%;}
@page WordSection1
	{size:595.3pt 841.9pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
 /* List Definitions */
 ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;div class="WordSection1"&gt;
&lt;h2&gt;

Intro&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
As a WPF flirt I can’t give you best practices or ideals -
but I can give you a simple technique for adding buttons to each row in a WPF
DataGrid that (in this case) will display contextual information in a dialog
box. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
It will also provide a good reference to my future self when
the gods of HTML reclaim the UI portion of my brain (the part that is pathetic
at visual designs).&lt;/div&gt;
&lt;h2&gt;

Data Model&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
To celebrate BT’s double screw-up at trying to get broadband
installed in my new home, this demo will be based on companies that suck.
Hence…&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;class&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;CompanyThatSucks&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;readonly&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;_reason;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;CompanyThatSucks(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;string&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;name,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;suckynessRating,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;howMuchWouldILoveToSeeThemGoBankrupt,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;string&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;reason)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Name&amp;nbsp;=&amp;nbsp;name;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SuckynessRating&amp;nbsp;=&amp;nbsp;suckynessRating;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;HowMuchWouldILoveToSeeThemGoBankrupt&amp;nbsp;= howMuchWouldILoveToSeeThemGoBankrupt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_reason&amp;nbsp;=&amp;nbsp;reason;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;Name&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10pt;"&gt;Int32&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;SuckynessRating&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10pt;"&gt;Int32&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;HowMuchWouldILoveToSeeThemGoBankrupt&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;get&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas; font-size: 10pt;"&gt;String&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;GetReasonForSucking()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas; font-size: 10pt;"&gt;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;_reason;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;h2&gt;

Data on Display&lt;/h2&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-Ou-a7xXq0xw/Tk-QyzKRTVI/AAAAAAAAADg/uy2nVaKq-o4/s1600/CompaniesThatSuck___1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="215" src="http://2.bp.blogspot.com/-Ou-a7xXq0xw/Tk-QyzKRTVI/AAAAAAAAADg/uy2nVaKq-o4/s400/CompaniesThatSuck___1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Hooked up via data binding to a view model, here is the live
list of companies that suck. Because I share this list with my mom, and she
moans by the essay, it would take too much space to show the reason in a cell.
So I’ll pop it up in a dialog when a button is pressed.&lt;/div&gt;
&lt;h2&gt;

DataGrid Action Buttons&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Here’s what we want, right?:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-crsV2PyLMTU/Tk-QziQ4TNI/AAAAAAAAADo/ecThnR3NwlU/s1600/CompaniesThatSuck__2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="215" src="http://4.bp.blogspot.com/-crsV2PyLMTU/Tk-QziQ4TNI/AAAAAAAAADo/ecThnR3NwlU/s400/CompaniesThatSuck__2.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Here’s how to get it:&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;MainWindow()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;this&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.DataContext&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;ViewModel&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;();&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;    &lt;/span&gt;&lt;span class="Apple-style-span" style="color: lime; font-family: Consolas;"&gt;"Suckers is the DataGrid"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Suckers.Loaded&amp;nbsp;+=&amp;nbsp;(x,&amp;nbsp;y)&amp;nbsp;=&amp;gt;&amp;nbsp;AddShowNotesColumnToDataGrid();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;AddShowNotesColumnToDataGrid()&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;button&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;FrameworkElementFactory&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;typeof&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Button&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;));&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;button.SetValue(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Button&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.ContentProperty,&amp;nbsp;&lt;/span&gt;&lt;span style="color: lime; font-family: Consolas;"&gt;"Show&amp;nbsp;Notes"&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;button.AddHandler(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Button&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.ClickEvent,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;column&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CellTemplate&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;()&lt;/span&gt;&lt;span class="Apple-style-span" style="color: white; font-family: Consolas;"&gt; {&amp;nbsp;VisualTree&amp;nbsp;=&amp;nbsp;button},&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DisplayIndex&amp;nbsp;=&amp;nbsp;3,&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Suckers.Columns.Add(column);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Create
a button thingy with that factory thingy&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Set
the button’s text &lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Create
a new column for the DataGrid and mangle it to contain the button&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72.0pt; text-indent: -18.0pt;"&gt;
a.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;The
DisplayIndex affects ordering of the columns – this one is at the end&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
4.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Add
the column to the DataGrid&lt;/div&gt;
&lt;h2&gt;

This Relationship is all about the Dialog&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
In two simple steps we can make that ornamental button come
to life quicker than you can cancel your account with BT (I have the stats).&lt;/div&gt;
&lt;h3&gt;

1. Create a Simple Method to Show a Dialog&lt;/h3&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt; private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;void&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;ShowDialog(&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;string&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;content)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;w&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Window&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Height&amp;nbsp;=&amp;nbsp;400,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Width&amp;nbsp;=&amp;nbsp;400,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; w.Content&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;TextBox&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text&amp;nbsp;=&amp;nbsp;content,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Foreground&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;SolidColorBrush&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Colors&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.White),&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;Background&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;SolidColorBrush&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Colors&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.Black)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;w.ShowDialog();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;h3&gt;

2. Bind to the Button’s Event Handler&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
This step of my trick is where the buttons actually do
something that relates to the row of data they represent. There are two
sub-steps.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;1. Get the “Reason for sucking” from a button&lt;/b&gt;&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;private&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;string&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;GetReasonForSucking(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Button&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;sender)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;companyThatSucks&amp;nbsp;=&amp;nbsp;(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;CompanyThatSucks&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)sender.DataContext;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;return&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;companyThatSucks.GetReasonForSucking();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;2. Actually bind to the button’s handler&lt;/b&gt;&lt;/div&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;button.AddHandler(&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Button&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;.ClickEvent,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: #282828;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #ff8000; font-family: Consolas;"&gt;new&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas;"&gt;RoutedEventHandler&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;((sender,&amp;nbsp;args)&amp;nbsp;=&amp;gt;&amp;nbsp;ShowDialog(GetReasonForSucking((&lt;/span&gt;&lt;span style="color: yellow; font-family: Consolas;"&gt;Button&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;)sender))));&lt;/span&gt;&lt;/pre&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Here I’m binding to the button’s click event. I’m using the
method in sub-step 1 above to get information from the button’s data context
and present it to the user in a dialog using the other little method I created
above. This code goes below the line that sets the buttons text.&lt;/div&gt;
&lt;h3&gt;

Result&lt;/h3&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-5J51rJojuuM/Tk-QzRT7G2I/AAAAAAAAADk/VxlWIxjw7ZQ/s1600/CompaniesThatSuck___3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="353" src="http://2.bp.blogspot.com/-5J51rJojuuM/Tk-QzRT7G2I/AAAAAAAAADk/VxlWIxjw7ZQ/s400/CompaniesThatSuck___3.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;/div&gt;
&lt;div class="MsoListParagraph"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;

Conclusion&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Today’s moral of the story is to not get angry with certain
organisations because they repeatedly inconvenience you after you trip
over yourself triple-confirming things will happen on certain days.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The sub-plot was a little less abstract - an education in
one technique for augmenting the functionality of a WPF DataGrid by adding
custom buttons that can perform actions specific to the row of data they belong
to.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-1803010765550232448?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/1803010765550232448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/08/wpf-datagrid-datadialogs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1803010765550232448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1803010765550232448'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/08/wpf-datagrid-datadialogs.html' title='WPF DataGrid DataDialogs'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-Ou-a7xXq0xw/Tk-QyzKRTVI/AAAAAAAAADg/uy2nVaKq-o4/s72-c/CompaniesThatSuck___1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-7386040205013045843</id><published>2011-06-29T12:06:00.000-07:00</published><updated>2011-06-29T12:26:09.736-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><title type='text'>UK Date Validation For JQuery Validate</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Tahoma;
 panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h1
 {mso-style-link:"Heading 1 Char";
 margin-top:24.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:14.0pt;
 font-family:"Cambria","serif";
 color:#365F91;}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 {mso-style-link:"Balloon Text Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:8.0pt;
 font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading1Char
 {mso-style-name:"Heading 1 Char";
 mso-style-link:"Heading 1";
 font-family:"Cambria","serif";
 color:#365F91;
 font-weight:bold;}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.BalloonTextChar
 {mso-style-name:"Balloon Text Char";
 mso-style-link:"Balloon Text";
 font-family:"Tahoma","sans-serif";}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;



&lt;div class="WordSection1"&gt;
&lt;div class="MsoNormal"&gt;
Recently I was making tweaks to a Monorail project and was
required to add date validation. The default configuration using active record
correctly applied the class “date” to the fields, which is a flag for JQuery validate.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Unfortunately, JQuery validate uses the American date format
(mm/dd/yyyy). I had a play with the settings but could not find a hook to
specify a UK date format. So I had to try something a bit different – I created
a custom JQuery validate method.&lt;br /&gt;
&lt;br /&gt;
You might also find this link useful:&amp;nbsp;&lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2009/10/29/jquery-date-validation-in-chrome.aspx"&gt;http://geekswithblogs.net/EltonStoneman/archive/2009/10/29/jquery-date-validation-in-chrome.aspx&lt;/a&gt;&lt;/div&gt;
&lt;h2&gt;







Preparation&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
To replicate my solution you’ll need a reference to three
files:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;JQuery&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;JQuery validate&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Date.js (Date.js.com)&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;script&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;
&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;
&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;
&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="date.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;







Laying down the rule&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Using the validator I plugged in a new rule that parses the
value using a date format. If the parse fails, then validation fails. This is
where Date.js comes in – the Date.parseExact method. Notice the single
characters for day and moth – this allows one or two digits.&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;$.validator.addMethod(&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: maroon;"&gt;"validateDate"&lt;/span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;function&lt;/span&gt; (value, element) {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;try&lt;/span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;if&lt;/span&gt; (!value) {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; d = Date.parseExact(value, &lt;span style="color: maroon;"&gt;"d/M/yyyy"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;if&lt;/span&gt; (d == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
} &lt;span style="color: blue;"&gt;else&lt;/span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;catch&lt;/span&gt; (e) {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
},&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: maroon;"&gt;"Please enter a valid UK date dd/mm/yyyy"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;







Apply the rule&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
The final step is to apply the validation to elements using
a css selector. In this case I chose all items with a class called “validateDate”:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;$(&lt;span style="color: maroon;"&gt;'.validateDate'&lt;/span&gt;).validate({&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
name: &lt;span style="color: maroon;"&gt;"validateDate"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
});&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;







Give it a whirl&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Here is the result of using a weird American date format:&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;a href="http://2.bp.blogspot.com/-2BzDNDJmLYY/Tgt6RHaAMRI/AAAAAAAAADc/NQPKWfxwmyA/s1600/badDate.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-2BzDNDJmLYY/Tgt6RHaAMRI/AAAAAAAAADc/NQPKWfxwmyA/s1600/badDate.png" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
And here’s the result of being normal (not that I recommend
it):&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;a href="http://4.bp.blogspot.com/-DEqBVAfNDhE/Tgt4aRl81KI/AAAAAAAAADU/FzuNMXkkEyg/s1600/goodDate.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-DEqBVAfNDhE/Tgt4aRl81KI/AAAAAAAAADU/FzuNMXkkEyg/s1600/goodDate.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;







A full example&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Here’s the sample html page I used to test it out. Don’t
forget to download Date.js if you try it out.&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;DOCTYPE&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;
&lt;span style="color: red;"&gt;html&lt;/span&gt; &lt;span style="color: red;"&gt;PUBLIC&lt;/span&gt; &lt;span style="color: blue;"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span style="color: blue;"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;html&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;
&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;head&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;Uk Date Validation&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;
&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;
&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;
&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="date.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
$(document).ready(&lt;span style="color: blue;"&gt;function&lt;/span&gt; () {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
$(&lt;span style="color: maroon;"&gt;'form'&lt;/span&gt;).validate();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
wireUpDateValidation();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
});&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;function&lt;/span&gt; wireUpDateValidation() {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
$.validator.addMethod(&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: maroon;"&gt;"validateDate"&lt;/span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;function&lt;/span&gt; (value, element) {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;try&lt;/span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;if&lt;/span&gt; (!value) {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; d = Date.parseExact(value, &lt;span style="color: maroon;"&gt;"d/M/yyyy"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;if&lt;/span&gt; (d == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
} &lt;span style="color: blue;"&gt;else&lt;/span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;catch&lt;/span&gt; (e) {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
},&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: maroon;"&gt;"Please enter a valid UK date dd/mm/yyyy"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
$(&lt;span style="color: maroon;"&gt;'.validateDate'&lt;/span&gt;).validate({&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
name: &lt;span style="color: maroon;"&gt;"validateDate"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
});&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;head&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;body&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;form&lt;/span&gt; &lt;span style="color: red;"&gt;method&lt;/span&gt;&lt;span style="color: blue;"&gt;="post"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;label&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Uk date: &lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;input&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text"&lt;/span&gt; &lt;span style="color: red;"&gt;class&lt;/span&gt;&lt;span style="color: blue;"&gt;="validateDate"&lt;/span&gt;
&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;label&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;button&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;Pow&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;button&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;form&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;body&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;html&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraph"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-7386040205013045843?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/7386040205013045843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/06/uk-date-validation-for-jquery-validate.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/7386040205013045843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/7386040205013045843'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/06/uk-date-validation-for-jquery-validate.html' title='UK Date Validation For JQuery Validate'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-2BzDNDJmLYY/Tgt6RHaAMRI/AAAAAAAAADc/NQPKWfxwmyA/s72-c/badDate.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-1132051025733762234</id><published>2011-05-15T11:20:00.000-07:00</published><updated>2011-05-15T11:59:53.917-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='clean code'/><title type='text'>Clean Code Tricks – Intention Revealing Messages</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h1
 {mso-style-link:"Heading 1 Char";
 margin-top:24.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:14.0pt;
 font-family:"Cambria","serif";
 color:#365F91;}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading1Char
 {mso-style-name:"Heading 1 Char";
 mso-style-link:"Heading 1";
 font-family:"Cambria","serif";
 color:#365F91;
 font-weight:bold;}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;div class="WordSection1"&gt;
&lt;h2&gt;



Intro&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
It’s easy to dismiss “clean code” as a myth or “only for the
perfectionist”, and who am I to say that is wrong? Well, I can’t say it, what I
will say is that I have found clean code to be real, to be immediately valuable
and to be an easy habit to get into. I have found clean code reduces the
cognitive load when you are trying to unravel the mysteries in code.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I’ve picked up some clean code techniques from &lt;a href="http://www.cleancoders.com/"&gt;www.cleancoders.com&lt;/a&gt;&lt;span class="MsoHyperlink"&gt; &lt;/span&gt;(Uncle Bob), &amp;nbsp;&lt;a href="http://www.amazon.co.uk/Code-Complete-Practical-Handbook-Construction/dp/0735619670/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1305482388&amp;amp;sr=1-1"&gt;Code
Complete 2&lt;/a&gt; (Steve McConnell), and &lt;a href="http://www.amazon.co.uk/Smalltalk-Best-Practice-Patterns-Kent/dp/013476904X/ref=sr_1_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1305482343&amp;amp;sr=8-2"&gt;Smalltalk
Best Practice Patterns&lt;/a&gt; (Kent Beck). I’m also always on the lookout for
more. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
In this indefinite series of posts, I’ll share my favourite
techniques and the reasons why I love them.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
As always, I continue to learn and respect other people’s
opinions. Nothing is part of my religion – just the way I currently perceive as
the best approach to writing code. If I gain new insights from others or from
my own adventures, I’ll be sure to present them.&lt;/div&gt;
&lt;h2&gt;



Intention Revealing Messages&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Intention revealing messages are at the heart of clean code
- they are methods which contain only small pieces of code. Their goal - to
explain what the small piece of code, sometimes just a single line, means.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
My favourite place for intention revealing messages is the
conditional in an “if statement”. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Benefit&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
If a method name tells me what the condition means:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="margin-left: 38.25pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;I don’t have to work it out myself &lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 74.25pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;Saves me time&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 74.25pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;saves me hassle &lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 74.25pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;saves my company money &lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 74.25pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;reduces potential for misinterpretation&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 74.25pt; text-indent: -18.0pt;"&gt;
&lt;span style="font-family: 'Courier New';"&gt;o&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&amp;nbsp;highlights a bug (where the name doesn’t match the implementation)&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="margin-left: 74.25pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Cost&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
A method signature and a pair of curly braces - sounds like
a deal.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;An Example&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;if&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; (row
&amp;gt; 0)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp; &amp;nbsp;Rows[row][column].Above = Rows[row - 1][column];&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
This is one if block in a block of 5 and I’m trying to find a
bug which could live in any of them.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
First of all, I have to work out what the author intended.
What does row &amp;gt; 0 mean? After reading associated code &lt;b&gt;for a few minutes&lt;/b&gt;,
it means “not the top row”. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I then have to work out what the code block means – “set the
cell above reference on this cell, using the cell above this one in the row
above” – &lt;b&gt;which takes more time&lt;/b&gt;.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Now imagine that this block of code is only a smart part of
a larger area of code which might have the bug – I’ve got to decode lots of implementations
to work out the high-level algorithm – and then check the implementations match
what I “think” the author intended.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;A solution&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
If I refactor small implementations into methods (intention
revealing messages), for each block, no-one has to work out the intentions –
only that the implementations match the intentions, or the intentions are wrong:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;if&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;
(!IsTopRow(row))&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;SetCellAbove(row, column);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Now I can walk through the code and read the algorithm in
English language. If the algorithm should work theoretically, then I can check
intentions (method names) against implementations (method bodies) - the bugs
will jump out at me. If the algorithm is flawed, then I don’t need to need to
dip into any implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Note: &lt;/i&gt;I've inverted the expression to keep the query positive (a common standard)&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Source&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Intention revealing methods are presented in &lt;a href="http://www.amazon.co.uk/Smalltalk-Best-Practice-Patterns-Kent/dp/013476904X/ref=sr_1_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1305482343&amp;amp;sr=8-2"&gt;Smalltalk
Best Practice Patterns&lt;/a&gt; &amp;nbsp;Using them in this way is recommended by Rob Martin
(Uncle Bob) on &lt;a href="http://www.cleancoders.com/"&gt;www.cleancoders.com&lt;/a&gt;
(episode 3).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-1132051025733762234?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/1132051025733762234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/05/clean-code-tricks-intention-revealing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1132051025733762234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/1132051025733762234'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/05/clean-code-tricks-intention-revealing.html' title='Clean Code Tricks – Intention Revealing Messages'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-2102150979477721271</id><published>2011-04-09T13:46:00.000-07:00</published><updated>2011-04-09T13:46:36.126-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Design Patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>From MVC to MVVM in WPF - My Findings</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;div class="WordSection1"&gt;
&lt;div class="MsoNormal"&gt;
The design for my exciting &lt;a href="https://github.com/NTCoding/Multi-Touch-MusicCatalogue"&gt;Multi-touch Music
Catalogue&lt;/a&gt; is a typical MVC architecture. Or at least it was. Once I’d got
to the end of the first iteration’s coding, I suddenly remembered reading in CODE
magazine about the MVVM pattern. A bit of googling later and this is the
de-facto architecture in WPF, Silverlight and WP7 – no question.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
An opportunity had now presented itself for me to understand
why it is the de-facto standard – and why it is better than MVC / MVP with
which I am more familiar. Below are my findings &lt;b&gt;specific to this project&lt;/b&gt;.&lt;/div&gt;
&lt;h2&gt;
Current Setup&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Using MVC / MVP, the controller/view setup looks like this –
with the view having to implement the IMusicView interface– in the process agreeing
to provide behaviour to maintain state and control &amp;nbsp;the UI – specific methods
for transitioning between display modes.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Controller Interface&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;interface&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IMusicController&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;IMusicView&lt;/span&gt; View { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Tag&lt;/span&gt;&amp;gt;
GetTags();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;void&lt;/span&gt; SetSongMode();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;void&lt;/span&gt; SongSearch(&lt;span style="color: blue;"&gt;string&lt;/span&gt;
tag, &lt;span style="color: blue;"&gt;int&lt;/span&gt; limit = 10, &lt;span style="color: blue;"&gt;int&lt;/span&gt;
page = 1);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;void&lt;/span&gt; SetSongDetailsMode(&lt;span style="color: blue;"&gt;int&lt;/span&gt; songId);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;Stream&lt;/span&gt; GetImage(&lt;span style="color: blue;"&gt;string&lt;/span&gt;
url);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;View Interface&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;interface&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IMusicView&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;ViewMode&lt;/span&gt; Mode { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;IMusicController&lt;/span&gt; Controller { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Tag&lt;/span&gt;&amp;gt;
Tags { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;&amp;gt;
Songs { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt; Song { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;string&lt;/span&gt; StatusMessage { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;void&lt;/span&gt; SetSongMode();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;void&lt;/span&gt; SetSongDetailsMode();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: #2b91af;"&gt;Stream&lt;/span&gt; GetImage(&lt;span style="color: #2b91af;"&gt;Release&lt;/span&gt;
release);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
Combining View/Controller logic into a ViewModel&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
If I was working top-down (my usual preference) the view
would tell me what properties my model needs. But this view is quite simple, so
I can work from controller and view interfaces to create the view model and I
won’t be too far away from where I need to be.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Step 1 – Straight-copy of data from view interface&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Properties on the current view interface are the data items
the view needs. So they are a straight swap to the view model (excluding the
controller). The mode property is an interesting one because the view doesn’t
need it. But I’ll take it anyway (and reconsider later).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;i&gt;View model created with presentation data&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MusicCatalogueViewModel&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ViewMode&lt;/span&gt;
Mode { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Tag&lt;/span&gt;&amp;gt; Tags { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;&amp;gt; Songs { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;
Song { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; StatusMessage
{ &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Step 2 – Translating view methods&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Methods of the view interface correspond to commands in WPF.
So at this point, I’ll create the commands and add them to the VM. Notice here
that logic previously needed to be implemented by every view, is now relocated
to the view model, as commands, and implemented &lt;i&gt;for&lt;/i&gt; any view that uses the model.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I’ve had to remove the GetImage method because it doesn’t
fit with MVVM. So I’ve relocated it to the song class. At this stage the
un-implemented commands are also not a concern.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;i&gt;View model updated with presentation behaviour&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MusicCatalogueViewModel&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ViewMode&lt;/span&gt;
Mode { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Tag&lt;/span&gt;&amp;gt; Tags { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;&amp;gt; Songs { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;
Song { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;
StatusMessage { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SetSongMode&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SetSongModeCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SetSongDetailsMode&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SetSongDetailsModelCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;Step 3 – Translating controller methods&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Behaviour currently on the controller (arguably presenter)
now also belongs in the VM too&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;i&gt;View model updated with controller behaviour&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MusicCatalogueViewModel&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ViewMode&lt;/span&gt;
Mode { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Tag&lt;/span&gt;&amp;gt; Tags { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;&amp;gt; Songs { &lt;span style="color: blue;"&gt;get&lt;/span&gt;;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;
Song { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;
StatusMessage { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SetSongMode&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SetSongModeCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SetSongDetailsMode&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SetSongDetailsModelCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SongSearch&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SongSearchCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
One new addition, SongSearch, is the only code needed from
the controller; mainly because the methods on the view delegated responsibility
to a similar method on the controller. Logic previously in the controller will
now be relocated to the appropriated commands (ICommand).&lt;/div&gt;
&lt;h2&gt;
Implementing INotifyPropertyChanged&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
In a nutshell, to keep view elements and the data they bind
to synchronised, a VM must announce when one of its properties has changed. It
does this by implementing INotifyPropertyChanged and specifying when an update
occurs.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;i&gt;View model after implementing INotifyPropertyChanged&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MusicCatalogueViewModel&lt;/span&gt;
: &lt;span style="color: #2b91af;"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;
_song;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Tag&lt;/span&gt;&amp;gt; _tags;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;&amp;gt; _songs;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;
_statusMessage;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ViewMode&lt;/span&gt;
Mode { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Tag&lt;/span&gt;&amp;gt; Tags&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt;
_tags; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_tags = &lt;span style="color: blue;"&gt;value&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
NotifyPropertyChanged(&lt;span style="color: #a31515;"&gt;"Tags"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;&amp;gt; Songs&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt;
_songs; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_songs = &lt;span style="color: blue;"&gt;value&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
NotifyPropertyChanged(&lt;span style="color: #a31515;"&gt;"Songs"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Song&lt;/span&gt;
Song&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt;
_song; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_song = &lt;span style="color: blue;"&gt;value&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
NotifyPropertyChanged(&lt;span style="color: #a31515;"&gt;"Song"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;
StatusMessage&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt;
_statusMessage; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_statusMessage = &lt;span style="color: blue;"&gt;value&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
NotifyPropertyChanged(&lt;span style="color: #a31515;"&gt;"StatusMessage"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SetSongMode&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SetSongModeCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SetSongDetailsMode&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SetSongDetailsModelCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ICommand&lt;/span&gt;
SongSearch&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SongSearchCommand&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;event&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;PropertyChangedEventHandler&lt;/span&gt; PropertyChanged;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt;
NotifyPropertyChanged(&lt;span style="color: blue;"&gt;string&lt;/span&gt; propertyName)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;if&lt;/span&gt; (PropertyChanged != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
PropertyChanged(&lt;span style="color: blue;"&gt;this&lt;/span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;PropertyChangedEventArgs&lt;/span&gt;(propertyName));&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-autospace: none;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
Advantages of MVVM in this Example&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Having made the switch from MVC to MVVM the first obvious
benefit is lack of logic in the view – zilch to be precise. The further away
from SmartUI the better.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
In my tests and executable specifications, I can now do away
with test doubles for the view. I black-box text my VM – as long as it works,
all the view has to do is bind to the properties and commands (from a
functional perspective).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Because the previously view &amp;nbsp;and controller logic now sit in
the VM, there is less overall code – no more view event handlers delegating
calls to the controller. Less code is generally better, I think most would
agree.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
MVVM works in in WPF, Silverlight and WP7 in the same way. So
if I make my application work on any of those platforms, I’ve got excellent
reuse potential. Or If I create other applications – the foundational knowledge
for developing them in an effective way.&lt;/div&gt;
&lt;h2&gt;
Drawbacks&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Whereas MVC / MVP requires an interface and thus
compile-time checking – MVVM has none of that – and for the same reason – view
binds to properties via “magic strings” - there is no refactoring support. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Announcing a property has changed generally involves calling
NotifyPropertyChanged in the setter – yes the setter – we now have backing
fields for all view-bound properties. Small potatoes, though really.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
What if I wanted to use this view model with another UI
technology that doesn’t support data binding via INotifyPropertyChanged – well,
you’d probably see something different – whereas MVC your new view just
implements the interface and provides its own presentational behaviours. Off
the top of my head, I can only imagine that’s WinForms – and not a concern for
me.&lt;/div&gt;
&lt;h2&gt;
Conclusion&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Switching from MVC to MVVM has been a relatively trivial
task once I’d read a few blogs and watched a screencast or two. For my efforts
I have an application that now works a way more suited to WPF. I also have a
good understanding of how to design applications for not just WPF, but
Silverlight and WP7 as well.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Now all my tests and executable specifications have broken.
Better go and fix them so I can push my changes and allow you all to play with
my code and tell me how there are millions of ways to do it better.&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-2102150979477721271?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/2102150979477721271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/04/from-mvc-to-mvvm-in-wpf-my-findings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2102150979477721271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2102150979477721271'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/04/from-mvc-to-mvvm-in-wpf-my-findings.html' title='From MVC to MVVM in WPF - My Findings'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-337557929484531974</id><published>2011-03-27T13:22:00.000-07:00</published><updated>2011-03-27T13:24:14.973-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Multi-touch'/><category scheme='http://www.blogger.com/atom/ns#' term='BDD'/><category scheme='http://www.blogger.com/atom/ns#' term='NUI'/><category scheme='http://www.blogger.com/atom/ns#' term='Projects'/><category scheme='http://www.blogger.com/atom/ns#' term='Agile'/><title type='text'>Multi-Touch Music Catalogue – Part 1: Getting Started</title><content type='html'>&lt;div class="WordSection1"&gt;
&lt;h2&gt;

Intro&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Towards the end of 2011 I went to a talk on multi-touch in
.NET at &lt;a href="http://www.nxtgenug.net/"&gt;NxtGenUG&lt;/a&gt; Birmingham, by &lt;a href="http://twitter.com/#!/GuySmithFerrier"&gt;Guy Smith Ferrier&lt;/a&gt;. This was my
first experience of multi-touch and I was amazed at how ready the technology
was for developers. Basically, it’s here – go use it, get stuck in, have some
fun.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
As a treat I bought myself a multi-touch capable monitor,
the Dell SX2210T for Christmas. Early this year I was then looking for a
multi-touch book. Guy Smith Ferrier kindly pointed me towards &lt;a href="http://twitter.com/#!/joshblake"&gt;Josh Blake’s&lt;/a&gt; &amp;nbsp;&lt;a href="http://www.manning.com/blake/"&gt;Natural User Interfaces in .NET&lt;/a&gt; early
access edition –which I’ve made good progress with and highly recommend.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So now I’m at a stage where I want to develop an application
and see what damage I can do with the multi-touch API’s available to me. As it
happens, I also want to learn &lt;a href="https://github.com/"&gt;Git&lt;/a&gt; and play
with a new agile ‘project management’ toy &lt;a href="http://www.speclog.net/"&gt;SpecLog&lt;/a&gt;.
So I had an idea – I’ll create a multi-touch music catalogue using all of these
tools – sweet!&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
To get data into my application I’ll be using the &lt;a href="http://developer.7digital.net/"&gt;7Digital API&lt;/a&gt;. In a simple spike
project I found it really easy to work with; the documentation is great; and I
got a riposte to a query on the mailing list. Also, if it’s good enough for &lt;a href="http://developer.7digital.net/CaseStudies/Spotify"&gt;Spotify&lt;/a&gt; and the &lt;a href="http://developer.7digital.net/CaseStudies/BlackBerryMusicApp"&gt;BlackBerry
Music App&lt;/a&gt;, it should (just about) meet my exquisite demands. As a side-benefit,
I’ll have a nice .NET API that wraps their API which may be of use to others.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
While creating the application I’ll be blogging about what I’ve
learnt from the tools I’m using and decisions I’ve made with my application. I’ll
also be welcoming of any comments, criticisms and suggestions about absolutely anything
– usability (especially NUI), coding style, architecture, testing, specs, go
crazy folks.&lt;/div&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

Creating my GitHub Repository&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
My first task was to create an empty solution and &lt;a href="https://github.com/NTCoding/Multi-Touch-MusicCatalogue"&gt;get it hosted on GitHub&lt;/a&gt;.
This actually took me about an hour or two. But that was because I did plenty
of research, and I’m glad I did – everything has run smoothly since then.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Initially I followed the &lt;a href="http://help.github.com/win-set-up-git/"&gt;getting started advice&lt;/a&gt; on GitHub
and read the first two chapters of the &lt;a href="http://progit.org/book/ch1-3.html"&gt;recommended reading&lt;/a&gt;. I followed
that up by downloading two tools: one that makes working with git on Windows
easy; and one for Visual Studio integration. I have to thank Krzystof Kozmic
for making me aware of these tools in &lt;a href="http://devlicio.us/blogs/krzysztof_kozmic/archive/2011/01/26/git-tooling-for-net-developers.aspx?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+Devlicious+%28Devlicio.us%29"&gt;this
blog post&lt;/a&gt;.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Now my application has a permanent home on GitHub. &lt;a href="https://github.com/NTCoding/Multi-Touch-MusicCatalogue"&gt;Here is the
repository&lt;/a&gt; if you want to check out current progress.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;

Capturing my Requirements with SpecLog&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
For almost a year now I’ve been using &lt;a href="http://www.specflow.org/"&gt;SpecFlow&lt;/a&gt; to create executable
specifications on some of my projects. Check out my &amp;nbsp;“BDD” blog posts if you’d
like to see how I have used (and abused) SpecFlow.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The guys at TechTalk who created &lt;a href="http://www.specflow.org/"&gt;SpecFlow&lt;/a&gt; have now created &lt;a href="http://www.speclog.net/"&gt;SpecLog&lt;/a&gt; which they say is ‘designed for
managing requirements in agile projects’. On their website you can see some clips
that show you how to use it – personally I think they are very impressive – but
I haven’t used many tools of this nature – so take my opinions for what they
are worth.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For my Multi-Touch Music Catalogue, I used SpecLog to plan 7
iterations (which will probably change). Doing this I was able to relate user
stories to business goals – and then link user stories to the feature files I
had created in my Visual Studio solution. With this done I can associate
information with user stories like comments and images – obviously more useful
in a multi-developer production environment.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I have found SpecLog to be very friendly. Some of the
windows are a little small, but apart from that it has good usability and is
notably easy on the eye.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-JwaXbsJItWE/TY-b6QdzarI/AAAAAAAAADM/-6tNRbWaCIE/s1600/SpecLog1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="306" src="http://1.bp.blogspot.com/-JwaXbsJItWE/TY-b6QdzarI/AAAAAAAAADM/-6tNRbWaCIE/s400/SpecLog1.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Above is a screenshot of my requirements for iteration 1 –
totally related to the business goal of allowing users to search for songs. The
graphical relationship between business goals and user stories is a nice touch –
and psychologically this kind of diagram is almost proven to help you understand
the information it represents.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I have only written the user stories for the first few
iterations, the rest are just business goals that I will flesh out later or
change as my ideas for the application do. In an ‘enterprise’ environment, you
would probably lay out all the stories on your main work space and then devise
your exact iterations at the start of the project (I would guess).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-dVK_bXo4kBA/TY-cE_FFKII/AAAAAAAAADQ/34B7Q4CLdYc/s1600/SpecLogDetailsPage.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="386" src="http://3.bp.blogspot.com/-dVK_bXo4kBA/TY-cE_FFKII/AAAAAAAAADQ/34B7Q4CLdYc/s400/SpecLogDetailsPage.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
In the above screenshot, you can see the details for a
particular user story – note how I’ve linked it to a feature file in the
solution and it has imported that feature file. I can see the obvious benefit
here of non-developers, clients maybe, using SpecLog to keep tabs on what the
developers are working on and the project’s progress.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The “Add criterion” button allows comments and images to be
associated with this file, which again seems to be a nice touch (but I haven’t
trialled in a production environment).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
If you want to have a look at my SpecLog repository and see
exactly what I’ve been upto, you can get it from &lt;a href="https://github.com/NTCoding/Multi-Touch-MusicCatalogue"&gt;my GitHub page&lt;/a&gt;
&amp;nbsp;and open with SpecLog which you can &lt;a href="http://www.speclog.net/download/"&gt;download
here&lt;/a&gt;.&lt;/div&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

Plan &lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
My plan for the application is quite simple, and fits with
my reasons for creating the application. Iteration 1 is all about getting some
basic functionality. Iteration 2 is then going crazy with multi-touch features
(such as multiple layout options) which is the main reason I am creating the
application. Although every iteration may include multi-touch improvements,
iteration 2 is a pure multi-touch R &amp;amp; D experience.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&amp;nbsp;Following iterations then add more functionality up to the
point where you can purchase songs – although making profit it not the goal.
But if I’m in a position where people want to use this application to purchase songs,
then I’ll be happy to let them – the 7Digital API is fully supportive of this.
Personally, I’d be content knowing that people just want to use the application
(it’s not a load of pants basically).&lt;/div&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

Conclusion&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Exciting times are ahead due to this project which
epitomises why I love software development – there are always new tools and
technologies, and so many options that let you be creative and imaginative. At
the same time you get some nice object-oriented challenges to sink your teeth
into (in this case creating the service that will communicate with the 7Digital
API).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
It would be great if you could contribute and share your
opinions.&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-337557929484531974?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/337557929484531974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/03/multi-touch-music-catalogue-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/337557929484531974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/337557929484531974'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/03/multi-touch-music-catalogue-part-1.html' title='Multi-Touch Music Catalogue – Part 1: Getting Started'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-JwaXbsJItWE/TY-b6QdzarI/AAAAAAAAADM/-6tNRbWaCIE/s72-c/SpecLog1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-8528945813007993623</id><published>2011-03-03T10:02:00.000-08:00</published><updated>2011-06-14T01:22:23.389-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Gembox Excel Downloads in ASP.NET MVC</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:12.0pt;
 margin-left:0cm;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
 {margin:0cm;
 margin-bottom:.0001pt;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:12.0pt;
 margin-left:36.0pt;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:12.0pt;
 margin-left:36.0pt;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;

&lt;br /&gt;
&lt;div class="WordSection1"&gt;
&lt;div class="MsoNormal"&gt;
Excel – the number-crunching tool of choice for
business-bods the world over. If you’re developing complex, bespoke web-apps
for these folk then Excel downloads are invaluable…inevitable…inexorable. They
want their data in .csv, .xls, .xlsx and even
.iWantThisTodayButIllWantThatTomorrowAndSomethingElseNextWeek.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
My tool of choice for catering to Excel needs in .NET is
&lt;a href="http://www.gemboxsoftware.com/"&gt;Gembox&lt;/a&gt;. “Word” has it the Office Interop libraries lack the full
capabilities you’ll need and most importantly are a drain on critical
performance in a web environment.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Gembox, however great, likes to work with streams – output streams
in particular. Give it a memory stream, and it will give you hassle. So this
makes life impossible when working with the FileResult in an MVC controller. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The examples available on the official site show Gembox
files being written directly to the response’s output stream. But no – not in
an MVC controller????&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Don’t be silly – unless you’re a cow boy. In which case,
switch off now and lasso that tightly-coupled spaghetti code into all sorts of
future-pain shaped pieces.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For those of use sitting on the scale between conscientious
and perfectionist&amp;nbsp; - and for the record, I only just make the grade – then for
us people, we create a custom action result, and do all our interaction with
the response in that little haven. We also do it in a flexible way which
encapsulates the logic bound to ASP.NET MVC interfaces.&lt;/div&gt;
&lt;div class="MsoNoSpacing"&gt;
Alas, you’re probably gagging for code, so feast on this:&lt;/div&gt;
&lt;div class="MsoNoSpacing"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;public&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;abstract&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;class&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ExcelResult&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;:&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ActionResult&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;private&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;readonly&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ExcelFile&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;_file;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;private&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;readonly&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;_fileName;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;ExcelResult(&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ExcelFile&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;file,&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;fileName)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_file&amp;nbsp;=&amp;nbsp;file;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_fileName&amp;nbsp;=&amp;nbsp;fileName;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;abstract&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;ContentType&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;get&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;abstract&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;Extension&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;get&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;abstract&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Action&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ExcelFile&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;Stream&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;gt;&amp;nbsp;SaveAction&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;get&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;public&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;override&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;void&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;ExecuteResult(&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ControllerContext&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;context)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
context.HttpContext.Response.Clear();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
context.HttpContext.Response.ContentType&amp;nbsp;=&amp;nbsp;ContentType;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
context.HttpContext.Response.AddHeader(&lt;/span&gt;&lt;span lang="EN-US" style="color: lime; font-family: Consolas; font-size: 12pt;"&gt;"Content-disposition"&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: lime; font-family: Consolas; font-size: 12pt;"&gt;"filename="&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;+&amp;nbsp;_fileName&amp;nbsp;+&amp;nbsp;Extension);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
SaveAction(_file,&amp;nbsp;context.HttpContext.Response.OutputStream);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&amp;nbsp;Essentially, this abstract class contains the logic that
sets up the response, but parameterises the actual data and the file name. It
also defines an interface that types of Excel file (csv, xls, xlsx,
blah-bluh-bleh) must provide implementations for –content type and the file
extension.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
SaveAction is the “parameter” which provides the data - it
takes a method with two parameters – the Gembox ExcelFile you supply in the
constructor and a Stream – which you can see is the Reponse.OutputStream. All
the base class wants you to do is put the data in the stream and think happy
thoughts.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
If the interface for ExecuteMethod on ActionResult changes
in a future version of MVC, we only have to tweak the method in this base
class. If we also wanted to use different Excel providers, we could use an
IExcelFile interface. Yagni, Yagni, Yagni. Ok, you get the get message. I’ve just
done what’s needed here, but made life easy in the future without any cost now
and been bone-DRY in the process.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
An example of a concrete class, in this case for Csv files
produced by Gembox, would look remarkably similar to this:&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;public&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;class&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;CsvResult&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;:&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ExcelResult&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;public&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;CsvResult(&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ExcelFile&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;file,&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;fileName)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
:&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;base&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;(file,&amp;nbsp;fileName)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;override&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;ContentType&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;get&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;return&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: lime; font-family: Consolas; font-size: 12pt;"&gt;"application/csv"&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm; text-indent: 36.0pt;"&gt;
&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;override&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;Extension&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;get&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;return&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: lime; font-family: Consolas; font-size: 12pt;"&gt;".csv"&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;override&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Action&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;ExcelFile&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: yellow; font-family: Consolas; font-size: 12pt;"&gt;Stream&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;gt;&amp;nbsp;SaveAction&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;get&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #ff8000; font-family: Consolas; font-size: 12pt;"&gt;return&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;(f,&amp;nbsp;s)&amp;nbsp;=&amp;gt;&amp;nbsp;f.SaveCsv(s,&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;CsvType&lt;/span&gt;&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;.CommaDelimited);&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #282828; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;
&lt;span lang="EN-US" style="color: white; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I’m lost for words. There’s absolutely nothing to talk about
– so simple it explains itself. If you now need to create one for .xls, .xlsx
or some of the other open formats supported by Gembox, then all the hard work
has been done.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
To use these custom results, return a new instance of the
desired sub-class, passing the Gembox ExcelFile along with a filename. Your
users get an Excel document and your colleagues will think you're cool.&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-8528945813007993623?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/8528945813007993623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/03/gembox-excel-downloads-in-aspnet-mvc.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/8528945813007993623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/8528945813007993623'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/03/gembox-excel-downloads-in-aspnet-mvc.html' title='Gembox Excel Downloads in ASP.NET MVC'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-338661520768654537</id><published>2011-01-24T13:19:00.000-08:00</published><updated>2011-01-24T13:19:59.328-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Augmenting the [AutoLoad] - Logical Parameter Names</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h1
 {mso-style-link:"Heading 1 Char";
 margin-top:24.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:14.0pt;
 font-family:"Cambria","serif";
 color:#365F91;}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
h3
 {mso-style-link:"Heading 3 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:11.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading1Char
 {mso-style-name:"Heading 1 Char";
 mso-style-link:"Heading 1";
 font-family:"Cambria","serif";
 color:#365F91;
 font-weight:bold;}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.Heading3Char
 {mso-style-name:"Heading 3 Char";
 mso-style-link:"Heading 3";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;
&lt;div class="WordSection1"&gt;
&lt;h2&gt;
Introduction&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
A few days ago I &lt;a href="http://ntcoding.blogspot.com/2011/01/elegant-opt-in-model-binding-to.html"&gt;blogged
about my custom model binder attribute&lt;/a&gt; for model binding to entities
managed by a persistence framework. I also mentioned, there were a number of
ways it could be improved. And since then, I’ve had even more ideas. &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The most fundamental issue was the parameter names – I can’t
bind to a parameter called “id” just because that is the key of a key-value
pair supplied by the request. This coupling has to be destroyed.&lt;/div&gt;
&lt;h2&gt;

Separating Model Names and Request Names&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
At the moment, when model binding, the key for a value sent
in the request, must match the name of the parameter that the model binder
works on. But this isn’t good. Can you see why?&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: #2b91af;"&gt;ViewResult&lt;/span&gt; Details([&lt;span style="color: #2b91af;"&gt;AutoLoad&lt;/span&gt;]&lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt; id)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; View(id);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Yes, I know you can – the name id doesn’t make sense and it
makes me feel insecure about my employment status. Fortunately, we can keep the
attribute concise, &lt;i&gt;and&lt;/i&gt; have flexibility with parameter names. It’s a
two-step process:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18pt;"&gt;
1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Tell
the model binder what key to look for and ignore the name of the parameter&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18pt;"&gt;
2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Add
an option to manually specify the key&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So the current key is the ModelName – the name of the
parameter:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;var&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;
valueKey = bindingContext.ModelName;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
What I’m going to do is step in here and say, the default is
now “id” unless I tell you otherwise. The updated code looks like so:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;private&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;const&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;
DefaultValueKey = &lt;span style="color: #a31515;"&gt;"id"&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;
ValueKey { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; AutoLoadModelBinder(&lt;span style="color: blue;"&gt;string&lt;/span&gt; valueKey = DefaultValueKey)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ValueKey = valueKey;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt;
&lt;span style="color: blue;"&gt;object&lt;/span&gt; BindModel(&lt;span style="color: #2b91af;"&gt;ControllerContext&lt;/span&gt;
controllerContext, &lt;span style="color: #2b91af;"&gt;ModelBindingContext&lt;/span&gt;
bindingContext)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; typeBeingBoundTo =
bindingContext.ModelType;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; rawValue =
bindingContext.ValueProvider.GetValue(ValueKey);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Have a quick glance at the constant “DefaultValueKey” with
the value id. If no value is specified as the constructor’s optional parameter,
then this is the key that the value provider will be queried for. And
obviously, to override, you just pass your desired key into the constructor.&lt;/div&gt;
&lt;h3&gt;

Keeping the AutoLoad Attrbute in Sync&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
We’ve allowed the binder to specify a key, but the key
will need to be propagated down from the attribute. Again, that’s really
trivial and it looks like so:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;AutoLoadAttribute&lt;/span&gt;
: &lt;span style="color: #2b91af;"&gt;CustomModelBinderAttribute&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;readonly&lt;/span&gt;
&lt;span style="color: blue;"&gt;string&lt;/span&gt; _valueKey;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; AutoLoadAttribute(&lt;span style="color: blue;"&gt;string&lt;/span&gt; valueKey)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
_valueKey = valueKey;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; AutoLoadAttribute()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt;
&lt;span style="color: #2b91af;"&gt;IModelBinder&lt;/span&gt; GetBinder()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; !&lt;span style="color: blue;"&gt;string&lt;/span&gt;.IsNullOrEmpty(_valueKey)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
? &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;AutoLoadModelBinder&lt;/span&gt;(_valueKey)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
: &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;AutoLoadModelBinder&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;
Attributes and default parameters don’t like to play nicely, so we have to have
an overload for the constructor. But the rest is pretty self explanatory.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
If I now go back to my details action, and just change the
name of the parameter:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: #2b91af;"&gt;ViewResult&lt;/span&gt; Details([&lt;span style="color: #2b91af;"&gt;AutoLoad&lt;/span&gt;]&lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt; healthFood)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; View(healthFood);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Not only does the code make sense, but it actually still
works. Fantastico.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
The assumption here is that the form posts the id for this
HealthFood using the name &amp;nbsp;“id” – the default value in the model binder. But if
it wasn’t and it was “healthFoodId”, well I could just do this:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: #2b91af;"&gt;ViewResult&lt;/span&gt; Details([&lt;span style="color: #2b91af;"&gt;AutoLoad&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"healthFoodId"&lt;/span&gt;)]&lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt;
healthFood)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;/div&gt;
&lt;h3&gt;

Why is This Useful?&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Good question. Let’s say you are creating an object, like
HealthFood, that has a many-to-many association with “HealthBenefit”. You might
want to create a new instance of HealthFood, and model bind to a HealthBenefit,
using the name “healthBenefitId”, which you can then associate in the
controller directly, rather than via a repository query – bleugh!.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Conclusion&lt;/h3&gt;
&amp;nbsp;After a successful proof-of-concept in the last post for elegant, opt-int model-binding to persistent entities, work needs to be done to tidy up and add significant value to the [AutoLoad] custom model binder attribute. In this blog post I removed the coupling between the parameter name and the key of the value in the request being bound to.&lt;br /&gt;
&lt;br /&gt;
I've still managed to dodge the bullet of making this tool ORM-agnostic and I am to still to make it work on Http Post requests. Let's not forget, we'd like to model bind to collections - on their own, or as child entities of other domain entities.&lt;br /&gt;
&lt;br /&gt;
Plenty more to come then.&lt;br /&gt;
&lt;br /&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas;
color:blue'&gt;public&lt;/span&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt; &lt;span
style='color:blue'&gt;class&lt;/span&gt; &lt;span style='color:#2B91AF'&gt;AutoLoadModelBinder&lt;/span&gt;
: &lt;span style='color:#2B91AF'&gt;DefaultModelBinder&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;   
{&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;private&lt;/span&gt; &lt;span style='color:blue'&gt;const&lt;/span&gt; &lt;span
style='color:blue'&gt;string&lt;/span&gt; DefaultValueKey = &lt;span style='color:#A31515'&gt;&amp;quot;id&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;private&lt;/span&gt; &lt;span style='color:blue'&gt;string&lt;/span&gt;
ValueKey { &lt;span style='color:blue'&gt;get&lt;/span&gt;; &lt;span style='color:blue'&gt;set&lt;/span&gt;;
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;public&lt;/span&gt; AutoLoadModelBinder(&lt;span
style='color:blue'&gt;string&lt;/span&gt; valueKey = DefaultValueKey)&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
{&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
ValueKey = valueKey;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;public&lt;/span&gt; &lt;span style='color:blue'&gt;override&lt;/span&gt;
&lt;span style='color:blue'&gt;object&lt;/span&gt; BindModel(&lt;span style='color:#2B91AF'&gt;ControllerContext&lt;/span&gt;
controllerContext, &lt;span style='color:#2B91AF'&gt;ModelBindingContext&lt;/span&gt;
bindingContext)&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
{&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;var&lt;/span&gt; typeBeingBoundTo =
bindingContext.ModelType;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;var&lt;/span&gt; rawValue =
bindingContext.ValueProvider.GetValue(ValueKey);&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;var&lt;/span&gt; entityId = &lt;span style='color:#2B91AF'&gt;Convert&lt;/span&gt;.ToInt32(rawValue.RawValue);&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:green'&gt;//&lt;/span&gt;&lt;b&gt;&lt;span style='color:darkblue'&gt;TODO - tied
to implementation details - I know&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;var&lt;/span&gt; dataContext = &lt;span style='color:blue'&gt;new&lt;/span&gt;
&lt;span style='color:#2B91AF'&gt;AutoLoadModelBinderExampleContext&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;var&lt;/span&gt; allItemsOfType =
dataContext.Set(typeBeingBoundTo);&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;var&lt;/span&gt; entityBeingBoundTo = allItemsOfType.Find(&lt;span
style='color:blue'&gt;new&lt;/span&gt; &lt;span style='color:blue'&gt;object&lt;/span&gt;[]
{entityId});&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;return&lt;/span&gt; entityBeingBoundTo;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;   
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas;
color:blue'&gt;public&lt;/span&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt; &lt;span
style='color:blue'&gt;class&lt;/span&gt; &lt;span style='color:#2B91AF'&gt;AutoLoadAttribute&lt;/span&gt;
: &lt;span style='color:#2B91AF'&gt;CustomModelBinderAttribute&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;   
{&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;private&lt;/span&gt; &lt;span style='color:blue'&gt;readonly&lt;/span&gt;
&lt;span style='color:blue'&gt;string&lt;/span&gt; _valueKey;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;public&lt;/span&gt; AutoLoadAttribute(&lt;span
style='color:blue'&gt;string&lt;/span&gt; valueKey)&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
{&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
_valueKey = valueKey;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;public&lt;/span&gt; AutoLoadAttribute()&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
{&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
&lt;span style='color:blue'&gt;public&lt;/span&gt; &lt;span style='color:blue'&gt;override&lt;/span&gt;
&lt;span style='color:#2B91AF'&gt;IModelBinder&lt;/span&gt; GetBinder()&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
{&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;           
&lt;span style='color:blue'&gt;return&lt;/span&gt; !&lt;span style='color:blue'&gt;string&lt;/span&gt;.IsNullOrEmpty(_valueKey)&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;                      
? &lt;span style='color:blue'&gt;new&lt;/span&gt; &lt;span style='color:#2B91AF'&gt;AutoLoadModelBinder&lt;/span&gt;(_valueKey)&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;                      
: &lt;span style='color:blue'&gt;new&lt;/span&gt; &lt;span style='color:#2B91AF'&gt;AutoLoadModelBinder&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;       
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'&gt;&lt;span style='font-size:9.5pt;font-family:Consolas'&gt;   
}&lt;/span&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt;

&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-338661520768654537?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/338661520768654537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/01/augmenting-autoload-logical-parameter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/338661520768654537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/338661520768654537'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/01/augmenting-autoload-logical-parameter.html' title='Augmenting the [AutoLoad] - Logical Parameter Names'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-2053018642410464975</id><published>2011-01-22T06:50:00.000-08:00</published><updated>2011-01-22T07:16:32.046-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Elegant, Opt-in Model Binding to Persistence Entities in ASP.NET MVC</title><content type='html'>&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Wingdings;
 panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Tahoma;
 panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
 {font-family:Consolas;
 panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:0cm;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
h2
 {mso-style-link:"Heading 2 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:13.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
h3
 {mso-style-link:"Heading 3 Char";
 margin-top:10.0pt;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:0cm;
 margin-bottom:.0001pt;
 line-height:115%;
 page-break-after:avoid;
 font-size:11.0pt;
 font-family:"Cambria","serif";
 color:#4F81BD;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {color:purple;
 text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 {mso-style-link:"Balloon Text Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:8.0pt;
 font-family:"Tahoma","sans-serif";}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
 {margin:0cm;
 margin-bottom:.0001pt;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:10.0pt;
 margin-left:36.0pt;
 line-height:115%;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";}
span.Heading2Char
 {mso-style-name:"Heading 2 Char";
 mso-style-link:"Heading 2";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.Heading3Char
 {mso-style-name:"Heading 3 Char";
 mso-style-link:"Heading 3";
 font-family:"Cambria","serif";
 color:#4F81BD;
 font-weight:bold;}
span.BalloonTextChar
 {mso-style-name:"Balloon Text Char";
 mso-style-link:"Balloon Text";
 font-family:"Tahoma","sans-serif";}
.MsoChpDefault
 {font-family:"Calibri","sans-serif";}
.MsoPapDefault
 {margin-bottom:10.0pt;
 line-height:115%;}
@page WordSection1
 {size:595.3pt 841.9pt;
 margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
 {page:WordSection1;}
 /* List Definitions */
 ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;
&lt;div class="WordSection1"&gt;
&lt;h3&gt;




&lt;i&gt;&lt;span style="font-family: &amp;quot;Cambria&amp;quot;,&amp;quot;serif&amp;quot;; font-style: normal;"&gt;Introduction&lt;/span&gt;&lt;/i&gt;&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
&lt;i&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-style: normal;"&gt;ASP.NET MVC is awesome. I really enjoy programming with it. Two
features that make it great are its “plugability” and extensibility; which is
good – because I feel the default model binder can be improved in certain
scenarios. One such scenario is when you want to get persistent entities from a
repository via your ORM tool. Rather than taking an ID and doing a query – just
model bind straight to it.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;i&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-style: normal;"&gt;Negatives to this approach are that it could cause security
concerns if you have nested persistent entities automatically loaded based on
form values. So ideally, you want to opt-in to this model binder – but you don’t
want the opt-in to be a verbose attribute declaration (more on this later).&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;i&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-style: normal;"&gt;For me, the ideal is an elegant, but obvious declaration.
And for me, I have this ideal&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="font-family: Wingdings; font-style: normal;"&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-style: normal;"&gt;. Read on and it can be yours too.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;h2&gt;




&lt;i&gt;&lt;span style="font-family: &amp;quot;Cambria&amp;quot;,&amp;quot;serif&amp;quot;; font-style: normal;"&gt;Shut Up
and Code&lt;/span&gt;&lt;/i&gt;&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Rather than just showing the implementation, I’m going to
show you a working example. To do this I’ll be using an MVC 3 web application
and the new MvcScaffolding – awesomely demonstrated by the genius Steven
Sanderson &lt;a href="http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/"&gt;here&lt;/a&gt;
and &lt;a href="http://blog.stevensanderson.com/2011/01/13/mvcscaffolding-standard-usage/"&gt;here&lt;/a&gt;
.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
If you want to follow this example, these features mean you
only need spare 5 minutes of your time.&lt;/div&gt;
&lt;h2&gt;




Setup&lt;/h2&gt;
&lt;div class="MsoListParagraphCxSpFirst"&gt;
Let’s do it:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72pt; text-indent: -18pt;"&gt;
1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Create
a new MVC 3 web application:&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 108pt; text-indent: -18pt;"&gt;
a.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;Razor view engine&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 108pt; text-indent: -18pt;"&gt;
b.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;Internet application&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 108pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72pt; text-indent: -18pt;"&gt;
2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Create
a domain model&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="margin-left: 108pt; text-indent: -18pt;"&gt;
a.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Add
a “HealthFood” class to the “Models” folder – like so&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt;
&lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;virtual&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; Id { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;virtual&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; Name { &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 90pt;"&gt;
&lt;b&gt;Above:&lt;/b&gt; HealthFood – our domain model (virtual properties for ORM)&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpFirst"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72pt; text-indent: -18pt;"&gt;
3.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NuGet:
Install-Package MvcScaffolding&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72pt; text-indent: -18pt;"&gt;
4.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NuGet:
Scaffold Controller HealthFood&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="margin-left: 72pt; text-indent: -18pt;"&gt;
5.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Run
the application after adding a link to the HealthFood controller. Then add a
few entries&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 54pt; text-indent: 18pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"&gt;ul&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="menu"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;li&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% yellow;"&gt;@&lt;/span&gt;Html.ActionLink(&lt;span style="color: #a31515;"&gt;"Home"&lt;/span&gt;, &lt;span style="color: #a31515;"&gt;"Index"&lt;/span&gt;,
&lt;span style="color: #a31515;"&gt;"Home"&lt;/span&gt;)&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;li&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;li&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% yellow;"&gt;@&lt;/span&gt;Html.ActionLink(&lt;span style="color: #a31515;"&gt;"About"&lt;/span&gt;, &lt;span style="color: #a31515;"&gt;"About"&lt;/span&gt;,
&lt;span style="color: #a31515;"&gt;"Home"&lt;/span&gt;)&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;li&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;li&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% yellow;"&gt;@&lt;/span&gt;Html.ActionLink(&lt;span style="color: #a31515;"&gt;"Health Foods"&lt;/span&gt;, &lt;span style="color: #a31515;"&gt;"Index"&lt;/span&gt;,
&lt;span style="color: #a31515;"&gt;"HealthFood"&lt;/span&gt;)&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;li&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ul&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;Above:&lt;/b&gt; A link to the HealthFood
controller in _Layout.cshtml&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_QZlBWCg5wmg/TTruJceReGI/AAAAAAAAADA/BYzVMLZZn6o/s1600/HealthFoods+-+DetailsView.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="268" src="http://1.bp.blogspot.com/_QZlBWCg5wmg/TTruJceReGI/AAAAAAAAADA/BYzVMLZZn6o/s400/HealthFoods+-+DetailsView.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Above:&lt;/b&gt; A few HealthFoods added to the system&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3&gt;




Rain-Check&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
With a system all set, a few entries added – let’s check
what the default behaviour is for viewing an object – the edit action.&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: #2b91af;"&gt;ActionResult&lt;/span&gt; Edit(&lt;span style="color: blue;"&gt;int&lt;/span&gt;
id)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt; p = context.HealthFoods.Single(x =&amp;gt;
x.Id == id);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; View(p);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So, what happens is that we take the Id from the posted form
values and query our “repository”. We then return the HealthFood to the view.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
What if I want to model bind directly to the HealthFood –
what if I’ve got many examples of this scenario – I can save a lot of code and
make things DRY – and even testable – if I had a reason for testing controllers
(rarely that I ever do).&lt;/div&gt;
&lt;h3&gt;




AutoLoad Model Binder&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Creating a model binder to retrieve persistent entities is
actually fairly easy in this scenario. I’ve avoided the bullet of generic
repositories, but I will be adding this feature soon.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Here’s the model binder which I’ve added to a new folder in
the project called “ModelBinders”.&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;AutoLoadModelBinder&lt;/span&gt; : &lt;span style="color: #2b91af;"&gt;DefaultModelBinder&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt;
&lt;span style="color: blue;"&gt;object&lt;/span&gt; BindModel(&lt;span style="color: #2b91af;"&gt;ControllerContext&lt;/span&gt;
controllerContext, &lt;span style="color: #2b91af;"&gt;ModelBindingContext&lt;/span&gt;
bindingContext)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; typeBeingBoundTo =
bindingContext.ModelType;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; valueKey = bindingContext.ModelName;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; rawValue =
bindingContext.ValueProvider.GetValue(valueKey);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; entityId = &lt;span style="color: #2b91af;"&gt;Convert&lt;/span&gt;.ToInt32(rawValue.RawValue);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: green;"&gt;//&lt;/span&gt;&lt;b&gt;&lt;span style="color: darkblue;"&gt;TODO - tied
to implementation details - I know&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; dataContext = &lt;span style="color: blue;"&gt;new&lt;/span&gt;
&lt;span style="color: #2b91af;"&gt;AutoLoadModelBinderExampleContext&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; allItemsOfType =
dataContext.Set(typeBeingBoundTo);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;var&lt;/span&gt; entityBeingBoundTo = allItemsOfType.Find(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;object&lt;/span&gt;[]
{entityId});&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; entityBeingBoundTo;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Remember the requirement where I wanted an opt-in scheme –
so this model binder doesn’t apply by default. Well, to make it work this way,
we apply it to our action parameter like so:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: #2b91af;"&gt;ViewResult&lt;/span&gt; Details([&lt;span style="color: #2b91af;"&gt;ModelBinder&lt;/span&gt;((&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af;"&gt;AutoLoadModelBinder&lt;/span&gt;)))]&lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt; id)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; View(id);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;




Testing Out the AutoLoad Model Binder&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
If you now run the app again and navigate to the details
page for a HealthFood – it works. It still works. Hence, the model binder
works, and it’s an opt-in scheme….&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
…but the declaration is ugly. It’s clunky - it makes the
controller look horrible if I’m honest. What can we do about that?&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Well, I figured, I could just extend the ModelBinder
attribute, rename it to AutoLoad and hard code the AutoLoadModelBinder into its
constructor. But ReSharper doesn’t like that. The compiler doesn’t like that…I
don’t’ like that.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So I check out the metadata for the ModelBinder class and I
see that this cheeky boy, whilst sealed and having none of it, inherits the “CustomModelBinderAttribute”
class. Awesome – game on.&lt;/div&gt;
&lt;h3&gt;




Improving the AutoLoad ModelBinder’s Usage&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
With this new information – the “CustomModelBinderAttribute”
- a class I never knew existed – I created the following:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;public&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;AutoLoadAttribute&lt;/span&gt;
: &lt;span style="color: #2b91af;"&gt;CustomModelBinderAttribute&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt;
&lt;span style="color: #2b91af;"&gt;IModelBinder&lt;/span&gt; GetBinder()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;AutoLoadModelBinder&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
I put this class in the “ModelBinders” folder, but you can
stick it anywhere you like (no offence).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
All it does is ensure that the model binder used is my AutoLoadModelBinder.&lt;/div&gt;
&lt;h3&gt;




Testing out the AutoLoad Attribute&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
Now we have the “AutoLoad” attribute. We can simplify this:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;([&lt;span style="color: #2b91af;"&gt;ModelBinder&lt;/span&gt;(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af;"&gt;AutoLoadModelBinder&lt;/span&gt;))] &lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt;
id)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
…to this:&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;([&lt;span style="color: #2b91af;"&gt;AutoLoad&lt;/span&gt;]&lt;span style="color: #2b91af;"&gt;HealthFood&lt;/span&gt;
id)&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;




Sanity Check&lt;/h3&gt;
&lt;div class="MsoNormal"&gt;
So let’s test it out. What happens when we head to the
details page for a HealthFood now?&lt;/div&gt;
&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_QZlBWCg5wmg/TTrt4qTwWRI/AAAAAAAAAC8/EZTDx2u7SRY/s1600/auto+load+still+works.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="268" src="http://2.bp.blogspot.com/_QZlBWCg5wmg/TTrt4qTwWRI/AAAAAAAAAC8/EZTDx2u7SRY/s400/auto+load+still+works.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Above: &lt;/b&gt;AutoLoad fantastico – elegant and effective&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
As expected (read: “hoped”) it still works. &lt;/div&gt;
&lt;h2&gt;




Conclusion&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Model binding to persistence entities (auto loading as I seem
to be calling it) can help to make your controllers look a lot cleaner and be a
lot more DRY – by not repeating calls to a repository – and even removing
references to repositories altogether. If you have attribute-based web
transactions for your ORM tool’s sessions and transactions, then those
controllers really can go on a diet.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
But let’s be aware that in this example I tied my model
binder to the entity framework DbContext. What would be awesome is to make use
of MVC 3’s DependencyResolver and the repository pattern to make this binder
ORM-agnostic. So whatever repository the DependecyResolver registers, it is
that which get’s queried.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
What about nested entities, many-to-many relationships in
scenarios where we create and update records? The attribute and the model
binder still have a lot to incorporate before I’m happy.&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
I will be augmenting and improving the behaviour of
the &lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;[&lt;span style="color: #2b91af;"&gt;AutoLoad&lt;/span&gt;] &lt;/span&gt;in coming posts.&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Also, did you notice how cool the MvcScaffolding was in this
scenario and how it plays nicely with NuGet? Keep up the good work Steven
Sanderson and the rest of the Web Platform Team. &lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5858898768007132818-2053018642410464975?l=ntcoding.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ntcoding.blogspot.com/feeds/2053018642410464975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ntcoding.blogspot.com/2011/01/elegant-opt-in-model-binding-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2053018642410464975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5858898768007132818/posts/default/2053018642410464975'/><link rel='alternate' type='text/html' href='http://ntcoding.blogspot.com/2011/01/elegant-opt-in-model-binding-to.html' title='Elegant, Opt-in Model Binding to Persistence Entities in ASP.NET MVC'/><author><name>NTCoding</name><uri>http://www.blogger.com/profile/04872151238552775698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_QZlBWCg5wmg/TTruJceReGI/AAAAAAAAADA/BYzVMLZZn6o/s72-c/HealthFoods+-+DetailsView.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5858898768007132818.post-6608127009600204442</id><published>2011-01-16T14:26:00.000-08:00</published><updated>2011-01-16T14:41:04.719-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BDD'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Total BDD in ASP.NET MVC</title><content type='html'>&lt;h2&gt;


Introduction&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
In previous blog posts (BDD category) I’ve shown a liking
for SpecFlow for implementing my BDD-style specs (tests). &lt;a href="http://ntcoding.blogspot.com/search/label/BDD?updated-max=2010-09-11T09%3A54%3A00-07%3A00&amp;amp;max-results=20"&gt;One
of those posts&lt;/a&gt; showed me using SpecFlow for specs closer in nature to unit
tests rather than acceptance tests – and this caused me avoidable problems
afterwards.&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
&amp;nbsp;Unit tests are there to be read easily – you follow the
logic contained within a single method. The way SpecFlow works with its
reusable step definitions is not conducive to this – and when my specs failed
and I tried to work out what was wrong I found myself navigating massive step
definition files to follow the logic of a small spec.&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
At this point I had the scars to prove SpecFlow just isn’t
useful at the unit test level in most cases (SpecFlow source code shows great
examples to the contrary). &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
But what about BDD – what about English-language used to
describe my business rules that need to be checked and enforced in the domain
itself? Well…&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
Along came this &lt;a href="http://blog.sharparchitecture.net/post/Some-thoughts-on-moving-to-MSpec.aspx"&gt;blog
post&lt;/a&gt; by the &lt;a href="http://sharparchitecture.net/"&gt;S#arp architecture&lt;/a&gt;
dudes (very smart boys) whose ASP.NET MVC stack I have been enjoying learning
from recently. They are using &lt;a href="https://github.com/agross/machine.specifications"&gt;MSpec&lt;/a&gt; for their
unit tests because they want the benefits of BDD - even though their clients
are developers like myself. When reading that blog post the light bulbs were
going off in my head like a 90’s game show.&lt;/div&gt;
&lt;h2&gt;


Specs.Integration&lt;/h2&gt;
&lt;div class="MsoNormal"&gt;
Right now I’m going to walk you through my methodology –
starting with my higher-level user story spec using SpecFlow and following that
up with my more granular, unit test-style specs (context specifications) with
MSpec (derived from the higher-level user story spec).&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For this demonstration I started with the following:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt; &lt;/span&gt;&lt;/span&gt;New MVC 3 app called TheSandwichGoRound&amp;nbsp; - using the almighty
Razor view engine&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;New class library called Specs.Integration&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72pt; text-indent: -18pt;"&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;o&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;NuGet SpecFlow&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72pt; text-indent: -18pt;"&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;o&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;NuGet NUnit&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="margin-left: 72pt; text-indent: -18pt;"&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;o&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;NuGet MvcContrib.Watin&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;New class library called Specs&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="MsoListParagraphCxSpLast" style="margin-left: 72pt; text-indent: -18pt;"&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;o&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;NuGet Machine.Specifications&lt;/div&gt;
&lt;div class="MsoListParagraphCxSpLast" style="margin-left: 72pt; text-indent: -18pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
In this silly example here is a feature file I dreamed up
and added to a folder called “features” in the Specs.Integration project:&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;Feature&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;:
Creating Sandwiches&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;i&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In
order to satisfy my appetite&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;i&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As
a hungry boy&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;i&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I
need to be able to create sandwiches&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;Scenario&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;:
Success&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Given &lt;/span&gt;I have navigated to the Create Sandwich page&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;And &lt;/span&gt;I have typed in a unique name&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;When &lt;/span&gt;I click Create&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Then &lt;/span&gt;I should be viewing the details of my new
sandwich&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
And here is the step definition, that when
successful confirms my product has the required behaviours (watch the tests
return “not implemented” and SpecFlow will give you the required definitions in
the output window) (my step file lives in a folder called “steps” in the
Specs.Integration project):&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="color: blue; font-family: Consolas; font-size: 9.5pt;"&gt;namespace&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;
Specs.Integration.steps&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="color: #2b91af;"&gt;Binding&lt;/span&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;SandwichSteps&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;const&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; Baseurl = &lt;span style="color: #a31515;"&gt;@"http://localhost/TheSandwichGoRound"&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IE&lt;/span&gt;
_browser;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;
SandwichName;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IE&lt;/span&gt;
Browswer&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt;
_browser ?? (_browser = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IE&lt;/span&gt;()); }&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="color: #2b91af;"&gt;Given&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;@"I
have navigated to the Create Sandwich page"&lt;/span&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt;
GivenIHaveNavigatedToTheCreateSandwichPage()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Browswer.GoTo(Baseurl + &lt;span style="color: #a31515;"&gt;@"/Sandwiches/Create"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="color: #2b91af;"&gt;Given&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;@"I
have typed in a unique name"&lt;/span&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt;
GivenIHaveTypedInAUniqueName()&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
SandwichName = &lt;span style="color: #a31515;"&gt;"Olivitza"&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Browswer.TextField(&lt;span style="color: #a31515;"&gt;"Name"&lt;/span&gt;).TypeText(SandwichName);&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&
