<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: designpatterns code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 12:48:09 GMT</pubDate>
    <description>DZone Snippets: designpatterns code</description>
    <item>
      <title>MVP - Composition overview</title>
      <link>http://snippets.dzone.com/posts/show/2541</link>
      <description>Adapted from code supporting article at http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/default.aspx&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public partial class ViewCustomers : System.Web.UI.Page, IViewCustomerView&lt;br /&gt;{&lt;br /&gt;	private ViewCustomerPresenter presenter;&lt;br /&gt;&lt;br /&gt;	protected override void OnInit(EventArgs e)&lt;br /&gt;    	{&lt;br /&gt;        	base.OnInit(e);&lt;br /&gt;        	presenter = new ViewCustomerPresenter(this);&lt;br /&gt;        	this.customerDropDownList.SelectedIndexChanged += delegate&lt;br /&gt;                                                                  {&lt;br /&gt;                                                                  	presenter.DisplayCustomerDetails();&lt;br /&gt;                                                              	  };&lt;br /&gt;    	}&lt;br /&gt;&lt;br /&gt;	// ...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class ViewCustomerPresenter&lt;br /&gt;{&lt;br /&gt;	private readonly IViewCustomerView view;&lt;br /&gt;	private readonly ICustomerTask task;&lt;br /&gt;&lt;br /&gt;	public ViewCustomerPresenter(IViewCustomerView view) : this(view, new CustomerTask()) {}&lt;br /&gt;&lt;br /&gt;        public ViewCustomerPresenter(IViewCustomerView view, ICustomerTask task)&lt;br /&gt;        {&lt;br /&gt;            this.view = view;&lt;br /&gt;            this.task = task;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void DisplayCustomerDetails()&lt;br /&gt;        {&lt;br /&gt;            int? customerId = SelectedCustomerId;&lt;br /&gt;&lt;br /&gt;            if (customerId.HasValue)&lt;br /&gt;            {&lt;br /&gt;                CustomerDTO customer = task.GetDetailsForCustomer(customerId.Value);&lt;br /&gt;                UpdateViewFrom(customer);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void UpdateViewFrom(CustomerDTO customer)&lt;br /&gt;        {&lt;br /&gt;            view.CompanyName = customer.CompanyName;&lt;br /&gt;            view.ContactName = customer.ContactName;&lt;br /&gt;            view.ContactTitle = customer.ContactTitle;&lt;br /&gt;            view.Address = customer.Address;&lt;br /&gt;            view.City = customer.City;&lt;br /&gt;            view.Region = customer.Region;&lt;br /&gt;            view.Country = customer.CountryOfResidence.Name;&lt;br /&gt;            view.Phone = customer.Phone;&lt;br /&gt;            view.Fax = customer.Fax;&lt;br /&gt;            view.PostalCode = customer.PostalCode;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;	// ...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class CustomerTask : ICustomerTask&lt;br /&gt;{&lt;br /&gt;	...&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 05 Sep 2006 01:22:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2541</guid>
      <author>hjnntaao (hjnntaao)</author>
    </item>
    <item>
      <title>Domain object interface</title>
      <link>http://snippets.dzone.com/posts/show/2534</link>
      <description>&lt;code&gt;&lt;br /&gt;public interface IDomainObject&lt;br /&gt;{             &lt;br /&gt;    int Id{get;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 05 Sep 2006 00:51:43 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2534</guid>
      <author>hjnntaao (hjnntaao)</author>
    </item>
  </channel>
</rss>
