<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>kevin Mocha - Design</title>
    <link>http://blog.ilovedoudou.com/</link>
    <description>Bookmarks collected from web.</description>
    <language>en-us</language>
    <copyright>Kevin Mocha</copyright>
    <lastBuildDate>Mon, 24 May 2010 15:32:43 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>lulustock@gmail.com</managingEditor>
    <webMaster>lulustock@gmail.com</webMaster>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=6f1e7693-0d30-4acc-a2d1-1a243e5005c0</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,6f1e7693-0d30-4acc-a2d1-1a243e5005c0.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,6f1e7693-0d30-4acc-a2d1-1a243e5005c0.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6f1e7693-0d30-4acc-a2d1-1a243e5005c0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://randypatterson.com/index.php/2007/09/26/how-to-design-a-fluent-interface/" href="http://randypatterson.com/index.php/2007/09/26/how-to-design-a-fluent-interface/">http://randypatterson.com/index.php/2007/09/26/how-to-design-a-fluent-interface/</a>
        </p>
        <p>
          <a title="http://en.wikipedia.org/wiki/Fluent_interface#C.23" href="http://en.wikipedia.org/wiki/Fluent_interface#C.23">http://en.wikipedia.org/wiki/Fluent_interface#C.23</a>
        </p>
        <pre class="csharpcode">
          <span class="preproc">#region</span> Fluent Example <span class="kwrd">public</span><span class="kwrd">interface</span> IConfigurationFluent
{ IConfigurationFluent SetColor(<span class="kwrd">string</span> color); IConfigurationFluent
SetHeight(<span class="kwrd">int</span> height); IConfigurationFluent SetLength(<span class="kwrd">int</span> length);
IConfigurationFluent SetDepth(<span class="kwrd">int</span> depth); } <span class="kwrd">public</span><span class="kwrd">class</span> ConfigurationFluent
: IConfigurationFluent { <span class="kwrd">string</span> color; <span class="kwrd">int</span> height; <span class="kwrd">int</span> length; <span class="kwrd">int</span> depth; <span class="kwrd">public</span> IConfigurationFluent
SetColor(<span class="kwrd">string</span> color) { <span class="kwrd">this</span>.color
= color; <span class="kwrd">return</span><span class="kwrd">this</span>; } <span class="kwrd">public</span> IConfigurationFluent
SetHeight(<span class="kwrd">int</span> height) { <span class="kwrd">this</span>.height
= height; <span class="kwrd">return</span><span class="kwrd">this</span>; } <span class="kwrd">public</span> IConfigurationFluent
SetLength(<span class="kwrd">int</span> length) { <span class="kwrd">this</span>.length
= length; <span class="kwrd">return</span><span class="kwrd">this</span>; } <span class="kwrd">public</span> IConfigurationFluent
SetDepth(<span class="kwrd">int</span> depth) { <span class="kwrd">this</span>.depth
= depth; <span class="kwrd">return</span><span class="kwrd">this</span>; } } <span class="preproc">#endregion</span><span class="kwrd">public</span><span class="kwrd">class</span> ExampleProgram
{ <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">void</span> Main(<span class="kwrd">string</span>[]
args) { <span class="rem">//Standard Example</span> IConfiguration config = <span class="kwrd">new</span> Configuration
{ Color = <span class="str">"blue"</span>, Height = 1, Length = 2, Depth = 3 }; <span class="rem">//Fluent
Example</span> IConfigurationFluent fluentConfig = <span class="kwrd">new</span> ConfigurationFluent().SetColor(<span class="str">"blue"</span>)
.SetHeight(1) .SetLength(2) .SetDepth(3); } } </pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=6f1e7693-0d30-4acc-a2d1-1a243e5005c0" />
      </body>
      <title>How to design a Fluent Interface</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,6f1e7693-0d30-4acc-a2d1-1a243e5005c0.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,6f1e7693-0d30-4acc-a2d1-1a243e5005c0.aspx</link>
      <pubDate>Mon, 24 May 2010 15:32:43 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://randypatterson.com/index.php/2007/09/26/how-to-design-a-fluent-interface/" href="http://randypatterson.com/index.php/2007/09/26/how-to-design-a-fluent-interface/"&gt;http://randypatterson.com/index.php/2007/09/26/how-to-design-a-fluent-interface/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://en.wikipedia.org/wiki/Fluent_interface#C.23" href="http://en.wikipedia.org/wiki/Fluent_interface#C.23"&gt;http://en.wikipedia.org/wiki/Fluent_interface#C.23&lt;/a&gt;
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="preproc"&gt;#region&lt;/span&gt; Fluent Example &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IConfigurationFluent
{ IConfigurationFluent SetColor(&lt;span class="kwrd"&gt;string&lt;/span&gt; color); IConfigurationFluent
SetHeight(&lt;span class="kwrd"&gt;int&lt;/span&gt; height); IConfigurationFluent SetLength(&lt;span class="kwrd"&gt;int&lt;/span&gt; length);
IConfigurationFluent SetDepth(&lt;span class="kwrd"&gt;int&lt;/span&gt; depth); } &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ConfigurationFluent
: IConfigurationFluent { &lt;span class="kwrd"&gt;string&lt;/span&gt; color; &lt;span class="kwrd"&gt;int&lt;/span&gt; height; &lt;span class="kwrd"&gt;int&lt;/span&gt; length; &lt;span class="kwrd"&gt;int&lt;/span&gt; depth; &lt;span class="kwrd"&gt;public&lt;/span&gt; IConfigurationFluent
SetColor(&lt;span class="kwrd"&gt;string&lt;/span&gt; color) { &lt;span class="kwrd"&gt;this&lt;/span&gt;.color
= color; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;; } &lt;span class="kwrd"&gt;public&lt;/span&gt; IConfigurationFluent
SetHeight(&lt;span class="kwrd"&gt;int&lt;/span&gt; height) { &lt;span class="kwrd"&gt;this&lt;/span&gt;.height
= height; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;; } &lt;span class="kwrd"&gt;public&lt;/span&gt; IConfigurationFluent
SetLength(&lt;span class="kwrd"&gt;int&lt;/span&gt; length) { &lt;span class="kwrd"&gt;this&lt;/span&gt;.length
= length; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;; } &lt;span class="kwrd"&gt;public&lt;/span&gt; IConfigurationFluent
SetDepth(&lt;span class="kwrd"&gt;int&lt;/span&gt; depth) { &lt;span class="kwrd"&gt;this&lt;/span&gt;.depth
= depth; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;; } } &lt;span class="preproc"&gt;#endregion&lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ExampleProgram
{ &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[]
args) { &lt;span class="rem"&gt;//Standard Example&lt;/span&gt; IConfiguration config = &lt;span class="kwrd"&gt;new&lt;/span&gt; Configuration
{ Color = &lt;span class="str"&gt;"blue"&lt;/span&gt;, Height = 1, Length = 2, Depth = 3 }; &lt;span class="rem"&gt;//Fluent
Example&lt;/span&gt; IConfigurationFluent fluentConfig = &lt;span class="kwrd"&gt;new&lt;/span&gt; ConfigurationFluent().SetColor(&lt;span class="str"&gt;"blue"&lt;/span&gt;)
.SetHeight(1) .SetLength(2) .SetDepth(3); } } &lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=6f1e7693-0d30-4acc-a2d1-1a243e5005c0" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,6f1e7693-0d30-4acc-a2d1-1a243e5005c0.aspx</comments>
      <category>Design;DotNet / CSharp</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=d317cd1e-4eb5-439f-8b56-ac4e3395165b</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,d317cd1e-4eb5-439f-8b56-ac4e3395165b.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,d317cd1e-4eb5-439f-8b56-ac4e3395165b.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d317cd1e-4eb5-439f-8b56-ac4e3395165b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference" href="http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference">
            <font size="2">http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference</font>
          </a>
          <br />
          <br />
        </p>
        <h4>Model-View-Presenter
</h4>
        <p>
          <font size="2">In <strong>MVP</strong>, the Presenter contains the the UI business
logic for the View. All invocations from the View delegate directly to Presenter.
The Presenter is also decoupled directly from the View and talks to it through an
interface. This is to allow mocking of the View in a unit test. One common attribute
of MVP is that there has to be a lot of two-way dispatching. For example, when someone
clicks the "Save" button, the event handler delegates to the Presenter's "OnSave"
method. Once the save is completed, the Presenter will then call back the View through
it's interface so that the View can display that the save has completed. </font>
        </p>
        <p>
          <font size="2">MVP tends to be a very natural pattern for achieving separated presentation
in Web Forms. The reason is because the View is always created first by the ASP.NET
runtime. You can </font>
          <a href="http://www.codeplex.com/websf/Wiki/View.aspx?title=MVPDocumentation&amp;referringTitle=bundles">
            <font size="2">find
out more about both variants</font>
          </a>
          <font size="2">.</font>
        </p>
        <h5>Two primary variations
</h5>
        <p>
          <font size="2">
            <strong>Passive View:</strong> The View is as as dumb as possible and
contains almost zero logic. The Presenter is a middle man that talks to the View and
the Model. The View and Model are completely shielded from one another. The Model
may raise events, but the Presenter subscribes to them for updating the View. In Passive
View there is no direct data binding, instead the View exposes setter properties which
the Presenter uses to set the data. All state is managed in the Presenter and not
the View.</font>
        </p>
        <ul>
          <li>
            <font size="2">Pro: maximum testability surface; clean separation of the View and
Model </font>
          </li>
          <li>
            <font size="2">Con: more work (for example all the setter properties) as you are doing
all the data binding yourself. </font>
          </li>
        </ul>
        <p>
          <font size="2">
            <strong>Supervising Controller:</strong> The Presenter handles user
gestures. <font color="#0080ff">The View binds to the Model directly through data
binding</font>. In this case it's the Presenter's job to pass off the Model to the
View so that it can bind to it. The Presenter will also contain logic for gestures
like pressing a button, navigation, etc. </font>
        </p>
        <ul>
          <li>
            <font size="2">Pro: by leveraging databinding the amount of code is reduced. </font>
          </li>
          <li>
            <font size="2">Con: there's less testable surface (because of data binding), and there's
less encapsulation in the View since it talks directly to the Model. </font>
          </li>
        </ul>
        <h4>Model-View-Controller
</h4>
        <p>
          <font size="2">In the <strong>MVC</strong>, <font color="#0080ff">the Controller is
responsible for determining which View is displayed in response to any action including
when the application loads. This differs from MVP where actions route through the
View to the Presenter.</font> In MVC, every action in the View correlates with a call
to a Controller along with an action. In the web each action involves a call to a
URL on the other side of which there is a Controller who responds. Once that Controller
has completed it's processing, it will return the correct View. The sequence continues
in that manner throughout the life of the application:</font>
        </p>
        <pre>
          <font size="2"> Action in the View -&gt; Call to Controller -&gt; Controller
Logic -&gt; Controller returns the View. </font>
        </pre>
        <p>
          <font size="2">One other big difference about MVC is that the <font color="#0080ff">View
does not directly bind to the Model. The view simply renders, and is completely stateless</font>.
In implementations of MVC the View usually will not have any logic in the code behind.
This is contrary to MVP where it is absolutely necessary as if the View does not delegate
to the Presenter, it will never get called. (lulu: That means the view has to have
the delegate code in MVP)<br /></font>
        </p>
        <p>
          <font size="2">There is a </font>
          <a href="http://msdn.microsoft.com/en-us/library/cc707885.aspx">
            <font size="2">MSDN
article about the Presentation Model</font>
          </a>
          <font size="2"> and a section in the </font>
          <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx">
            <font size="2">Composite
Application Guidance for WPF</font>
          </a>
          <font size="2"> (former Prism) about </font>
          <a href="http://msdn.microsoft.com/en-us/library/cc707862.aspx">
            <font size="2">Separated
Presentation Patterns</font>
          </a>
        </p>
        <h4>
          <font size="2">Presentation Model</font>
        </h4>
        <p>
          <font size="2">One other pattern to look at is the <strong>Presentation Model</strong> pattern.
In this pattern there is no Presenter. Instead the View binds directly to a Presentation
Model. The Presentation Model is a Model crafted specifically for the View. This means
this Model can expose properties that one would never put on a domain model as it
would be a violation of separation-of-concerns. In this case, the Presentation Model
binds to the domain model, and may subscribe to event coming from that Model. The
View then subscribes to events coming from the Presentation Model and updates itself
accordingly. The Presentation Model can expose commands which the view uses for invoking
actions. The advantage of this approach is that you can essentially remove the code-behind
altogether as the PM complete encapsulates all of the behaviour for the view. This
pattern is a very strong candidate for use in WPF applications and is also called </font>
          <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx">
            <font size="2">Model-View-ViewModel</font>
          </a>
          <font size="2">.</font>
        </p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <font size="3">
            <strong>More links about this:</strong>
          </font>
        </p>
        <p>
  
</p>
        <p>
          <a title="http://www.aspiringcraftsman.com/2007/08/interactive-application-architecture/" href="http://www.aspiringcraftsman.com/2007/08/interactive-application-architecture/">
            <font size="2">http://www.aspiringcraftsman.com/2007/08/interactive-application-architecture/</font>
          </a>
        </p>
        <p>
(lulu: traditional MVC)
</p>
        <p>
          <img alt="http://www.aspiringcraftsman.com/wordpress/wp-content/uploads/2007/08/MVC1.png" src="http://www.aspiringcraftsman.com/wordpress/wp-content/uploads/2007/08/MVC1.png" width="324" height="194" />
        </p>
        <p>
The View’s responsibility can be seen as primarily dealing with output while the Controller’s
responsibility can be seen as primarily dealing with input. It is the shared responsibility
of both the View and the Controller to interact with the Model. The Controller interacts
with the Model as the result of responding to user input, while the View interacts
with the Model as the result of updates to itself. Both may access and modify data
within the Model as needed. 
</p>
        <p>
As data is entered by the user, the Controller intercepts the user’s input and responds
appropriately. Some user actions will result in interaction with the Model, such as
changing data or invoking methods, while other user actions may result in visual changes
to the View, such as the collapsing of menus, the highlighting of scrollbars, etc.<br /></p>
        <h6>MVC Misconceptions
</h6>
        <p>
One common misconception about the relationship between the MVC components is that
the purpose of the Controller is to separate the View from the Model. While the MVC
pattern does decouple the application’s domain layer from presentation concerns, this
is achieved through the Observer Pattern, not through the Controller. The Controller
was conceived as a mediator between the end user and the application, not between
the View and the Model. 
</p>
        <p>
 
</p>
        <p>
          <font size="2">
          </font> 
</p>
        <p>
          <br />
          <a title="http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx" href="http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx">http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx</a>
        </p>
        <p>
(lulu: IN current MVC, the view will not get data from Model directly)
</p>
        <p>
          <font size="2">The two patterns are similar in that they both are concerned with separating
concerns and they both contain Models and Views. Many consider the MVP pattern to
simply be a variant of the MVC pattern. The key difference is suggested by the problem
that the MVP pattern sought to solve with the MVP pattern. Who handles the user input?</font>
        </p>
        <p>
          <font size="2">With MVC, it’s always the controller’s responsibility to handle mouse
and keyboard events. With MVP, GUI components themselves initially handle the user’s
input, but delegate to the interpretation of that input to the presenter. This has
often been called “</font>
          <a href="http://aviadezra.blogspot.com/2007/07/twisting-mvp-triad-say-hello-to-mvpc.html">
            <font size="2">Twisting
the Triad</font>
          </a>
          <font size="2">”, which refers to rotating the three elements
of the MVC triangle and replacing the “C” with “P” in order to get <em>MVP</em>.</font>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=d317cd1e-4eb5-439f-8b56-ac4e3395165b" />
      </body>
      <title>MVC MVP</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,d317cd1e-4eb5-439f-8b56-ac4e3395165b.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,d317cd1e-4eb5-439f-8b56-ac4e3395165b.aspx</link>
      <pubDate>Wed, 07 Apr 2010 21:00:38 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference" href="http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference"&gt;&lt;font size="2"&gt;http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference&lt;/font&gt;&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;h4&gt;Model-View-Presenter
&lt;/h4&gt;
&lt;p&gt;
&lt;font size="2"&gt;In &lt;strong&gt;MVP&lt;/strong&gt;, the Presenter contains the the UI business
logic for the View. All invocations from the View delegate directly to Presenter.
The Presenter is also decoupled directly from the View and talks to it through an
interface. This is to allow mocking of the View in a unit test. One common attribute
of MVP is that there has to be a lot of two-way dispatching. For example, when someone
clicks the "Save" button, the event handler delegates to the Presenter's "OnSave"
method. Once the save is completed, the Presenter will then call back the View through
it's interface so that the View can display that the save has completed. &lt;/font&gt; 
&lt;p&gt;
&lt;font size="2"&gt;MVP tends to be a very natural pattern for achieving separated presentation
in Web Forms. The reason is because the View is always created first by the ASP.NET
runtime. You can &lt;/font&gt;&lt;a href="http://www.codeplex.com/websf/Wiki/View.aspx?title=MVPDocumentation&amp;amp;referringTitle=bundles"&gt;&lt;font size="2"&gt;find
out more about both variants&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt; 
&lt;h5&gt;Two primary variations
&lt;/h5&gt;
&lt;p&gt;
&lt;font size="2"&gt;&lt;strong&gt;Passive View:&lt;/strong&gt; The View is as as dumb as possible and
contains almost zero logic. The Presenter is a middle man that talks to the View and
the Model. The View and Model are completely shielded from one another. The Model
may raise events, but the Presenter subscribes to them for updating the View. In Passive
View there is no direct data binding, instead the View exposes setter properties which
the Presenter uses to set the data. All state is managed in the Presenter and not
the View.&lt;/font&gt; 
&lt;ul&gt;
&lt;li&gt;
&lt;font size="2"&gt;Pro: maximum testability surface; clean separation of the View and
Model &lt;/font&gt; 
&lt;li&gt;
&lt;font size="2"&gt;Con: more work (for example all the setter properties) as you are doing
all the data binding yourself. &lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;font size="2"&gt;&lt;strong&gt;Supervising Controller:&lt;/strong&gt; The Presenter handles user
gestures. &lt;font color="#0080ff"&gt;The View binds to the Model directly through data
binding&lt;/font&gt;. In this case it's the Presenter's job to pass off the Model to the
View so that it can bind to it. The Presenter will also contain logic for gestures
like pressing a button, navigation, etc. &lt;/font&gt; 
&lt;ul&gt;
&lt;li&gt;
&lt;font size="2"&gt;Pro: by leveraging databinding the amount of code is reduced. &lt;/font&gt; 
&lt;li&gt;
&lt;font size="2"&gt;Con: there's less testable surface (because of data binding), and there's
less encapsulation in the View since it talks directly to the Model. &lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Model-View-Controller
&lt;/h4&gt;
&lt;p&gt;
&lt;font size="2"&gt;In the &lt;strong&gt;MVC&lt;/strong&gt;, &lt;font color="#0080ff"&gt;the Controller is
responsible for determining which View is displayed in response to any action including
when the application loads. This differs from MVP where actions route through the
View to the Presenter.&lt;/font&gt; In MVC, every action in the View correlates with a call
to a Controller along with an action. In the web each action involves a call to a
URL on the other side of which there is a Controller who responds. Once that Controller
has completed it's processing, it will return the correct View. The sequence continues
in that manner throughout the life of the application:&lt;/font&gt;&lt;pre&gt;&lt;font size="2"&gt; Action
in the View -&amp;gt; Call to Controller -&amp;gt; Controller Logic -&amp;gt; Controller returns
the View. &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font size="2"&gt;One other big difference about MVC is that the &lt;font color="#0080ff"&gt;View
does not directly bind to the Model. The view simply renders, and is completely stateless&lt;/font&gt;.
In implementations of MVC the View usually will not have any logic in the code behind.
This is contrary to MVP where it is absolutely necessary as if the View does not delegate
to the Presenter, it will never get called. (lulu: That means the view has to have
the delegate code in MVP)&lt;br&gt;
&lt;/font&gt; 
&lt;p&gt;
&lt;font size="2"&gt;There is a &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc707885.aspx"&gt;&lt;font size="2"&gt;MSDN
article about the Presentation Model&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; and a section in the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx"&gt;&lt;font size="2"&gt;Composite
Application Guidance for WPF&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; (former Prism) about &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc707862.aspx"&gt;&lt;font size="2"&gt;Separated
Presentation Patterns&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;h4&gt;&lt;font size="2"&gt;Presentation Model&lt;/font&gt;
&lt;/h4&gt;
&lt;p&gt;
&lt;font size="2"&gt;One other pattern to look at is the &lt;strong&gt;Presentation Model&lt;/strong&gt; pattern.
In this pattern there is no Presenter. Instead the View binds directly to a Presentation
Model. The Presentation Model is a Model crafted specifically for the View. This means
this Model can expose properties that one would never put on a domain model as it
would be a violation of separation-of-concerns. In this case, the Presentation Model
binds to the domain model, and may subscribe to event coming from that Model. The
View then subscribes to events coming from the Presentation Model and updates itself
accordingly. The Presentation Model can expose commands which the view uses for invoking
actions. The advantage of this approach is that you can essentially remove the code-behind
altogether as the PM complete encapsulates all of the behaviour for the view. This
pattern is a very strong candidate for use in WPF applications and is also called &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx"&gt;&lt;font size="2"&gt;Model-View-ViewModel&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;font size="3"&gt;&lt;strong&gt;More links about this:&lt;/strong&gt;&lt;/font&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a title="http://www.aspiringcraftsman.com/2007/08/interactive-application-architecture/" href="http://www.aspiringcraftsman.com/2007/08/interactive-application-architecture/"&gt;&lt;font size="2"&gt;http://www.aspiringcraftsman.com/2007/08/interactive-application-architecture/&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
(lulu: traditional MVC)
&lt;/p&gt;
&lt;p&gt;
&lt;img alt="http://www.aspiringcraftsman.com/wordpress/wp-content/uploads/2007/08/MVC1.png" src="http://www.aspiringcraftsman.com/wordpress/wp-content/uploads/2007/08/MVC1.png" width="324" height="194"&gt;
&lt;/p&gt;
&lt;p&gt;
The View’s responsibility can be seen as primarily dealing with output while the Controller’s
responsibility can be seen as primarily dealing with input. It is the shared responsibility
of both the View and the Controller to interact with the Model. The Controller interacts
with the Model as the result of responding to user input, while the View interacts
with the Model as the result of updates to itself. Both may access and modify data
within the Model as needed. 
&lt;p&gt;
As data is entered by the user, the Controller intercepts the user’s input and responds
appropriately. Some user actions will result in interaction with the Model, such as
changing data or invoking methods, while other user actions may result in visual changes
to the View, such as the collapsing of menus, the highlighting of scrollbars, etc.&lt;br&gt;
&lt;h6&gt;MVC Misconceptions
&lt;/h6&gt;
&lt;p&gt;
One common misconception about the relationship between the MVC components is that
the purpose of the Controller is to separate the View from the Model. While the MVC
pattern does decouple the application’s domain layer from presentation concerns, this
is achieved through the Observer Pattern, not through the Controller. The Controller
was conceived as a mediator between the end user and the application, not between
the View and the Model. 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;a title="http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx" href="http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx"&gt;http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
(lulu: IN current MVC, the view will not get data from Model directly)
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2"&gt;The two patterns are similar in that they both are concerned with separating
concerns and they both contain Models and Views. Many consider the MVP pattern to
simply be a variant of the MVC pattern. The key difference is suggested by the problem
that the MVP pattern sought to solve with the MVP pattern. Who handles the user input?&lt;/font&gt; 
&lt;p&gt;
&lt;font size="2"&gt;With MVC, it’s always the controller’s responsibility to handle mouse
and keyboard events. With MVP, GUI components themselves initially handle the user’s
input, but delegate to the interpretation of that input to the presenter. This has
often been called “&lt;/font&gt;&lt;a href="http://aviadezra.blogspot.com/2007/07/twisting-mvp-triad-say-hello-to-mvpc.html"&gt;&lt;font size="2"&gt;Twisting
the Triad&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;”, which refers to rotating the three elements
of the MVC triangle and replacing the “C” with “P” in order to get &lt;em&gt;MVP&lt;/em&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=d317cd1e-4eb5-439f-8b56-ac4e3395165b" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,d317cd1e-4eb5-439f-8b56-ac4e3395165b.aspx</comments>
      <category>Design</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=fd5378e3-196c-4440-adcb-45d3e8718ebf</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,fd5378e3-196c-4440-adcb-45d3e8718ebf.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,fd5378e3-196c-4440-adcb-45d3e8718ebf.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fd5378e3-196c-4440-adcb-45d3e8718ebf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font size="2">The whole point of bringing in an IoC container is that you can use
it to eliminate hard-coded<br />
dependencies between components.</font>
        </p>
        <p>
          <font size="2">
          </font>  
</p>
        <p>
          <font size="2">
            <strong>Using an IoC Container<br /></strong>
          </font>
          <br />
          <font size="2">An IoC container is a standard software component that supports and
simplifies IoC. It lets<br />
you register a set of components (i.e., abstract types and your currently chosen concrete<br />
implementations), and then handles the business of instantiating them. You can configure<br />
and register components either with an XML file or with C# code (or both).<br /><br />
At runtime, you can call a method similar to container.Resolve(Type type), where<br />
type could be a particular interface or abstract type or a particular concrete type,
and the<br />
container will return an object satisfying that type definition, according to whatever
concrete<br />
type is configured. It sounds trivial, but a good IoC container adds three extra clever
features:<br /><br /><strong>Dependency chain resolution</strong>: If you request a component that itself
has dependencies<br />
(e.g., constructor parameters), the container will satisfy those dependencies recursively,<br />
so you can have component A, which depends on B, which depends on C, and so on. In<br />
other words, you can forget about the wiring on your component circuit board—just<br />
think about the components, because wiring happens magically.<br /><br /><strong>Object lifetime management:</strong> If you request component A more than
once, should you get<br />
the same actual instance of A each time, or a fresh new instance each time? The container<br />
will usually let you configure the “lifestyle” of a component, allowing you to select
from<br />
predefined options including <strong>singleton (the same instance each time), transient
(a new<br />
instance each time), instance-per-thread, instance-from-a-pool</strong>, and so on.<br /><br /><strong>Explicit constructor parameter values configuration:</strong> For example,
if the constructor for<br />
MembersRepository demands a string called connectionString, (as ours did earlier),
you<br />
can configure a value for it in your XML config file. It’s a crude but simple configuration<br />
system that removes any need for your code to pass around connection strings, SMTP<br />
server addresses, and so on.<br />
So, in the preceding example, you’d configure MembersRepository as the active concrete<br />
implementation for IMembersRepository. Then, when some code calls container.Resolve<br />
(typeof(AdminController)), the container will figure out that to satisfy AdminController’s<br />
constructor parameters it first needs an object implementing IMembersRepository. It
will<br />
get one according to whatever concrete implementation you’ve configured (in this case,<br />
MembersRepository), supplying the connectionString you’ve configured. It will then
use that to<br />
instantiate and return an AdminController.</font>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=fd5378e3-196c-4440-adcb-45d3e8718ebf" />
      </body>
      <title>IoC Container</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,fd5378e3-196c-4440-adcb-45d3e8718ebf.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,fd5378e3-196c-4440-adcb-45d3e8718ebf.aspx</link>
      <pubDate>Sun, 04 Apr 2010 21:34:04 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font size="2"&gt;The whole point of bringing in an IoC container is that you can use
it to eliminate hard-coded&lt;br&gt;
dependencies between components.&lt;/font&gt; 
&lt;p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&amp;nbsp; 
&lt;p&gt;
&lt;font size="2"&gt;&lt;strong&gt;Using an IoC Container&lt;br&gt;
&lt;/strong&gt;&lt;/font&gt;
&lt;br&gt;
&lt;font size="2"&gt;An IoC container is a standard software component that supports and
simplifies IoC. It lets&lt;br&gt;
you register a set of components (i.e., abstract types and your currently chosen concrete&lt;br&gt;
implementations), and then handles the business of instantiating them. You can configure&lt;br&gt;
and register components either with an XML file or with C# code (or both).&lt;br&gt;
&lt;br&gt;
At runtime, you can call a method similar to container.Resolve(Type type), where&lt;br&gt;
type could be a particular interface or abstract type or a particular concrete type,
and the&lt;br&gt;
container will return an object satisfying that type definition, according to whatever
concrete&lt;br&gt;
type is configured. It sounds trivial, but a good IoC container adds three extra clever
features:&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;Dependency chain resolution&lt;/strong&gt;: If you request a component that itself
has dependencies&lt;br&gt;
(e.g., constructor parameters), the container will satisfy those dependencies recursively,&lt;br&gt;
so you can have component A, which depends on B, which depends on C, and so on. In&lt;br&gt;
other words, you can forget about the wiring on your component circuit board—just&lt;br&gt;
think about the components, because wiring happens magically.&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;Object lifetime management:&lt;/strong&gt; If you request component A more than
once, should you get&lt;br&gt;
the same actual instance of A each time, or a fresh new instance each time? The container&lt;br&gt;
will usually let you configure the “lifestyle” of a component, allowing you to select
from&lt;br&gt;
predefined options including &lt;strong&gt;singleton (the same instance each time), transient
(a new&lt;br&gt;
instance each time), instance-per-thread, instance-from-a-pool&lt;/strong&gt;, and so on.&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;Explicit constructor parameter values configuration:&lt;/strong&gt; For example,
if the constructor for&lt;br&gt;
MembersRepository demands a string called connectionString, (as ours did earlier),
you&lt;br&gt;
can configure a value for it in your XML config file. It’s a crude but simple configuration&lt;br&gt;
system that removes any need for your code to pass around connection strings, SMTP&lt;br&gt;
server addresses, and so on.&lt;br&gt;
So, in the preceding example, you’d configure MembersRepository as the active concrete&lt;br&gt;
implementation for IMembersRepository. Then, when some code calls container.Resolve&lt;br&gt;
(typeof(AdminController)), the container will figure out that to satisfy AdminController’s&lt;br&gt;
constructor parameters it first needs an object implementing IMembersRepository. It
will&lt;br&gt;
get one according to whatever concrete implementation you’ve configured (in this case,&lt;br&gt;
MembersRepository), supplying the connectionString you’ve configured. It will then
use that to&lt;br&gt;
instantiate and return an AdminController.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=fd5378e3-196c-4440-adcb-45d3e8718ebf" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,fd5378e3-196c-4440-adcb-45d3e8718ebf.aspx</comments>
      <category>Design</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font size="2">Model-view-presenter (MVP) is a recent variation on MVC that’s designed
to fit more easily<br />
with stateful GUI platforms such as Windows Forms or ASP.NET WebForms. You don’t need
to<br />
know about MVP when you’re using ASP.NET MVC, but it’s worth explaining what it is
so you<br />
can avoid confusion.<br /><br />
In this twist, the presenter has the same responsibilities as MVC’s controller, plus
it also<br />
takes a more hands-on relationship to the stateful view, <strong>directly editing
the values displayed<br /></strong>in its UI widgets according to user input <strong>(instead of letting the
view render itself from a template</strong>).<br />
There are two main flavors:<br /><br />
• Passive view, in which the view contains no logic, and merely has its UI widgets
manipulated<br />
by the presenter.<br /><br />
• Supervising controller, in which the view may be responsible for certain presentation<br />
logic, such as data binding, having been given a reference to some data source in
the<br />
model.<br /><br />
The difference between the two flavors is quite subjective and simply relates to how<br />
intelligent the view is allowed to be. Either way, the presenter is decoupled from
the GUI<br />
technology, so its logic can be followed easily and is suitable for automated testing</font>
        </p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/MVPvsMVC_F4EA/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/MVPvsMVC_F4EA/image_thumb.png" width="555" height="144" />
          </a>
        </p>
        <p>
          <font size="2">In this architecture, <strong>requests are routed to a controller class</strong>,
which processes user input<br />
and works with the domain model to handle the request. While the domain model holds<br />
domain logic (i.e., business objects and rules), controllers hold application logic,
such as navigation<br />
through a multistep process or technical details like authentication. When it’s time
to<br />
produce a visible UI for the user, <strong>the controller prepares the data to be
displayed</strong> (the presentation<br />
model, or ViewData in ASP.NET MVC, which for example might be a list of Product<br />
objects matching the requested category), selects a view, and leaves it to complete
the job.<br />
Since controller classes aren’t coupled to the UI technology (HTML), they are just
pure,<br />
testable application logic.</font>
          <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8" />
        </p>
      </body>
      <title>MVP vs MVC</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8.aspx</link>
      <pubDate>Sun, 04 Apr 2010 21:25:02 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font size="2"&gt;Model-view-presenter (MVP) is a recent variation on MVC that’s designed
to fit more easily&lt;br&gt;
with stateful GUI platforms such as Windows Forms or ASP.NET WebForms. You don’t need
to&lt;br&gt;
know about MVP when you’re using ASP.NET MVC, but it’s worth explaining what it is
so you&lt;br&gt;
can avoid confusion.&lt;br&gt;
&lt;br&gt;
In this twist, the presenter has the same responsibilities as MVC’s controller, plus
it also&lt;br&gt;
takes a more hands-on relationship to the stateful view, &lt;strong&gt;directly editing
the values displayed&lt;br&gt;
&lt;/strong&gt;in its UI widgets according to user input &lt;strong&gt;(instead of letting the
view render itself from a template&lt;/strong&gt;).&lt;br&gt;
There are two main flavors:&lt;br&gt;
&lt;br&gt;
• Passive view, in which the view contains no logic, and merely has its UI widgets
manipulated&lt;br&gt;
by the presenter.&lt;br&gt;
&lt;br&gt;
• Supervising controller, in which the view may be responsible for certain presentation&lt;br&gt;
logic, such as data binding, having been given a reference to some data source in
the&lt;br&gt;
model.&lt;br&gt;
&lt;br&gt;
The difference between the two flavors is quite subjective and simply relates to how&lt;br&gt;
intelligent the view is allowed to be. Either way, the presenter is decoupled from
the GUI&lt;br&gt;
technology, so its logic can be followed easily and is suitable for automated testing&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/MVPvsMVC_F4EA/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/MVPvsMVC_F4EA/image_thumb.png" width="555" height="144"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2"&gt;In this architecture, &lt;strong&gt;requests are routed to a controller class&lt;/strong&gt;,
which processes user input&lt;br&gt;
and works with the domain model to handle the request. While the domain model holds&lt;br&gt;
domain logic (i.e., business objects and rules), controllers hold application logic,
such as navigation&lt;br&gt;
through a multistep process or technical details like authentication. When it’s time
to&lt;br&gt;
produce a visible UI for the user, &lt;strong&gt;the controller prepares the data to be
displayed&lt;/strong&gt; (the presentation&lt;br&gt;
model, or ViewData in ASP.NET MVC, which for example might be a list of Product&lt;br&gt;
objects matching the requested category), selects a view, and leaves it to complete
the job.&lt;br&gt;
Since controller classes aren’t coupled to the UI technology (HTML), they are just
pure,&lt;br&gt;
testable application logic.&lt;/font&gt;&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,2d15b6d5-fc6b-4f22-afe0-0cf247ee51d8.aspx</comments>
      <category>Design;DotNet / ASP</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=7ff0a174-37a0-4056-b0cf-f9acc5595c54</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,7ff0a174-37a0-4056-b0cf-f9acc5595c54.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,7ff0a174-37a0-4056-b0cf-f9acc5595c54.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7ff0a174-37a0-4056-b0cf-f9acc5595c54</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
From book “Code leader using people tools and processes to build successful software”
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb.png" width="244" height="130" />
          </a>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb_1.png" width="126" height="244" />
          </a>  
</p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_6.png">
          <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb_2.png" width="381" height="287" />
        </a>
        <p>
 
</p>
        <p>
The trickiest part of the MVP design process is the View. It must represent all of
the interaction you will<br />
have with your user, using display-agnostic data types. The View, in essence, forms
your application’s<br />
contract with what is ‘‘on the glass’’ or visible to the user on their monitor. If
you are following a TDD<br />
development process, your View is likely to change and evolve during the course of
development, as<br />
requirements become more apparent. That should be easy to do if the proper separation
between View<br />
and Presenter is maintained, although a little refactoring along the way never hurt
anyone.
</p>
        <p>
In most languages, it is easiest to represent your View as an <strong>interface</strong>.
The concrete class directly responsible<br />
for display will implement the View interface. When you write your test code, you
can create another<br />
implementation of the View interface for testing purposes that has no actual user
interface elements<br />
associated with it.
</p>
        <p>
There is one major decision to make before starting work on your View interface. Will
your View expose<br />
events directly? Or will it call the Presenter to report user activity? This is often
debated when starting an<br />
MVP project, and there are adherents in both camps. To put the cards on the table
up front, I personally<br />
favor the former from an architectural perspective. It offers the cleanest separation
between View and<br />
Presenter because the View need know nothing at all about the Presenter. It only receives
data pushed to<br />
it and fires events that represent user actions. From a practical standpoint, however,
there are cons. Using<br />
events may be difficult in some implementation environments. Specifically in a web
application, it may<br />
be difficult for your server ‘‘page’’ to fire events, and just as difficult for your
Presenter to subscribe to<br />
them. It can be much easier in such an application to provide the View with direct
access to the Presenter<br />
so that user events can be reported directly as method calls. That potentially makes
it easier to deal with<br />
the issue of display-agnostic data types as well. If your View’s user interface element
(a button, say) fires<br />
events, and the View has to catch those events, translate from display data types
to neutral data types,<br />
and then fire a second event, the code could become quite cumbersome. 
</p>
        <p>
  
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_8.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb_3.png" width="297" height="216" />
          </a>
        </p>
        <p>
  
</p>
        <p>
Method 1 
</p>
        <p>
  
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="lnum"> 1: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">interface</span> ISurveyView</pre>
          <pre>
            <span class="lnum"> 2: </span>{</pre>
          <pre class="alt">
            <span class="lnum"> 3: </span> List&lt;<span class="kwrd">string</span>&gt;
Users { get; set; }</pre>
          <pre>
            <span class="lnum"> 4: </span>
            <span class="kwrd">bool</span> Question1 { get;
set; }</pre>
          <pre class="alt">
            <span class="lnum"> 5: </span>
            <span class="kwrd">string</span> Question2
{ get; set; }</pre>
          <pre>
            <span class="lnum"> 6: </span>}</pre>
          <pre class="alt">
            <span class="lnum"> 7: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">class</span> SurveyPresenter</pre>
          <pre>
            <span class="lnum"> 8: </span>{</pre>
          <pre class="alt">
            <span class="lnum"> 9: </span>
            <span class="kwrd">private</span>
            <span class="kwrd">static</span> Dictionary&lt;ISurveyView,
SurveyPresenter&gt; _presenters =</pre>
          <pre>
            <span class="lnum"> 10: </span>
            <span class="kwrd">new</span> Dictionary&lt;ISurveyView,
SurveyPresenter&gt;();</pre>
          <pre class="alt">
            <span class="lnum"> 11: </span>
            <span class="kwrd">private</span>
            <span class="kwrd">static</span>
            <span class="kwrd">readonly</span>
            <span class="kwrd">object</span> lockObject
= <span class="kwrd">new</span><span class="kwrd">object</span>();</pre>
          <pre>
            <span class="lnum"> 12: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">static</span> SurveyPresenter
Instance(ISurveyView view)</pre>
          <pre class="alt">
            <span class="lnum"> 13: </span> {</pre>
          <pre>
            <span class="lnum"> 14: </span>
            <span class="kwrd">lock</span> (lockObject)</pre>
          <pre class="alt">
            <span class="lnum"> 15: </span> {</pre>
          <pre>
            <span class="lnum"> 16: </span>
            <span class="kwrd">if</span> (!_presenters.ContainsKey(view))</pre>
          <pre class="alt">
            <span class="lnum"> 17: </span> _presenters[view] = <span class="kwrd">new</span> SurveyPresenter(view);</pre>
          <pre>
            <span class="lnum"> 18: </span>
            <span class="kwrd">return</span> _presenters[view];</pre>
          <pre class="alt">
            <span class="lnum"> 19: </span> }</pre>
          <pre>
            <span class="lnum"> 20: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 21: </span> ISurveyView _view;</pre>
          <pre>
            <span class="lnum"> 22: </span>
            <span class="kwrd">private</span> SurveyPresenter(ISurveyView
view)</pre>
          <pre class="alt">
            <span class="lnum"> 23: </span> {</pre>
          <pre>
            <span class="lnum"> 24: </span> _view = view;</pre>
          <pre class="alt">
            <span class="lnum"> 25: </span> }</pre>
          <pre>
            <span class="lnum"> 26: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">void</span> OnLoad()</pre>
          <pre class="alt">
            <span class="lnum"> 27: </span>{</pre>
          <pre>
            <span class="lnum"> 28: </span>
            <span class="rem">//this is where you would go
to the</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 29: </span>
            <span class="rem">//model for data,
but we’ll cheat</span>
          </pre>
          <pre>
            <span class="lnum"> 30: </span>List&lt;<span class="kwrd">string</span>&gt; users
= <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;(<span class="kwrd">new</span><span class="kwrd">string</span>[]
i</pre>
          <pre class="alt">
            <span class="lnum"> 31: </span>{ <span class="str">"Fred"</span>, <span class="str">"Bob"</span>, <span class="str">"Patty"</span> });</pre>
          <pre>
            <span class="lnum"> 32: </span>_view.Users = users;</pre>
          <pre class="alt">
            <span class="lnum"> 33: </span>}</pre>
          <pre>
            <span class="lnum"> 34: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">void</span> SelectedIndexChanged(<span class="kwrd">int</span> index)</pre>
          <pre class="alt">
            <span class="lnum"> 35: </span> {</pre>
          <pre>
            <span class="lnum"> 36: </span>
            <span class="rem">//go to the model and get answers
for questions</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 37: </span>
            <span class="rem">//we’ll make it
up</span>
          </pre>
          <pre>
            <span class="lnum"> 38: </span>
            <span class="rem">//this is also where the answers
to the previous</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 39: </span>
            <span class="rem">//questions would
be saved back to the model</span>
          </pre>
          <pre>
            <span class="lnum"> 40: </span> _view.Question1 = <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 41: </span> _view.Question2 = <span class="kwrd">string</span>.Format(<span class="str">"{0}
is cool!"</span>, _view.Users[index]);</pre>
          <pre>
            <span class="lnum"> 42: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 43: </span>}</pre>
          <pre>
            <span class="lnum"> 44: </span> </pre>
          <pre class="alt">
            <span class="lnum"> 45: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">partial</span>
            <span class="kwrd">class</span> MvpMain
: Form, ISurveyView</pre>
          <pre>
            <span class="lnum"> 46: </span>{</pre>
          <pre class="alt">
            <span class="lnum"> 47: </span>
            <span class="kwrd">public</span> MvpMain()</pre>
          <pre>
            <span class="lnum"> 48: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 49: </span> InitializeComponent();</pre>
          <pre>
            <span class="lnum"> 50: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 51: </span>
            <span class="kwrd">private</span> SurveyPresenter
_presenter;</pre>
          <pre>
            <span class="lnum"> 52: </span>
            <span class="preproc">#region</span> ISurveyView
Members</pre>
          <pre class="alt">
            <span class="lnum"> 53: </span>
            <span class="kwrd">public</span> List&lt;<span class="kwrd">string</span>&gt;
Users</pre>
          <pre>
            <span class="lnum"> 54: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 55: </span> get</pre>
          <pre>
            <span class="lnum"> 56: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 57: </span> List&lt;<span class="kwrd">string</span>&gt;
users = <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;();</pre>
          <pre>
            <span class="lnum"> 58: </span>
            <span class="kwrd">foreach</span> (<span class="kwrd">object</span> item <span class="kwrd">in</span> userList.Items)</pre>
          <pre class="alt">
            <span class="lnum"> 59: </span> {</pre>
          <pre>
            <span class="lnum"> 60: </span> users.Add((<span class="kwrd">string</span>)item);</pre>
          <pre class="alt">
            <span class="lnum"> 61: </span> }</pre>
          <pre>
            <span class="lnum"> 62: </span>
            <span class="kwrd">return</span> users;</pre>
          <pre class="alt">
            <span class="lnum"> 63: </span> }</pre>
          <pre>
            <span class="lnum"> 64: </span> set</pre>
          <pre class="alt">
            <span class="lnum"> 65: </span> {</pre>
          <pre>
            <span class="lnum"> 66: </span> userList.Items.Clear();</pre>
          <pre class="alt">
            <span class="lnum"> 67: </span>
            <span class="kwrd">foreach</span> (<span class="kwrd">string</span> user <span class="kwrd">in</span><span class="kwrd">value</span>)</pre>
          <pre>
            <span class="lnum"> 68: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 69: </span> userList.Items.Add(user);</pre>
          <pre>
            <span class="lnum"> 70: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 71: </span> }</pre>
          <pre>
            <span class="lnum"> 72: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 73: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">bool</span> Question1</pre>
          <pre>
            <span class="lnum"> 74: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 75: </span> get</pre>
          <pre>
            <span class="lnum"> 76: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 77: </span>
            <span class="kwrd">if</span> (yesButton.Checked)</pre>
          <pre>
            <span class="lnum"> 78: </span>
            <span class="kwrd">return</span>
            <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 79: </span>
            <span class="kwrd">else</span>
          </pre>
          <pre>
            <span class="lnum"> 80: </span>
            <span class="kwrd">return</span>
            <span class="kwrd">false</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 81: </span> }</pre>
          <pre>
            <span class="lnum"> 82: </span> set</pre>
          <pre class="alt">
            <span class="lnum"> 83: </span> {</pre>
          <pre>
            <span class="lnum"> 84: </span>
            <span class="kwrd">if</span> (<span class="kwrd">value</span>)</pre>
          <pre class="alt">
            <span class="lnum"> 85: </span> {</pre>
          <pre>
            <span class="lnum"> 86: </span> yesButton.Checked = <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 87: </span> noButton.Checked = <span class="kwrd">false</span>;</pre>
          <pre>
            <span class="lnum"> 88: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 89: </span>
            <span class="kwrd">else</span>
          </pre>
          <pre>
            <span class="lnum"> 90: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 91: </span> yesButton.Checked = <span class="kwrd">false</span>;</pre>
          <pre>
            <span class="lnum"> 92: </span> noButton.Checked = <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 93: </span> }</pre>
          <pre>
            <span class="lnum"> 94: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 95: </span> }</pre>
          <pre>
            <span class="lnum"> 96: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">string</span> Question2</pre>
          <pre class="alt">
            <span class="lnum"> 97: </span> {</pre>
          <pre>
            <span class="lnum"> 98: </span> get</pre>
          <pre class="alt">
            <span class="lnum"> 99: </span> {</pre>
          <pre>
            <span class="lnum"> 100: </span>
            <span class="kwrd">return</span> question2Box.Text;</pre>
          <pre class="alt">
            <span class="lnum"> 101: </span> }</pre>
          <pre>
            <span class="lnum"> 102: </span> set</pre>
          <pre class="alt">
            <span class="lnum"> 103: </span> {</pre>
          <pre>
            <span class="lnum"> 104: </span> question2Box.Text = <span class="kwrd">value</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 105: </span> }</pre>
          <pre>
            <span class="lnum"> 106: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 107: </span>
            <span class="preproc">#endregion</span>
          </pre>
          <pre>
            <span class="lnum"> 108: </span>
            <span class="kwrd">private</span>
            <span class="kwrd">void</span> MvpMain_Load(<span class="kwrd">object</span> sender,
EventArgs e)</pre>
          <pre class="alt">
            <span class="lnum"> 109: </span> {</pre>
          <pre>
            <span class="lnum"> 110: </span> _presenter = SurveyPresenter.Instance(<span class="kwrd">this</span>);</pre>
          <pre class="alt">
            <span class="lnum"> 111: </span> _presenter.OnLoad();</pre>
          <pre>
            <span class="lnum"> 112: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 113: </span>
            <span class="kwrd">private</span>
            <span class="kwrd">void</span> userList_SelectedIndexChanged(<span class="kwrd">object</span> sender,
EventArgs e)</pre>
          <pre>
            <span class="lnum"> 114: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 115: </span> _presenter.SelectedIndexChanged(userList.SelectedIndex);</pre>
          <pre>
            <span class="lnum"> 116: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 117: </span>}</pre>
        </div>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
 
</p>
        <p>
Method 2
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="lnum"> 1: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">interface</span> ISurveyView</pre>
          <pre>
            <span class="lnum"> 2: </span>{</pre>
          <pre class="alt">
            <span class="lnum"> 3: </span> List&lt;<span class="kwrd">string</span>&gt;
Users { get; set; }</pre>
          <pre>
            <span class="lnum"> 4: </span>
            <span class="kwrd">bool</span> Question1 { get;
set; }</pre>
          <pre class="alt">
            <span class="lnum"> 5: </span>
            <span class="kwrd">string</span> Question2
{ get; set; }</pre>
          <pre>
            <span class="lnum"> 6: </span>
            <span class="kwrd">event</span> SelectionChangedDelegate
SelectionChanged;</pre>
          <pre class="alt">
            <span class="lnum"> 7: </span>
            <span class="kwrd">event</span> OnLoadDelegate
OnLoad;</pre>
          <pre>
            <span class="lnum"> 8: </span>}</pre>
          <pre class="alt">
            <span class="lnum"> 9: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">delegate</span>
            <span class="kwrd">void</span> SelectionChangedDelegate(<span class="kwrd">int</span> index);</pre>
          <pre>
            <span class="lnum"> 10: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">delegate</span>
            <span class="kwrd">void</span> OnLoadDelegate();</pre>
          <pre class="alt">
            <span class="lnum"> 11: </span> </pre>
          <pre>
            <span class="lnum"> 12: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">class</span> SurveyPresenter</pre>
          <pre class="alt">
            <span class="lnum"> 13: </span>{</pre>
          <pre>
            <span class="lnum"> 14: </span> ISurveyView _view;</pre>
          <pre class="alt">
            <span class="lnum"> 15: </span>
            <span class="kwrd">public</span> SurveyPresenter(ISurveyView
view)</pre>
          <pre>
            <span class="lnum"> 16: </span>{</pre>
          <pre class="alt">
            <span class="lnum"> 17: </span>_view = view;</pre>
          <pre>
            <span class="lnum"> 18: </span>_view.OnLoad += <span class="kwrd">new</span> OnLoadDelegate(OnLoad);</pre>
          <pre class="alt">
            <span class="lnum"> 19: </span>_view.SelectionChanged += <span class="kwrd">new</span> i</pre>
          <pre>
            <span class="lnum"> 20: </span>SelectionChangedDelegate(SelectedIndexChanged);</pre>
          <pre class="alt">
            <span class="lnum"> 21: </span>}</pre>
          <pre>
            <span class="lnum"> 22: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">void</span> OnLoad()</pre>
          <pre class="alt">
            <span class="lnum"> 23: </span>{</pre>
          <pre>
            <span class="lnum"> 24: </span>
            <span class="rem">//this is where you would go
to the</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 25: </span>
            <span class="rem">//model for data,
but we’ll cheat</span>
          </pre>
          <pre>
            <span class="lnum"> 26: </span>List&lt;<span class="kwrd">string</span>&gt; users
= <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;(<span class="kwrd">new</span><span class="kwrd">string</span>[]
i</pre>
          <pre class="alt">
            <span class="lnum"> 27: </span>{ <span class="str">"Fred"</span>, <span class="str">"Bob"</span>, <span class="str">"Patty"</span> });</pre>
          <pre>
            <span class="lnum"> 28: </span>_view.Users = users;</pre>
          <pre class="alt">
            <span class="lnum"> 29: </span>}</pre>
          <pre>
            <span class="lnum"> 30: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">void</span> SelectedIndexChanged(<span class="kwrd">int</span> index)</pre>
          <pre class="alt">
            <span class="lnum"> 31: </span> {</pre>
          <pre>
            <span class="lnum"> 32: </span>
            <span class="rem">//go to the model and get answers
for questions</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 33: </span>
            <span class="rem">//we’ll make it
up</span>
          </pre>
          <pre>
            <span class="lnum"> 34: </span>
            <span class="rem">//This is also where the answers
to the previous</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 35: </span>
            <span class="rem">//questions would
be saved back to the model.</span>
          </pre>
          <pre>
            <span class="lnum"> 36: </span> _view.Question1 = <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 37: </span> _view.Question2 = <span class="kwrd">string</span>.Format(<span class="str">"{0}
is cool!"</span>, _view.Users[index]);</pre>
          <pre>
            <span class="lnum"> 38: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 39: </span>}</pre>
          <pre>
            <span class="lnum"> 40: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">partial</span>
            <span class="kwrd">class</span> MvpMain
: Form, ISurveyView</pre>
          <pre class="alt">
            <span class="lnum"> 41: </span>{</pre>
          <pre>
            <span class="lnum"> 42: </span>
            <span class="kwrd">public</span> MvpMain()</pre>
          <pre class="alt">
            <span class="lnum"> 43: </span> {</pre>
          <pre>
            <span class="lnum"> 44: </span> InitializeComponent();</pre>
          <pre class="alt">
            <span class="lnum"> 45: </span> _presenter = <span class="kwrd">new</span> SurveyPresenter(<span class="kwrd">this</span>);</pre>
          <pre>
            <span class="lnum"> 46: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 47: </span>
            <span class="kwrd">private</span> SurveyPresenter
_presenter;</pre>
          <pre>
            <span class="lnum"> 48: </span>
            <span class="preproc">#region</span> ISurveyView
Members</pre>
          <pre class="alt">
            <span class="lnum"> 49: </span>
            <span class="kwrd">public</span> List&lt;<span class="kwrd">string</span>&gt;
Users</pre>
          <pre>
            <span class="lnum"> 50: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 51: </span> get</pre>
          <pre>
            <span class="lnum"> 52: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 53: </span> List&lt;<span class="kwrd">string</span>&gt;
users = <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;();</pre>
          <pre>
            <span class="lnum"> 54: </span>
            <span class="kwrd">foreach</span> (<span class="kwrd">object</span> item <span class="kwrd">in</span> userList.Items)</pre>
          <pre class="alt">
            <span class="lnum"> 55: </span> {</pre>
          <pre>
            <span class="lnum"> 56: </span> users.Add((<span class="kwrd">string</span>)item);</pre>
          <pre class="alt">
            <span class="lnum"> 57: </span> }</pre>
          <pre>
            <span class="lnum"> 58: </span>
            <span class="kwrd">return</span> users;</pre>
          <pre class="alt">
            <span class="lnum"> 59: </span> }</pre>
          <pre>
            <span class="lnum"> 60: </span> set</pre>
          <pre class="alt">
            <span class="lnum"> 61: </span> {</pre>
          <pre>
            <span class="lnum"> 62: </span> userList.Items.Clear();</pre>
          <pre class="alt">
            <span class="lnum"> 63: </span>
            <span class="kwrd">foreach</span> (<span class="kwrd">string</span> user <span class="kwrd">in</span><span class="kwrd">value</span>)</pre>
          <pre>
            <span class="lnum"> 64: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 65: </span> userList.Items.Add(user);</pre>
          <pre>
            <span class="lnum"> 66: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 67: </span> }</pre>
          <pre>
            <span class="lnum"> 68: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 69: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">bool</span> Question1</pre>
          <pre>
            <span class="lnum"> 70: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 71: </span> get</pre>
          <pre>
            <span class="lnum"> 72: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 73: </span>
            <span class="kwrd">if</span> (yesButton.Checked)</pre>
          <pre>
            <span class="lnum"> 74: </span>
            <span class="kwrd">return</span>
            <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 75: </span>
            <span class="kwrd">else</span>
          </pre>
          <pre>
            <span class="lnum"> 76: </span>
            <span class="kwrd">return</span>
            <span class="kwrd">false</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 77: </span> }</pre>
          <pre>
            <span class="lnum"> 78: </span> set</pre>
          <pre class="alt">
            <span class="lnum"> 79: </span> {</pre>
          <pre>
            <span class="lnum"> 80: </span>
            <span class="kwrd">if</span> (<span class="kwrd">value</span>)</pre>
          <pre class="alt">
            <span class="lnum"> 81: </span> {</pre>
          <pre>
            <span class="lnum"> 82: </span> yesButton.Checked = <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 83: </span> noButton.Checked = <span class="kwrd">false</span>;</pre>
          <pre>
            <span class="lnum"> 84: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 85: </span>
            <span class="kwrd">else</span>
          </pre>
          <pre>
            <span class="lnum"> 86: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 87: </span> yesButton.Checked = <span class="kwrd">false</span>;</pre>
          <pre>
            <span class="lnum"> 88: </span> noButton.Checked = <span class="kwrd">true</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 89: </span> }</pre>
          <pre>
            <span class="lnum"> 90: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 91: </span> }</pre>
          <pre>
            <span class="lnum"> 92: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">string</span> Question2</pre>
          <pre class="alt">
            <span class="lnum"> 93: </span> {</pre>
          <pre>
            <span class="lnum"> 94: </span> get</pre>
          <pre class="alt">
            <span class="lnum"> 95: </span> {</pre>
          <pre>
            <span class="lnum"> 96: </span>
            <span class="kwrd">return</span> question2Box.Text;</pre>
          <pre class="alt">
            <span class="lnum"> 97: </span> }</pre>
          <pre>
            <span class="lnum"> 98: </span> set</pre>
          <pre class="alt">
            <span class="lnum"> 99: </span> {</pre>
          <pre>
            <span class="lnum"> 100: </span> question2Box.Text = <span class="kwrd">value</span>;</pre>
          <pre class="alt">
            <span class="lnum"> 101: </span> }</pre>
          <pre>
            <span class="lnum"> 102: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 103: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">event</span> OnLoadDelegate
OnLoad;</pre>
          <pre>
            <span class="lnum"> 104: </span>
            <span class="kwrd">public</span>
            <span class="kwrd">event</span> SelectionChangedDelegate
SelectionChanged;</pre>
          <pre class="alt">
            <span class="lnum"> 105: </span>
            <span class="preproc">#endregion</span>
          </pre>
          <pre>
            <span class="lnum"> 106: </span>
            <span class="kwrd">private</span>
            <span class="kwrd">void</span> MvpMain_Load(<span class="kwrd">object</span> sender,
EventArgs e)</pre>
          <pre class="alt">
            <span class="lnum"> 107: </span> {</pre>
          <pre>
            <span class="lnum"> 108: </span>
            <span class="kwrd">if</span> (OnLoad != <span class="kwrd">null</span>)</pre>
          <pre class="alt">
            <span class="lnum"> 109: </span> OnLoad();</pre>
          <pre>
            <span class="lnum"> 110: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 111: </span>
            <span class="kwrd">private</span>
            <span class="kwrd">void</span> userList_SelectedIndexChanged(<span class="kwrd">object</span> sender,
EventArgs e)</pre>
          <pre>
            <span class="lnum"> 112: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 113: </span>
            <span class="kwrd">if</span> (SelectionChanged
!= <span class="kwrd">null</span>)</pre>
          <pre>
            <span class="lnum"> 114: </span> SelectionChanged(userList.SelectedIndex);</pre>
          <pre class="alt">
            <span class="lnum"> 115: </span> }</pre>
          <pre>
            <span class="lnum"> 116: </span>}</pre>
        </div>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=7ff0a174-37a0-4056-b0cf-f9acc5595c54" />
      </body>
      <title>Model-View-Presenter</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,7ff0a174-37a0-4056-b0cf-f9acc5595c54.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,7ff0a174-37a0-4056-b0cf-f9acc5595c54.aspx</link>
      <pubDate>Thu, 25 Mar 2010 20:56:58 GMT</pubDate>
      <description>&lt;p&gt;
From book “Code leader using people tools and processes to build successful software”
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb.png" width="244" height="130"&gt;&lt;/a&gt; &lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb_1.png" width="126" height="244"&gt;&lt;/a&gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb_2.png" width="381" height="287"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The trickiest part of the MVP design process is the View. It must represent all of
the interaction you will&lt;br&gt;
have with your user, using display-agnostic data types. The View, in essence, forms
your application’s&lt;br&gt;
contract with what is ‘‘on the glass’’ or visible to the user on their monitor. If
you are following a TDD&lt;br&gt;
development process, your View is likely to change and evolve during the course of
development, as&lt;br&gt;
requirements become more apparent. That should be easy to do if the proper separation
between View&lt;br&gt;
and Presenter is maintained, although a little refactoring along the way never hurt
anyone.
&lt;/p&gt;
&lt;p&gt;
In most languages, it is easiest to represent your View as an &lt;strong&gt;interface&lt;/strong&gt;.
The concrete class directly responsible&lt;br&gt;
for display will implement the View interface. When you write your test code, you
can create another&lt;br&gt;
implementation of the View interface for testing purposes that has no actual user
interface elements&lt;br&gt;
associated with it.
&lt;/p&gt;
&lt;p&gt;
There is one major decision to make before starting work on your View interface. Will
your View expose&lt;br&gt;
events directly? Or will it call the Presenter to report user activity? This is often
debated when starting an&lt;br&gt;
MVP project, and there are adherents in both camps. To put the cards on the table
up front, I personally&lt;br&gt;
favor the former from an architectural perspective. It offers the cleanest separation
between View and&lt;br&gt;
Presenter because the View need know nothing at all about the Presenter. It only receives
data pushed to&lt;br&gt;
it and fires events that represent user actions. From a practical standpoint, however,
there are cons. Using&lt;br&gt;
events may be difficult in some implementation environments. Specifically in a web
application, it may&lt;br&gt;
be difficult for your server ‘‘page’’ to fire events, and just as difficult for your
Presenter to subscribe to&lt;br&gt;
them. It can be much easier in such an application to provide the View with direct
access to the Presenter&lt;br&gt;
so that user events can be reported directly as method calls. That potentially makes
it easier to deal with&lt;br&gt;
the issue of display-agnostic data types as well. If your View’s user interface element
(a button, say) fires&lt;br&gt;
events, and the View has to catch those events, translate from display data types
to neutral data types,&lt;br&gt;
and then fire a second event, the code could become quite cumbersome. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/ModelViewPresenter_EECC/image_thumb_3.png" width="297" height="216"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Method 1 
&lt;p&gt;
&amp;nbsp; 
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 1: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ISurveyView&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 2: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 3: &lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;
Users { get; set; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 4: &lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Question1 { get;
set; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 5: &lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Question2
{ get; set; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 6: &lt;/span&gt;}&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 7: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SurveyPresenter&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 8: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 9: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Dictionary&amp;lt;ISurveyView,
SurveyPresenter&amp;gt; _presenters =&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 10: &lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;ISurveyView,
SurveyPresenter&amp;gt;();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 11: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; lockObject
= &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;();&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 12: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; SurveyPresenter
Instance(ISurveyView view)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 13: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 14: &lt;/span&gt; &lt;span class="kwrd"&gt;lock&lt;/span&gt; (lockObject)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 15: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 16: &lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (!_presenters.ContainsKey(view))&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 17: &lt;/span&gt; _presenters[view] = &lt;span class="kwrd"&gt;new&lt;/span&gt; SurveyPresenter(view);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 18: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; _presenters[view];&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 19: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 20: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 21: &lt;/span&gt; ISurveyView _view;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 22: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; SurveyPresenter(ISurveyView
view)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 23: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 24: &lt;/span&gt; _view = view;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 25: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 26: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnLoad()&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 27: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 28: &lt;/span&gt;&lt;span class="rem"&gt;//this is where you would go
to the&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 29: &lt;/span&gt;&lt;span class="rem"&gt;//model for data,
but we’ll cheat&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 30: &lt;/span&gt;List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; users
= &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;[]
i&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 31: &lt;/span&gt;{ &lt;span class="str"&gt;"Fred"&lt;/span&gt;, &lt;span class="str"&gt;"Bob"&lt;/span&gt;, &lt;span class="str"&gt;"Patty"&lt;/span&gt; });&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 32: &lt;/span&gt;_view.Users = users;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 33: &lt;/span&gt;}&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 34: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SelectedIndexChanged(&lt;span class="kwrd"&gt;int&lt;/span&gt; index)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 35: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 36: &lt;/span&gt; &lt;span class="rem"&gt;//go to the model and get answers
for questions&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 37: &lt;/span&gt; &lt;span class="rem"&gt;//we’ll make it
up&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 38: &lt;/span&gt; &lt;span class="rem"&gt;//this is also where the answers
to the previous&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 39: &lt;/span&gt; &lt;span class="rem"&gt;//questions would
be saved back to the model&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 40: &lt;/span&gt; _view.Question1 = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 41: &lt;/span&gt; _view.Question2 = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0}
is cool!"&lt;/span&gt;, _view.Users[index]);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 42: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 43: &lt;/span&gt;}&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 44: &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 45: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MvpMain
: Form, ISurveyView&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 46: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 47: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; MvpMain()&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 48: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 49: &lt;/span&gt; InitializeComponent();&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 50: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 51: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; SurveyPresenter
_presenter;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 52: &lt;/span&gt; &lt;span class="preproc"&gt;#region&lt;/span&gt; ISurveyView
Members&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 53: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;
Users&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 54: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 55: &lt;/span&gt; get&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 56: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 57: &lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;
users = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 58: &lt;/span&gt; &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;object&lt;/span&gt; item &lt;span class="kwrd"&gt;in&lt;/span&gt; userList.Items)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 59: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 60: &lt;/span&gt; users.Add((&lt;span class="kwrd"&gt;string&lt;/span&gt;)item);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 61: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 62: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; users;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 63: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 64: &lt;/span&gt; set&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 65: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 66: &lt;/span&gt; userList.Items.Clear();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 67: &lt;/span&gt; &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; user &lt;span class="kwrd"&gt;in&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 68: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 69: &lt;/span&gt; userList.Items.Add(user);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 70: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 71: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 72: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 73: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Question1&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 74: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 75: &lt;/span&gt; get&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 76: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 77: &lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (yesButton.Checked)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 78: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 79: &lt;/span&gt; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 80: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 81: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 82: &lt;/span&gt; set&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 83: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 84: &lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 85: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 86: &lt;/span&gt; yesButton.Checked = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 87: &lt;/span&gt; noButton.Checked = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 88: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 89: &lt;/span&gt; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 90: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 91: &lt;/span&gt; yesButton.Checked = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 92: &lt;/span&gt; noButton.Checked = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 93: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 94: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 95: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 96: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Question2&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 97: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 98: &lt;/span&gt; get&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 99: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 100: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; question2Box.Text;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 101: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 102: &lt;/span&gt; set&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 103: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 104: &lt;/span&gt; question2Box.Text = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 105: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 106: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 107: &lt;/span&gt; &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 108: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MvpMain_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 109: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 110: &lt;/span&gt; _presenter = SurveyPresenter.Instance(&lt;span class="kwrd"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 111: &lt;/span&gt; _presenter.OnLoad();&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 112: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 113: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; userList_SelectedIndexChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 114: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 115: &lt;/span&gt; _presenter.SelectedIndexChanged(userList.SelectedIndex);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 116: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 117: &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Method 2
&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 1: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ISurveyView&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 2: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 3: &lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;
Users { get; set; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 4: &lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Question1 { get;
set; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 5: &lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Question2
{ get; set; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 6: &lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; SelectionChangedDelegate
SelectionChanged;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 7: &lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; OnLoadDelegate
OnLoad;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 8: &lt;/span&gt;}&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 9: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;delegate&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SelectionChangedDelegate(&lt;span class="kwrd"&gt;int&lt;/span&gt; index);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 10: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;delegate&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnLoadDelegate();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 11: &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 12: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SurveyPresenter&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 13: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 14: &lt;/span&gt; ISurveyView _view;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 15: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; SurveyPresenter(ISurveyView
view)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 16: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 17: &lt;/span&gt;_view = view;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 18: &lt;/span&gt;_view.OnLoad += &lt;span class="kwrd"&gt;new&lt;/span&gt; OnLoadDelegate(OnLoad);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 19: &lt;/span&gt;_view.SelectionChanged += &lt;span class="kwrd"&gt;new&lt;/span&gt; i&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 20: &lt;/span&gt;SelectionChangedDelegate(SelectedIndexChanged);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 21: &lt;/span&gt;}&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 22: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnLoad()&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 23: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 24: &lt;/span&gt;&lt;span class="rem"&gt;//this is where you would go
to the&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 25: &lt;/span&gt;&lt;span class="rem"&gt;//model for data,
but we’ll cheat&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 26: &lt;/span&gt;List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; users
= &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;[]
i&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 27: &lt;/span&gt;{ &lt;span class="str"&gt;"Fred"&lt;/span&gt;, &lt;span class="str"&gt;"Bob"&lt;/span&gt;, &lt;span class="str"&gt;"Patty"&lt;/span&gt; });&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 28: &lt;/span&gt;_view.Users = users;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 29: &lt;/span&gt;}&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 30: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SelectedIndexChanged(&lt;span class="kwrd"&gt;int&lt;/span&gt; index)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 31: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 32: &lt;/span&gt; &lt;span class="rem"&gt;//go to the model and get answers
for questions&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 33: &lt;/span&gt; &lt;span class="rem"&gt;//we’ll make it
up&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 34: &lt;/span&gt; &lt;span class="rem"&gt;//This is also where the answers
to the previous&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 35: &lt;/span&gt; &lt;span class="rem"&gt;//questions would
be saved back to the model.&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 36: &lt;/span&gt; _view.Question1 = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 37: &lt;/span&gt; _view.Question2 = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0}
is cool!"&lt;/span&gt;, _view.Users[index]);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 38: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 39: &lt;/span&gt;}&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 40: &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MvpMain
: Form, ISurveyView&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 41: &lt;/span&gt;{&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 42: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; MvpMain()&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 43: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 44: &lt;/span&gt; InitializeComponent();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 45: &lt;/span&gt; _presenter = &lt;span class="kwrd"&gt;new&lt;/span&gt; SurveyPresenter(&lt;span class="kwrd"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 46: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 47: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; SurveyPresenter
_presenter;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 48: &lt;/span&gt; &lt;span class="preproc"&gt;#region&lt;/span&gt; ISurveyView
Members&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 49: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;
Users&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 50: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 51: &lt;/span&gt; get&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 52: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 53: &lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;
users = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 54: &lt;/span&gt; &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;object&lt;/span&gt; item &lt;span class="kwrd"&gt;in&lt;/span&gt; userList.Items)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 55: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 56: &lt;/span&gt; users.Add((&lt;span class="kwrd"&gt;string&lt;/span&gt;)item);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 57: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 58: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; users;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 59: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 60: &lt;/span&gt; set&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 61: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 62: &lt;/span&gt; userList.Items.Clear();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 63: &lt;/span&gt; &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; user &lt;span class="kwrd"&gt;in&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 64: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 65: &lt;/span&gt; userList.Items.Add(user);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 66: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 67: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 68: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 69: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Question1&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 70: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 71: &lt;/span&gt; get&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 72: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 73: &lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (yesButton.Checked)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 74: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 75: &lt;/span&gt; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 76: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 77: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 78: &lt;/span&gt; set&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 79: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 80: &lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 81: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 82: &lt;/span&gt; yesButton.Checked = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 83: &lt;/span&gt; noButton.Checked = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 84: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 85: &lt;/span&gt; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 86: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 87: &lt;/span&gt; yesButton.Checked = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 88: &lt;/span&gt; noButton.Checked = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 89: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 90: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 91: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 92: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Question2&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 93: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 94: &lt;/span&gt; get&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 95: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 96: &lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; question2Box.Text;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 97: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 98: &lt;/span&gt; set&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 99: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 100: &lt;/span&gt; question2Box.Text = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 101: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 102: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 103: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; OnLoadDelegate
OnLoad;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 104: &lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; SelectionChangedDelegate
SelectionChanged;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 105: &lt;/span&gt; &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 106: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MvpMain_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 107: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 108: &lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (OnLoad != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 109: &lt;/span&gt; OnLoad();&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 110: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 111: &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; userList_SelectedIndexChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 112: &lt;/span&gt; {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 113: &lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (SelectionChanged
!= &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 114: &lt;/span&gt; SelectionChanged(userList.SelectedIndex);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 115: &lt;/span&gt; }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt; 116: &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=7ff0a174-37a0-4056-b0cf-f9acc5595c54" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,7ff0a174-37a0-4056-b0cf-f9acc5595c54.aspx</comments>
      <category>Design;DotNet</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=bc74545d-dbbc-4b34-bfd8-238e1e472dff</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=bc74545d-dbbc-4b34-bfd8-238e1e472dff</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://en.wikipedia.org/wiki/Component-oriented_programming" href="http://en.wikipedia.org/wiki/Component-oriented_programming">http://en.wikipedia.org/wiki/Component-oriented_programming</a>
        </p>
        <p>
The main idea is <i>separation of concerns</i>;
</p>
        <p>
Software engineers regard components as part of the starting platform for service
orientation. Components play this role, for example, in <a href="http://en.wikipedia.org/wiki/Web_Services">Web
Services</a>, and more recently, in <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">Service-Oriented
Architecture (SOA)</a> - whereby a component is converted<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words">by
whom?</a></i>]</sup> into a <i>service</i> and subsequently inherits further characteristics
beyond that of an ordinary component.
</p>
        <p>
An individual component is a software package or a <a href="http://en.wikipedia.org/wiki/Modular_programming">module</a> that
encapsulates a set of related functions (or data).
</p>
        <p>
All system processes are placed into separate components so that all of the data and
functions inside each component are semantically related (just as with the contents
of classes). Because of this principle, it is often said that components are <i>modular</i> and <i>cohesive</i>.
</p>
        <p>
With regard to system-wide co-ordination, components communicate with each other <strong>via <i>interfaces</i></strong>.
When a component offers services to the rest of the system, it adopts a <i>provided</i> interface
which specifies the services that can be utilized by other components and how. This
interface can be seen as a <strong>signature</strong> of the component - the client
does not need to know about the inner workings of the component (implementation) in
order to make use of it. This principle results in components referred to as <i><strong><font color="#ff0000">encapsulated</font></strong></i>.
</p>
        <p>
Another important attribute of components is that they are <i><strong><font color="#ff0000">substitutable</font></strong></i>,
</p>
        <p>
Software components often take <strong>the form of </strong><a href="http://en.wikipedia.org/wiki/Object_%28computing%29"><strong>objects</strong></a><strong> or
collections of objects</strong> (from <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented
programming</a>), in some binary or textual form, adhering to some <a href="http://en.wikipedia.org/wiki/Interface_description_language">interface
description language</a> (IDL) so that the component may exist autonomously from other
components in a <a href="http://en.wikipedia.org/wiki/Computer">computer</a>.
</p>
        <p>
          <a href="http://en.wikipedia.org/wiki/Reusability">
            <strong>
              <font color="#ff0000">Reusability</font>
            </strong>
          </a> is
an important characteristic of a high-quality software component. A software component
should be designed and implemented so that it can be reused in many different programs. 
</p>
        <p>
It takes significant effort and awareness to write a software component that is effectively
reusable. The component needs to be: 
</p>
        <ul>
          <li>
fully documented 
</li>
          <li>
thoroughly tested 
<ul><li>
robust - with comprehensive input-validity checking 
</li><li>
able to pass back appropriate <a href="http://en.wikipedia.org/wiki/Error_message">error
messages</a> or return codes 
</li></ul></li>
          <li>
designed with an awareness that it <i>will</i> be put to unforeseen uses 
</li>
        </ul>
        <h4>Differences from object-oriented programming
</h4>
        <p>
Proponents of <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented
programming</a> (OOP) maintain that software should be written according to a mental
model of the actual or imagined objects it represents. OOP and the related disciplines
of <a href="http://en.wikipedia.org/wiki/Object-oriented_design">object-oriented design</a> and <a href="http://en.wikipedia.org/wiki/Object-oriented_analysis">object-oriented
analysis</a> focus on modeling real-world<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed">citation
needed</a></i>]</sup> interactions and attempting to create "verbs" and "nouns" which
can be used in intuitive<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed">citation
needed</a></i>]</sup> ways, ideally by end users as well as by programmers coding
for those end users. 
</p>
        <p>
Component-based software engineering, by contrast, makes no such assumptions, and
instead states that developers should construct software by gluing together prefabricated
components - much like in the fields of <a href="http://en.wikipedia.org/wiki/Electronics">electronics</a> or <a href="http://en.wikipedia.org/wiki/Mechanics">mechanics</a>.
Some peers<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words">who?</a></i>]</sup> will
even talk of modularizing systems as software components as a new <a href="http://en.wikipedia.org/wiki/Programming_paradigm">programming
paradigm</a>. 
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <em>
            <strong>
              <font color="#0080ff">Component-based development (CBD) is an extension
of object-oriented programming. CBD does away with the language and vendor-specific
limitations of OOP, and makes software reuse more practical and accelerates the development
process. Event-based programming is the next logical step in CBD, and makes components
more reusable due to their decoupled nature. But event-based systems are easier to
develop, which means they are cheaper and more reliable than traditional OOP or CBD
systems.</font>
            </strong>
          </em>
          <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=bc74545d-dbbc-4b34-bfd8-238e1e472dff" />
        </p>
      </body>
      <title>Component-Oriented Programming</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</link>
      <pubDate>Tue, 09 Mar 2010 19:22:24 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://en.wikipedia.org/wiki/Component-oriented_programming" href="http://en.wikipedia.org/wiki/Component-oriented_programming"&gt;http://en.wikipedia.org/wiki/Component-oriented_programming&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The main idea is &lt;i&gt;separation of concerns&lt;/i&gt;;
&lt;/p&gt;
&lt;p&gt;
Software engineers regard components as part of the starting platform for service
orientation. Components play this role, for example, in &lt;a href="http://en.wikipedia.org/wiki/Web_Services"&gt;Web
Services&lt;/a&gt;, and more recently, in &lt;a href="http://en.wikipedia.org/wiki/Service-oriented_architecture"&gt;Service-Oriented
Architecture (SOA)&lt;/a&gt; - whereby a component is converted&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words"&gt;by
whom?&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; into a &lt;i&gt;service&lt;/i&gt; and subsequently inherits further characteristics
beyond that of an ordinary component.
&lt;/p&gt;
&lt;p&gt;
An individual component is a software package or a &lt;a href="http://en.wikipedia.org/wiki/Modular_programming"&gt;module&lt;/a&gt; that
encapsulates a set of related functions (or data).
&lt;/p&gt;
&lt;p&gt;
All system processes are placed into separate components so that all of the data and
functions inside each component are semantically related (just as with the contents
of classes). Because of this principle, it is often said that components are &lt;i&gt;modular&lt;/i&gt; and &lt;i&gt;cohesive&lt;/i&gt;.
&lt;/p&gt;
&lt;p&gt;
With regard to system-wide co-ordination, components communicate with each other &lt;strong&gt;via &lt;i&gt;interfaces&lt;/i&gt;&lt;/strong&gt;.
When a component offers services to the rest of the system, it adopts a &lt;i&gt;provided&lt;/i&gt; interface
which specifies the services that can be utilized by other components and how. This
interface can be seen as a &lt;strong&gt;signature&lt;/strong&gt; of the component - the client
does not need to know about the inner workings of the component (implementation) in
order to make use of it. This principle results in components referred to as &lt;i&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;encapsulated&lt;/font&gt;&lt;/strong&gt;&lt;/i&gt;.
&lt;/p&gt;
&lt;p&gt;
Another important attribute of components is that they are &lt;i&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;substitutable&lt;/font&gt;&lt;/strong&gt;&lt;/i&gt;,
&lt;/p&gt;
&lt;p&gt;
Software components often take &lt;strong&gt;the form of &lt;/strong&gt;&lt;a href="http://en.wikipedia.org/wiki/Object_%28computing%29"&gt;&lt;strong&gt;objects&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; or
collections of objects&lt;/strong&gt; (from &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming"&gt;object-oriented
programming&lt;/a&gt;), in some binary or textual form, adhering to some &lt;a href="http://en.wikipedia.org/wiki/Interface_description_language"&gt;interface
description language&lt;/a&gt; (IDL) so that the component may exist autonomously from other
components in a &lt;a href="http://en.wikipedia.org/wiki/Computer"&gt;computer&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://en.wikipedia.org/wiki/Reusability"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Reusability&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; is
an important characteristic of a high-quality software component. A software component
should be designed and implemented so that it can be reused in many different programs. 
&lt;p&gt;
It takes significant effort and awareness to write a software component that is effectively
reusable. The component needs to be: 
&lt;ul&gt;
&lt;li&gt;
fully documented 
&lt;li&gt;
thoroughly tested 
&lt;ul&gt;
&lt;li&gt;
robust - with comprehensive input-validity checking 
&lt;li&gt;
able to pass back appropriate &lt;a href="http://en.wikipedia.org/wiki/Error_message"&gt;error
messages&lt;/a&gt; or return codes 
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
designed with an awareness that it &lt;i&gt;will&lt;/i&gt; be put to unforeseen uses 
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Differences from object-oriented programming
&lt;/h4&gt;
&lt;p&gt;
Proponents of &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming"&gt;object-oriented
programming&lt;/a&gt; (OOP) maintain that software should be written according to a mental
model of the actual or imagined objects it represents. OOP and the related disciplines
of &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_design"&gt;object-oriented design&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_analysis"&gt;object-oriented
analysis&lt;/a&gt; focus on modeling real-world&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed"&gt;citation
needed&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; interactions and attempting to create "verbs" and "nouns" which
can be used in intuitive&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed"&gt;citation
needed&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; ways, ideally by end users as well as by programmers coding
for those end users. 
&lt;p&gt;
Component-based software engineering, by contrast, makes no such assumptions, and
instead states that developers should construct software by gluing together prefabricated
components - much like in the fields of &lt;a href="http://en.wikipedia.org/wiki/Electronics"&gt;electronics&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Mechanics"&gt;mechanics&lt;/a&gt;.
Some peers&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words"&gt;who?&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; will
even talk of modularizing systems as software components as a new &lt;a href="http://en.wikipedia.org/wiki/Programming_paradigm"&gt;programming
paradigm&lt;/a&gt;. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;em&gt;&lt;strong&gt;&lt;font color="#0080ff"&gt;Component-based development (CBD) is an extension
of object-oriented programming. CBD does away with the language and vendor-specific
limitations of OOP, and makes software reuse more practical and accelerates the development
process. Event-based programming is the next logical step in CBD, and makes components
more reusable due to their decoupled nature. But event-based systems are easier to
develop, which means they are cheaper and more reliable than traditional OOP or CBD
systems.&lt;/font&gt;&lt;/strong&gt;&lt;/em&gt;&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=bc74545d-dbbc-4b34-bfd8-238e1e472dff" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</comments>
      <category>Design;Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=8de2cc59-7159-4e28-a5c9-4fe776be0782</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,8de2cc59-7159-4e28-a5c9-4fe776be0782.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,8de2cc59-7159-4e28-a5c9-4fe776be0782.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8de2cc59-7159-4e28-a5c9-4fe776be0782</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>
            <font size="2">(By Eric Evan)</font>
          </strong>
        </p>
        <p>
          <strong>
            <font size="2">Chapter 1 What Is Domain-Driven Design</font>
          </strong>
        </p>
        <p>
When we begin a software project, we should focus on the domain it is operating in.
The entire purpose of the software is to enhance a specific domain. 
</p>
        <p>
How can we make the software fit harmoniously with the domain? The best way to do
it is to make software a reflection of the domain.<br /></p>
        <p>
The model is our internal representation of the target domain, and it is very necessary
throughout the design and the development process.
</p>
        <p>
There are different approaches to software design. One is the waterfall design method.
This method involves a number of stages. The business experts put up a set of requirements
which are communicated to the business analysts. The analysts create a model based
on those requirements, and pass the results to the developers, who start coding based
on what they have received. It’s a one way flow of knowledge. While this has been
a traditional approach in software design, and has been used with a certain level
of success over the years, it has its flaws and limits. The main problem is that there
is no feedback from the analysts to the business experts or from the developers to
the analysts. Another approach is the Agile methodologies, such as Extreme Programming
(XP). These methodologies are a collective movement against the waterfall approach,
resulting from the difficulties of trying to come up with all the requirements upfront,
particularly in light of requirements change. It’s really hard to create a complete
model which covers all aspects of a domain upfront. It takes a lot of thinking, and
often you just cannot see all the issues involved from the beginning, nor can you
foresee some of the negative side effects or mistakes of your design. Another problem
Agile attempts to solve is the so called “analysis paralysis”, with team members so
afraid of making any design decisions that they make no progress at all. While Agile
advocates recognize the importance of design decision, they resist upfront design.
Instead they employ a great deal of implementation flexibility, and through iterative
development with continuous business stakeholder participation and a lot of refactoring,
the development team gets to learn more about the customer domain and can better produce
software that meets the customers needs. 
</p>
        <p>
  
</p>
        <p>
The Agile methods have their own problems and limitations; they advocate simplicity,
but everybody has their own view of what that means. Also, continuous refactoring
done by developers without solid design principles will produce code that is hard
to understand or change. And while the waterfall approach may lead to over-engineering,
the fear of overengineering may lead to another fear: the fear of doing a deep, thoroughly
thought out design. 
</p>
        <p>
  
</p>
        <p>
          <font size="2">
            <strong>Chapter 2 The Ubiquitous Language</strong>
          </font>
        </p>
        <p>
A core principle of domain-driven design is to use a language based on the model.
Since the model is the common ground, the place where the software meets the domain,
it is appropriate to use it as the building ground for this language. 
</p>
        <p>
Building a language like that has a clear outcome: the model and the language are
strongly interconnected with one another. A change in the language should become a
change to the model. 
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <font size="2">
            <strong>Chapter 3 Model-Driven Design</strong>
          </font>
        </p>
        <p>
A better approach is to closely relate domain modeling and design. The model should
be constructed with an eye open to the software and design considerations. Developers
should be included in the modeling process. 
</p>
        <p>
  
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb_2.png" width="792" height="564" />
          </a>
        </p>
        <p>
  
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_8.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb_3.png" width="735" height="420" />
          </a>
        </p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_10.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb_4.png" width="660" height="469" />
          </a>
        </p>
        <p>
  
</p>
        <p>
          <strong>Entities</strong>: There is a category of objects which seem to have an identity,
which remains the same throughout the states of the software. For these objects it
is not the attributes which matter, but a thread of continuity and identity, which
spans the life of a system and can extend beyond it. Such objects are called Entities. 
</p>
        <p>
  
</p>
        <p>
          <strong>Value Objects</strong>:  There are cases when we need to contain some
attributes of a domain element. We are not interested in which object it is, but what
attributes it has. An object that is used to describe certain aspects of a domain,
and which does not have identity, is named Value Object. 
</p>
        <p>
It is highly recommended that value objects be immutable.<br />
One golden rule is: if Value Objects are shareable, they should be immutable. Value
Objects should be kept thin and simple. When a Value Object is needed by another party,
it can be simply passed by value, or a copy of it can be created and given. 
</p>
        <p>
  
</p>
        <p>
          <strong>Services</strong>: 
</p>
        <p>
we discover that some aspects of the domain are not easily mapped to objects. 
But there are some actions in the domain, some verbs, which do not seem to belong
to any object. They represent an important behavior of the domain, so they cannot
be neglected or simply incorporated into some of the Entities or Value Objects. When
such a behavior is recognized in the domain, the best practice is to declare it as
a Service. Such an object does not have an internal state, and its purpose is to simply
provide functionality for the domain. The assistance provided by a Service can be
a significant one, and a Service can group related functionality which serves the
Entities and the Value Objects. 
</p>
        <p>
(For example, to transfer money from one account to another; should that function
be in the sending account or the receiving account? It feels just as misplaced in
either.) 
</p>
        <p>
There are three characteristics of a Service:<br />
1. The operation performed by the Service refers to a domain concept which does not
naturally belong to an Entity or Value<br />
Object.<br />
2. The operation performed refers to other objects in the domain.<br />
3. The operation is stateless. 
</p>
        <p>
  
</p>
        <p>
          <strong>Modules</strong>: it is necessary to organize the model into modules. Modules
are used as a method of organizing related concepts and tasks in order to reduce complexity. 
<br /></p>
        <p>
Another reason for using modules is related to code quality. It is widely accepted
that software code should have <strong>a high level of cohesion and a low level of
coupling</strong>.<br /></p>
        <p>
Two of the most used are <strong>communicational cohesion and functional cohesion</strong>. 
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <strong>Three patterns:  Aggregate is a domain pattern used to define object
ownership and boundaries. Factories and Repositories are two design patterns which
help us deal with object creation and storage.</strong>
        </p>
        <p>
  
</p>
        <p>
An <strong>Aggregate</strong> is a group of associated objects which are considered
as one unit with regard to data changes. 
</p>
        <p>
  
</p>
        <p>
The root is an Entity, and it is the only object accessible from outside. The root
can hold references to any of the aggregate objects, and the other objects can hold
references to each other, but an outside object can hold references only to the root
object. 
</p>
        <p>
Cluster the Entities and Value Objects into Aggregates and define boundaries around
each. Choose one Entity to be the root of each Aggregate, and control all access to
the objects inside the boundary through the root. Allow external objects to hold references
to the root only. Transient references to internal members can be passed out for use
within a single operation only. 
</p>
        <p>
  
</p>
        <p>
          <strong>Factories</strong> are used to encapsulate the knowledge necessary for object
creation, and they are especially useful to create Aggregates. When the root of the
Aggregate is created, all the objects contained by the Aggregate are created along
with it, and all the invariants are enforced.<br />
A Factory Method is an object method which contains and hides knowledge necessary
to create another object. 
</p>
        <p>
  
</p>
        <p>
There are times when a Factory is not needed, and a simple constructor is enough.
Use a constructor when:<br />
• The construction is not complicated.<br />
• The creation of an object does not involve the creation of others, and all the attributes
needed are passed via the constructor.<br />
• The client is interested in the implementation, perhaps wants to choose the Strategy
used.<br />
• The class is the type. There is no hierarchy involved, so no need to choose between
a list of concrete implementations. 
</p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
  
</p>
        <p>
Therefore, use a <strong>Repository</strong>, the purpose of which is to encapsulate
all the logic needed to obtain object references. 
</p>
        <p>
The overall effect is that the domain model is decoupled from the need of storing
objects or their references, and accessing the<br />
underlying persistence infrastructure. Provide repositories only for Aggregate roots
that actually need direct access. Keep the client focused on the model, delegating
all object storage and access to the Repositories. 
</p>
        <p>
  
</p>
        <p>
There is a relationship between Factory and Repository. They are both patterns of
the model-driven design, and they both help us to manage the life cycle of domain
objects. While the Factory is concerned with the creation of objects, the Repository
takes care of already existing objects. 
</p>
        <p>
  
</p>
        <p>
          <strong>
            <font size="2">Chapter 4 Refactoring Toward Deeper Insight</font>
          </strong>
        </p>
        <p>
          <strong>
            <font size="2">
            </font>
          </strong>  
</p>
        <p>
One of the first things we are taught about modeling is to read the business specifications
and look for nouns and verbs. The nouns are converted to classes, while the verbs
become methods. This is a simplification, and will lead to a <strong>shallow</strong> model. 
</p>
        <p>
We start with a coarse, shallow model. Then we refine it and the design based on deeper
knowledge about the domain, on a better understanding of the concerns. We add new
concepts and abstractions to it. The design is then refactored. Each refinement adds
more clarity to the design. This creates in turn the premises for a Breakthrough. 
</p>
        <p>
  
</p>
        <p>
To reach a Breakthrough, we need to make the implicit concepts explicit.<br /></p>
        <p>
The first way to discover implicit concepts is to listen to the language.<br /></p>
        <p>
Try to see if there is a missing concept. 
</p>
        <p>
  
</p>
        <p>
Another obvious way of digging out model concepts is to use domain literature. 
</p>
        <p>
  
</p>
        <p>
There are other concepts which are very useful when made explicit: Constraint, Process
and Specification.<br /></p>
        <p>
Placing the Constraint into a separate method has the advantage of making it explicit. 
<br />
Processes are usually expressed in code with procedures.<br />
Simply said, a Specification is used to test an object to see if it satisfies a certain
criteria. The domain layer contains business rules which are applied to Entities and
Value Objects. Those rules are usually incorporated into the objects they apply to.
When rule is not a simple method and spans many entities and value objects, 
the rule should be encapsulated into an object of its own, which becomes the Specification
of the Customer, and should be kept in the domain layer. 
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <strong>
            <font size="2">Chapter 5 Preserving Model Integrity</font>
          </strong>
        </p>
        <p>
  
</p>
        <p>
This chapter is about large projects which require the combined efforts of multiple
teams. 
</p>
        <p>
  
</p>
        <p>
Instead of trying to keep one big model that will fall apart later, we should consciously
divide it into several models. 
</p>
        <p>
Each model should have a clearly delimited border, and the relationships between models
should be defined with precision. 
</p>
        <p>
  
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb.png" width="731" height="381" />
          </a>
        </p>
        <p>
  
</p>
        <p>
A model should be small enough to be assigned to one team. 
</p>
        <p>
  
</p>
        <p>
          <strong>Bounded Context</strong>: The main idea is to define the scope of a model,
to draw up the boundaries of its context, then do the most possible to keep the model
unified.<br />
Explicitly set boundaries in terms of team organization, usage within specific parts
of the application, and physical manifestations such as code bases and database schemas.
Keep the model strictly consistent within these bounds, but don’t be distracted or
confused by issues outside. 
</p>
        <p>
A Bounded Context is not a Module. A Bounded Context provides the logical frame inside
of which the model evolves. Modules are used to organize the elements of a model,
so Bounded Context encompasses the Module. 
</p>
        <p>
  
</p>
        <p>
A <strong>Context Map</strong> is a document which outlines the different Bounded
Contexts and the relationships between them. What it is important is that everyone
working on the project shares and understands it. 
</p>
        <p>
  
</p>
        <p>
A common practice is to define the contexts, then create modules for each context,
and use a naming convention to indicate the context each module belongs to. 
</p>
        <p>
  
</p>
        <p>
The purpose of the Shared Kernel is to reduce duplication, but still keep two separate
contexts. 
</p>
        <p>
  
</p>
        <p>
          <strong>Core Domain and Generic Subdomain</strong>
        </p>
        <p>
          <strong>
          </strong>  
</p>
        <p>
          <strong>
            <font size="3">Last Chapter</font>
          </strong>
        </p>
        <p>
  
</p>
        <p>
Keep in mind some of the pitfalls of domain modeling:<br />
1) Stay hands-on. Modelers need to code.<br />
2) Focus on concrete scenarios. Abstract thinking has to be anchored in concrete cases.<br />
3) Don't try to apply DDD to everything. Draw a context map and decide on where you
will make a push for DDD and where you will not. And then don't worry about it outside
those boundaries.<br />
4) Experiment a lot and expect to make lots of mistakes. Modeling is a creative process. <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=8de2cc59-7159-4e28-a5c9-4fe776be0782" /></p>
      </body>
      <title>Domain Drive Design Quickly &amp;ndash; book review</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,8de2cc59-7159-4e28-a5c9-4fe776be0782.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,8de2cc59-7159-4e28-a5c9-4fe776be0782.aspx</link>
      <pubDate>Mon, 25 Jan 2010 21:54:21 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;&lt;font size="2"&gt;(By Eric Evan)&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font size="2"&gt;Chapter 1 What Is Domain-Driven Design&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
When we begin a software project, we should focus on the domain it is operating in.
The entire purpose of the software is to enhance a specific domain. 
&lt;p&gt;
How can we make the software fit harmoniously with the domain? The best way to do
it is to make software a reflection of the domain.&lt;br&gt;
&lt;p&gt;
The model is our internal representation of the target domain, and it is very necessary
throughout the design and the development process.
&lt;/p&gt;
&lt;p&gt;
There are different approaches to software design. One is the waterfall design method.
This method involves a number of stages. The business experts put up a set of requirements
which are communicated to the business analysts. The analysts create a model based
on those requirements, and pass the results to the developers, who start coding based
on what they have received. It’s a one way flow of knowledge. While this has been
a traditional approach in software design, and has been used with a certain level
of success over the years, it has its flaws and limits. The main problem is that there
is no feedback from the analysts to the business experts or from the developers to
the analysts. Another approach is the Agile methodologies, such as Extreme Programming
(XP). These methodologies are a collective movement against the waterfall approach,
resulting from the difficulties of trying to come up with all the requirements upfront,
particularly in light of requirements change. It’s really hard to create a complete
model which covers all aspects of a domain upfront. It takes a lot of thinking, and
often you just cannot see all the issues involved from the beginning, nor can you
foresee some of the negative side effects or mistakes of your design. Another problem
Agile attempts to solve is the so called “analysis paralysis”, with team members so
afraid of making any design decisions that they make no progress at all. While Agile
advocates recognize the importance of design decision, they resist upfront design.
Instead they employ a great deal of implementation flexibility, and through iterative
development with continuous business stakeholder participation and a lot of refactoring,
the development team gets to learn more about the customer domain and can better produce
software that meets the customers needs. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
The Agile methods have their own problems and limitations; they advocate simplicity,
but everybody has their own view of what that means. Also, continuous refactoring
done by developers without solid design principles will produce code that is hard
to understand or change. And while the waterfall approach may lead to over-engineering,
the fear of overengineering may lead to another fear: the fear of doing a deep, thoroughly
thought out design. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;font size="2"&gt;&lt;strong&gt;Chapter 2 The Ubiquitous Language&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
A core principle of domain-driven design is to use a language based on the model.
Since the model is the common ground, the place where the software meets the domain,
it is appropriate to use it as the building ground for this language. 
&lt;p&gt;
Building a language like that has a clear outcome: the model and the language are
strongly interconnected with one another. A change in the language should become a
change to the model. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;font size="2"&gt;&lt;strong&gt;Chapter 3 Model-Driven Design&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
A better approach is to closely relate domain modeling and design. The model should
be constructed with an eye open to the software and design considerations. Developers
should be included in the modeling process. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb_2.png" width="792" height="564"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb_3.png" width="735" height="420"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_10.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb_4.png" width="660" height="469"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Entities&lt;/strong&gt;: There is a category of objects which seem to have an identity,
which remains the same throughout the states of the software. For these objects it
is not the attributes which matter, but a thread of continuity and identity, which
spans the life of a system and can extend beyond it. Such objects are called Entities. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Value Objects&lt;/strong&gt;:&amp;nbsp; There are cases when we need to contain some
attributes of a domain element. We are not interested in which object it is, but what
attributes it has. An object that is used to describe certain aspects of a domain,
and which does not have identity, is named Value Object. 
&lt;p&gt;
It is highly recommended that value objects be immutable.&lt;br&gt;
One golden rule is: if Value Objects are shareable, they should be immutable. Value
Objects should be kept thin and simple. When a Value Object is needed by another party,
it can be simply passed by value, or a copy of it can be created and given. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Services&lt;/strong&gt;: 
&lt;p&gt;
we discover that some aspects of the domain are not easily mapped to objects.&amp;nbsp;
But there are some actions in the domain, some verbs, which do not seem to belong
to any object. They represent an important behavior of the domain, so they cannot
be neglected or simply incorporated into some of the Entities or Value Objects. When
such a behavior is recognized in the domain, the best practice is to declare it as
a Service. Such an object does not have an internal state, and its purpose is to simply
provide functionality for the domain. The assistance provided by a Service can be
a significant one, and a Service can group related functionality which serves the
Entities and the Value Objects. 
&lt;p&gt;
(For example, to transfer money from one account to another; should that function
be in the sending account or the receiving account? It feels just as misplaced in
either.) 
&lt;p&gt;
There are three characteristics of a Service:&lt;br&gt;
1. The operation performed by the Service refers to a domain concept which does not
naturally belong to an Entity or Value&lt;br&gt;
Object.&lt;br&gt;
2. The operation performed refers to other objects in the domain.&lt;br&gt;
3. The operation is stateless. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Modules&lt;/strong&gt;: it is necessary to organize the model into modules. Modules
are used as a method of organizing related concepts and tasks in order to reduce complexity. 
&lt;br&gt;
&lt;p&gt;
Another reason for using modules is related to code quality. It is widely accepted
that software code should have &lt;strong&gt;a high level of cohesion and a low level of
coupling&lt;/strong&gt;.&lt;br&gt;
&lt;p&gt;
Two of the most used are &lt;strong&gt;communicational cohesion and functional cohesion&lt;/strong&gt;. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Three patterns:&amp;nbsp; Aggregate is a domain pattern used to define object
ownership and boundaries. Factories and Repositories are two design patterns which
help us deal with object creation and storage.&lt;/strong&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
An &lt;strong&gt;Aggregate&lt;/strong&gt; is a group of associated objects which are considered
as one unit with regard to data changes. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
The root is an Entity, and it is the only object accessible from outside. The root
can hold references to any of the aggregate objects, and the other objects can hold
references to each other, but an outside object can hold references only to the root
object. 
&lt;p&gt;
Cluster the Entities and Value Objects into Aggregates and define boundaries around
each. Choose one Entity to be the root of each Aggregate, and control all access to
the objects inside the boundary through the root. Allow external objects to hold references
to the root only. Transient references to internal members can be passed out for use
within a single operation only. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Factories&lt;/strong&gt; are used to encapsulate the knowledge necessary for object
creation, and they are especially useful to create Aggregates. When the root of the
Aggregate is created, all the objects contained by the Aggregate are created along
with it, and all the invariants are enforced.&lt;br&gt;
A Factory Method is an object method which contains and hides knowledge necessary
to create another object. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
There are times when a Factory is not needed, and a simple constructor is enough.
Use a constructor when:&lt;br&gt;
• The construction is not complicated.&lt;br&gt;
• The creation of an object does not involve the creation of others, and all the attributes
needed are passed via the constructor.&lt;br&gt;
• The client is interested in the implementation, perhaps wants to choose the Strategy
used.&lt;br&gt;
• The class is the type. There is no hierarchy involved, so no need to choose between
a list of concrete implementations. 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Therefore, use a &lt;strong&gt;Repository&lt;/strong&gt;, the purpose of which is to encapsulate
all the logic needed to obtain object references. 
&lt;p&gt;
The overall effect is that the domain model is decoupled from the need of storing
objects or their references, and accessing the&lt;br&gt;
underlying persistence infrastructure. Provide repositories only for Aggregate roots
that actually need direct access. Keep the client focused on the model, delegating
all object storage and access to the Repositories. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
There is a relationship between Factory and Repository. They are both patterns of
the model-driven design, and they both help us to manage the life cycle of domain
objects. While the Factory is concerned with the creation of objects, the Repository
takes care of already existing objects. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;&lt;font size="2"&gt;Chapter 4 Refactoring Toward Deeper Insight&lt;/font&gt;&lt;/strong&gt; 
&lt;p&gt;
&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp; 
&lt;p&gt;
One of the first things we are taught about modeling is to read the business specifications
and look for nouns and verbs. The nouns are converted to classes, while the verbs
become methods. This is a simplification, and will lead to a &lt;strong&gt;shallow&lt;/strong&gt; model. 
&lt;p&gt;
We start with a coarse, shallow model. Then we refine it and the design based on deeper
knowledge about the domain, on a better understanding of the concerns. We add new
concepts and abstractions to it. The design is then refactored. Each refinement adds
more clarity to the design. This creates in turn the premises for a Breakthrough. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
To reach a Breakthrough, we need to make the implicit concepts explicit.&lt;br&gt;
&lt;p&gt;
The first way to discover implicit concepts is to listen to the language.&lt;br&gt;
&lt;p&gt;
Try to see if there is a missing concept. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Another obvious way of digging out model concepts is to use domain literature. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
There are other concepts which are very useful when made explicit: Constraint, Process
and Specification.&lt;br&gt;
&lt;p&gt;
Placing the Constraint into a separate method has the advantage of making it explicit. 
&lt;br&gt;
Processes are usually expressed in code with procedures.&lt;br&gt;
Simply said, a Specification is used to test an object to see if it satisfies a certain
criteria. The domain layer contains business rules which are applied to Entities and
Value Objects. Those rules are usually incorporated into the objects they apply to.
When rule is not a simple method and spans many entities and value objects,&amp;nbsp;
the rule should be encapsulated into an object of its own, which becomes the Specification
of the Customer, and should be kept in the domain layer. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;&lt;font size="2"&gt;Chapter 5 Preserving Model Integrity&lt;/font&gt;&lt;/strong&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
This chapter is about large projects which require the combined efforts of multiple
teams. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Instead of trying to keep one big model that will fall apart later, we should consciously
divide it into several models. 
&lt;p&gt;
Each model should have a clearly delimited border, and the relationships between models
should be defined with precision. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/DomainDriveDesign_EE07/image_thumb.png" width="731" height="381"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
A model should be small enough to be assigned to one team. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Bounded Context&lt;/strong&gt;: The main idea is to define the scope of a model,
to draw up the boundaries of its context, then do the most possible to keep the model
unified.&lt;br&gt;
Explicitly set boundaries in terms of team organization, usage within specific parts
of the application, and physical manifestations such as code bases and database schemas.
Keep the model strictly consistent within these bounds, but don’t be distracted or
confused by issues outside. 
&lt;p&gt;
A Bounded Context is not a Module. A Bounded Context provides the logical frame inside
of which the model evolves. Modules are used to organize the elements of a model,
so Bounded Context encompasses the Module. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
A &lt;strong&gt;Context Map&lt;/strong&gt; is a document which outlines the different Bounded
Contexts and the relationships between them. What it is important is that everyone
working on the project shares and understands it. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
A common practice is to define the contexts, then create modules for each context,
and use a naming convention to indicate the context each module belongs to. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
The purpose of the Shared Kernel is to reduce duplication, but still keep two separate
contexts. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Core Domain and Generic Subdomain&lt;/strong&gt; 
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;&lt;font size="3"&gt;Last Chapter&lt;/font&gt;&lt;/strong&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Keep in mind some of the pitfalls of domain modeling:&lt;br&gt;
1) Stay hands-on. Modelers need to code.&lt;br&gt;
2) Focus on concrete scenarios. Abstract thinking has to be anchored in concrete cases.&lt;br&gt;
3) Don't try to apply DDD to everything. Draw a context map and decide on where you
will make a push for DDD and where you will not. And then don't worry about it outside
those boundaries.&lt;br&gt;
4) Experiment a lot and expect to make lots of mistakes. Modeling is a creative process. &lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=8de2cc59-7159-4e28-a5c9-4fe776be0782" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,8de2cc59-7159-4e28-a5c9-4fe776be0782.aspx</comments>
      <category>Design;DotNet</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=b79a6ad1-c5e0-4ce5-9156-9a5c86f389df</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,b79a6ad1-c5e0-4ce5-9156-9a5c86f389df.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,b79a6ad1-c5e0-4ce5-9156-9a5c86f389df.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=b79a6ad1-c5e0-4ce5-9156-9a5c86f389df</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
(IOC) Inversion of Control
</p>
        <p>
          <a title="http://www.martinfowler.com/articles/injection.html" href="http://www.martinfowler.com/articles/injection.html">http://www.martinfowler.com/articles/injection.html</a>
        </p>
        <p>
Reduce dependency
</p>
        <p>
          <a title="http://weblogs.asp.net/sfeldman/archive/2008/02/14/understanding-ioc-container.aspx" href="http://weblogs.asp.net/sfeldman/archive/2008/02/14/understanding-ioc-container.aspx">http://weblogs.asp.net/sfeldman/archive/2008/02/14/understanding-ioc-container.aspx</a>
        </p>
        <p>
          <a title="http://weblogs.asp.net/sfeldman/archive/2008/02/20/understanding-ioc-container-part-2.aspx" href="http://weblogs.asp.net/sfeldman/archive/2008/02/20/understanding-ioc-container-part-2.aspx">http://weblogs.asp.net/sfeldman/archive/2008/02/20/understanding-ioc-container-part-2.aspx</a>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=b79a6ad1-c5e0-4ce5-9156-9a5c86f389df" />
      </body>
      <title>understanding IoC Container</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,b79a6ad1-c5e0-4ce5-9156-9a5c86f389df.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,b79a6ad1-c5e0-4ce5-9156-9a5c86f389df.aspx</link>
      <pubDate>Mon, 21 Apr 2008 21:16:49 GMT</pubDate>
      <description>&lt;p&gt;
(IOC) Inversion of Control
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.martinfowler.com/articles/injection.html" href="http://www.martinfowler.com/articles/injection.html"&gt;http://www.martinfowler.com/articles/injection.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Reduce dependency
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://weblogs.asp.net/sfeldman/archive/2008/02/14/understanding-ioc-container.aspx" href="http://weblogs.asp.net/sfeldman/archive/2008/02/14/understanding-ioc-container.aspx"&gt;http://weblogs.asp.net/sfeldman/archive/2008/02/14/understanding-ioc-container.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://weblogs.asp.net/sfeldman/archive/2008/02/20/understanding-ioc-container-part-2.aspx" href="http://weblogs.asp.net/sfeldman/archive/2008/02/20/understanding-ioc-container-part-2.aspx"&gt;http://weblogs.asp.net/sfeldman/archive/2008/02/20/understanding-ioc-container-part-2.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=b79a6ad1-c5e0-4ce5-9156-9a5c86f389df" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,b79a6ad1-c5e0-4ce5-9156-9a5c86f389df.aspx</comments>
      <category>Design;DotNet</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=5e4513eb-3c94-471c-93ad-7d86a88f5166</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,5e4513eb-3c94-471c-93ad-7d86a88f5166.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,5e4513eb-3c94-471c-93ad-7d86a88f5166.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5e4513eb-3c94-471c-93ad-7d86a88f5166</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://designinginterfaces.com/About_the_Book" href="http://designinginterfaces.com/About_the_Book">http://designinginterfaces.com/About_the_Book</a>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=5e4513eb-3c94-471c-93ad-7d86a88f5166" />
      </body>
      <title>Good Book: Designing Interfaces</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,5e4513eb-3c94-471c-93ad-7d86a88f5166.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,5e4513eb-3c94-471c-93ad-7d86a88f5166.aspx</link>
      <pubDate>Tue, 08 Apr 2008 15:00:57 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://designinginterfaces.com/About_the_Book" href="http://designinginterfaces.com/About_the_Book"&gt;http://designinginterfaces.com/About_the_Book&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=5e4513eb-3c94-471c-93ad-7d86a88f5166" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,5e4513eb-3c94-471c-93ad-7d86a88f5166.aspx</comments>
      <category>Design;Research</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=36c80db1-e931-424a-9436-5772722d1a81</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,36c80db1-e931-424a-9436-5772722d1a81.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,36c80db1-e931-424a-9436-5772722d1a81.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=36c80db1-e931-424a-9436-5772722d1a81</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp</a>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=36c80db1-e931-424a-9436-5772722d1a81" />
      </body>
      <title>Design Guidelines for Class Library Developers</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,36c80db1-e931-424a-9436-5772722d1a81.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,36c80db1-e931-424a-9436-5772722d1a81.aspx</link>
      <pubDate>Mon, 07 Jan 2008 23:00:58 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=36c80db1-e931-424a-9436-5772722d1a81" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,36c80db1-e931-424a-9436-5772722d1a81.aspx</comments>
      <category>Design</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=0af73610-aa9e-4251-b84f-bf5ced6fcf60</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,0af73610-aa9e-4251-b84f-bf5ced6fcf60.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,0af73610-aa9e-4251-b84f-bf5ced6fcf60.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0af73610-aa9e-4251-b84f-bf5ced6fcf60</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://www.cnblogs.com/blusehuang/archive/2007/10/17/926802.html" href="http://www.cnblogs.com/blusehuang/archive/2007/10/17/926802.html">http://www.cnblogs.com/blusehuang/archive/2007/10/17/926802.html</a>
        </p>
        <p>
 
</p>
        <p>
          <a href="http://www.cnblogs.com/images/cnblogs_com/blusehuang/WindowsLiveWriter/eb68a8cfaa29_10951/image_2.png">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="387" alt="image" src="http://www.cnblogs.com/images/cnblogs_com/blusehuang/WindowsLiveWriter/eb68a8cfaa29_10951/image_thumb.png" width="430" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=0af73610-aa9e-4251-b84f-bf5ced6fcf60" />
      </body>
      <title>Agile programming core</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,0af73610-aa9e-4251-b84f-bf5ced6fcf60.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,0af73610-aa9e-4251-b84f-bf5ced6fcf60.aspx</link>
      <pubDate>Tue, 16 Oct 2007 20:20:11 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://www.cnblogs.com/blusehuang/archive/2007/10/17/926802.html" href="http://www.cnblogs.com/blusehuang/archive/2007/10/17/926802.html"&gt;http://www.cnblogs.com/blusehuang/archive/2007/10/17/926802.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.cnblogs.com/images/cnblogs_com/blusehuang/WindowsLiveWriter/eb68a8cfaa29_10951/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="387" alt="image" src="http://www.cnblogs.com/images/cnblogs_com/blusehuang/WindowsLiveWriter/eb68a8cfaa29_10951/image_thumb.png" width="430" border="0"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=0af73610-aa9e-4251-b84f-bf5ced6fcf60" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,0af73610-aa9e-4251-b84f-bf5ced6fcf60.aspx</comments>
      <category>Design</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=15e1fecd-0352-4268-9cf9-a31e1cf035e4</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,15e1fecd-0352-4268-9cf9-a31e1cf035e4.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,15e1fecd-0352-4268-9cf9-a31e1cf035e4.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=15e1fecd-0352-4268-9cf9-a31e1cf035e4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h2>
          <u>Chapter 1:</u>
        </h2>
        <p>
There are three legs that hold up every implementation of empirical process control: <strong><i>visibility</i>, <i>inspection</i>,
and <i>adaptation</i>.</strong></p>
        <p>
I've limited my enumeration of complexity in software development to the three most
significant dimensions: <strong>requirements, technology, and people.</strong></p>
        <p>
          <a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_2.png" atomicselection="true">
            <img height="311" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_2.png" width="508" />
          </a>
        </p>
        <p>
The skeleton operates this way: At the start of an iteration, the team reviews what
it must do. It then selects what it believes it can turn into an increment of potentially
shippable functionality by the end of the iteration. The team is then left alone to
make its best effort for the rest of the iteration. At the end of the iteration, the
team presents the increment of functionality it built so that the stakeholders can
inspect the functionality and timely adaptations to the project can be made. 
</p>
        <p>
The heart of Scrum lies in the iteration. The team takes a look at the requirements,
considers the available technology, and evaluates its own skills and capabilities.
It then collectively determines how to build the functionality, modifying its approach
daily as it encounters new complexities, difficulties, and surprises. The team figures
out what needs to be done and selects the best way to do it. This creative process
is the heart of the Scrum's productivity. 
</p>
        <p>
There are only three Scrum roles: <strong>the Product Owner, the Team, and the ScrumMaster.           </strong><strong>"Ham
and Eggs!"</strong></p>
        <p>
 
</p>
        <strong>
        </strong>
        <p>
          <a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_1.png" atomicselection="true">
            <img height="623" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_1.png" width="815" />
          </a>
        </p>
        <ol>
          <li>
            <strong>Monthly Sprint planning meeting</strong>
          </li>
          <li>
            <strong>Daily Scrum meeting </strong>
          </li>
          <li>
            <strong>monthly Sprint review meeting</strong>
          </li>
          <li>
            <strong>Sprint retrospective meeting</strong>
          </li>
        </ol>
        <p>
          <strong>
            <a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_3.png" atomicselection="true">
              <img height="676" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_3.png" width="765" />
            </a>
          </strong>
        </p>
        <p>
          <strong>
          </strong> 
</p>
        <p>
          <a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_4.png" atomicselection="true">
            <img height="399" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_4.png" width="547" />
          </a>
        </p>
        <p>
          <strong>
            <a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_5.png" atomicselection="true">
              <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="813" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_5.png" width="767" border="0" />
            </a>
          </strong>
        </p>
        <p>
Tasks should be divided so that each takes roughly 4 to 16 hours to finish. Tasks
longer than 4 to 16 hours are considered mere placeholders for tasks that haven't
yet been appropriately defined.
</p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=15e1fecd-0352-4268-9cf9-a31e1cf035e4" />
      </body>
      <title>Chapter1: Reading Notes of &amp;lt;&amp;lt;Agile Project Management with Scrum &amp;gt;&amp;gt;</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,15e1fecd-0352-4268-9cf9-a31e1cf035e4.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,15e1fecd-0352-4268-9cf9-a31e1cf035e4.aspx</link>
      <pubDate>Mon, 15 Oct 2007 22:20:32 GMT</pubDate>
      <description>&lt;h2&gt;&lt;u&gt;Chapter 1:&lt;/u&gt;
&lt;/h2&gt;
&lt;p&gt;
There are three legs that hold up every implementation of empirical process control: &lt;strong&gt;&lt;i&gt;visibility&lt;/i&gt;, &lt;i&gt;inspection&lt;/i&gt;,
and &lt;i&gt;adaptation&lt;/i&gt;.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I've limited my enumeration of complexity in software development to the three most
significant dimensions: &lt;strong&gt;requirements, technology, and people.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_2.png" atomicselection="true"&gt;&lt;img height="311" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_2.png" width="508"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The skeleton operates this way: At the start of an iteration, the team reviews what
it must do. It then selects what it believes it can turn into an increment of potentially
shippable functionality by the end of the iteration. The team is then left alone to
make its best effort for the rest of the iteration. At the end of the iteration, the
team presents the increment of functionality it built so that the stakeholders can
inspect the functionality and timely adaptations to the project can be made. 
&lt;p&gt;
The heart of Scrum lies in the iteration. The team takes a look at the requirements,
considers the available technology, and evaluates its own skills and capabilities.
It then collectively determines how to build the functionality, modifying its approach
daily as it encounters new complexities, difficulties, and surprises. The team figures
out what needs to be done and selects the best way to do it. This creative process
is the heart of the Scrum's productivity. 
&lt;p&gt;
There are only three Scrum roles: &lt;strong&gt;the Product Owner, the Team, and the ScrumMaster.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/strong&gt;&lt;strong&gt;"Ham
and Eggs!"&lt;/strong&gt; 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;strong&gt;&lt;/strong&gt; 
&lt;p&gt;
&lt;a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_1.png" atomicselection="true"&gt;&lt;img height="623" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_1.png" width="815"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Monthly Sprint planning meeting&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Daily Scrum meeting &lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;monthly Sprint review meeting&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sprint retrospective meeting&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_3.png" atomicselection="true"&gt;&lt;img height="676" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_3.png" width="765"&gt;&lt;/a&gt; &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_4.png" atomicselection="true"&gt;&lt;img height="399" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_4.png" width="547"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_5.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="813" alt="image" src="http://blog.lulutech.com/content/binary/WindowsLiveWriter/ReadingNotesofAgileProjectManagementwith_1013C/image_thumb_5.png" width="767" border="0"&gt;&lt;/a&gt; &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Tasks should be divided so that each takes roughly 4 to 16 hours to finish. Tasks
longer than 4 to 16 hours are considered mere placeholders for tasks that haven't
yet been appropriately defined.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=15e1fecd-0352-4268-9cf9-a31e1cf035e4" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,15e1fecd-0352-4268-9cf9-a31e1cf035e4.aspx</comments>
      <category>Design;Design / Scrum</category>
    </item>
  </channel>
</rss>