<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Working with Interfaces Part One &#8211; Contracts</title>
	<atom:link href="http://lostechies.com/colinramsay/2007/10/01/working-with-interfaces-part-one-contracts/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/colinramsay/2007/10/01/working-with-interfaces-part-one-contracts/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Wed, 27 May 2009 23:01:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Jason Meridth</title>
		<link>http://lostechies.com/colinramsay/2007/10/01/working-with-interfaces-part-one-contracts/#comment-16</link>
		<dc:creator>Jason Meridth</dc:creator>
		<pubDate>Tue, 02 Oct 2007 12:50:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/colin_ramsay/archive/2007/10/01/working-with-interfaces-part-one-contracts.aspx#comment-16</guid>
		<description>I&#039;ve used Model View Presenter in the last couple years for my Forms and it can become very hairy fast if you have &quot;base&quot; forms (inheritence).  What interfaces allow you to do is ensure the contract is being fulfilled, but the other benefit is mocking.  You are able to make your form implement IView for example and mock that and therefore unit test your UI.  There are qwerks with doing that in ASP.NET, but the best (reading) example is in the &quot;Agile Patterns, Patterns, and Practices in C#&quot; book by Robert and Micah Martin, Chapter 38 shows the Model View Presenter in action. (beware, they refer to the UI as an interface also, so read carefully)  

Hope this helps.

Great post Colin.  I think interfaces can sometimes be hard to wrap your mind around.  Once a person has that &quot;aha&quot; moment, they will never turn back.

SIDE NOTE:  The only thing a degree in our field, unfortunately, will do is get your foot in the door for an interview (usually).  If you have a recruiter who actually reads the resumes and sees the the experience listed, everyone has a fighting chance.

I personally don&#039;t rate a developer on his education.  I base it on experience.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve used Model View Presenter in the last couple years for my Forms and it can become very hairy fast if you have &#8220;base&#8221; forms (inheritence).  What interfaces allow you to do is ensure the contract is being fulfilled, but the other benefit is mocking.  You are able to make your form implement IView for example and mock that and therefore unit test your UI.  There are qwerks with doing that in ASP.NET, but the best (reading) example is in the &#8220;Agile Patterns, Patterns, and Practices in C#&#8221; book by Robert and Micah Martin, Chapter 38 shows the Model View Presenter in action. (beware, they refer to the UI as an interface also, so read carefully)  </p>
<p>Hope this helps.</p>
<p>Great post Colin.  I think interfaces can sometimes be hard to wrap your mind around.  Once a person has that &#8220;aha&#8221; moment, they will never turn back.</p>
<p>SIDE NOTE:  The only thing a degree in our field, unfortunately, will do is get your foot in the door for an interview (usually).  If you have a recruiter who actually reads the resumes and sees the the experience listed, everyone has a fighting chance.</p>
<p>I personally don&#8217;t rate a developer on his education.  I base it on experience.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cramsay</title>
		<link>http://lostechies.com/colinramsay/2007/10/01/working-with-interfaces-part-one-contracts/#comment-15</link>
		<dc:creator>cramsay</dc:creator>
		<pubDate>Tue, 02 Oct 2007 08:33:57 +0000</pubDate>
		<guid isPermaLink="false">/blogs/colin_ramsay/archive/2007/10/01/working-with-interfaces-part-one-contracts.aspx#comment-15</guid>
		<description>No problem Sean, it can be a tricky topic initially so more examples are good!

Jamal: I think your example is pretty much why C# disallows multiple inheritance. Imagine what sort of a mess you could get in then!</description>
		<content:encoded><![CDATA[<p>No problem Sean, it can be a tricky topic initially so more examples are good!</p>
<p>Jamal: I think your example is pretty much why C# disallows multiple inheritance. Imagine what sort of a mess you could get in then!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Chambers</title>
		<link>http://lostechies.com/colinramsay/2007/10/01/working-with-interfaces-part-one-contracts/#comment-14</link>
		<dc:creator>Sean Chambers</dc:creator>
		<pubDate>Tue, 02 Oct 2007 01:54:06 +0000</pubDate>
		<guid isPermaLink="false">/blogs/colin_ramsay/archive/2007/10/01/working-with-interfaces-part-one-contracts.aspx#comment-14</guid>
		<description>Good post Colin! It will make for good conversation.

I am on the same path Colin. I have no degree, kind of stumbled into programming from web development and learned as I went, no mentor just myself reading books and asking for help in groups. As a result it took me awhile to fully leverage the power of interfaces. After using them for awhile now I don&#039;t see how I got on without them.

The best piece advice I can give everyone to help them with interfaces is first, the word &quot;Contract&quot;. It confused me alot at first but it made sense later because all the interface does is assure clients that said class can perform the interface operations.

Then to the next step of once you know that a class can do a certain set of methods, you can then swap out classes that otherwise have no relation to each other. If they did, you could use inheritance.

A prime example I just coded the other night. I had an interface called IAuthService. The interface has two methods:

bool Authenticate(string username, string password);
string[] GetGroupMembership(string username);

Now, there are two classes that implement this interface,
ActiveDirectoryAuthService : IAuthService
DatabaseAuthService : IAuthService

The consumer method would then be like so:
class Consumer
{
  public void DoWork(IAuthService myAuthService)
  {
    return myAuthService.Authenticate(&quot;un&quot;, &quot;pw&quot;);
  }
}

As you can see, I can now change the classes the consumer is using very easily, because the consumer doesn&#039;t care how the task is achieved, it just wants the task to be done.

Therein lies the power, loose coupling. Because no consumer knows about the intimate details of the AuthService class. Only how to interact with it.

Hopefully thats not too confusing. An example like that really helped me to see the light with interfaces when I first started using them.

Didn&#039;t mean to hijack your thread colin, just wanted to let everyone know what helped me see the light.

good post colin!</description>
		<content:encoded><![CDATA[<p>Good post Colin! It will make for good conversation.</p>
<p>I am on the same path Colin. I have no degree, kind of stumbled into programming from web development and learned as I went, no mentor just myself reading books and asking for help in groups. As a result it took me awhile to fully leverage the power of interfaces. After using them for awhile now I don&#8217;t see how I got on without them.</p>
<p>The best piece advice I can give everyone to help them with interfaces is first, the word &#8220;Contract&#8221;. It confused me alot at first but it made sense later because all the interface does is assure clients that said class can perform the interface operations.</p>
<p>Then to the next step of once you know that a class can do a certain set of methods, you can then swap out classes that otherwise have no relation to each other. If they did, you could use inheritance.</p>
<p>A prime example I just coded the other night. I had an interface called IAuthService. The interface has two methods:</p>
<p>bool Authenticate(string username, string password);<br />
string[] GetGroupMembership(string username);</p>
<p>Now, there are two classes that implement this interface,<br />
ActiveDirectoryAuthService : IAuthService<br />
DatabaseAuthService : IAuthService</p>
<p>The consumer method would then be like so:<br />
class Consumer<br />
{<br />
  public void DoWork(IAuthService myAuthService)<br />
  {<br />
    return myAuthService.Authenticate(&#8220;un&#8221;, &#8220;pw&#8221;);<br />
  }<br />
}</p>
<p>As you can see, I can now change the classes the consumer is using very easily, because the consumer doesn&#8217;t care how the task is achieved, it just wants the task to be done.</p>
<p>Therein lies the power, loose coupling. Because no consumer knows about the intimate details of the AuthService class. Only how to interact with it.</p>
<p>Hopefully thats not too confusing. An example like that really helped me to see the light with interfaces when I first started using them.</p>
<p>Didn&#8217;t mean to hijack your thread colin, just wanted to let everyone know what helped me see the light.</p>
<p>good post colin!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamal Hansen</title>
		<link>http://lostechies.com/colinramsay/2007/10/01/working-with-interfaces-part-one-contracts/#comment-13</link>
		<dc:creator>Jamal Hansen</dc:creator>
		<pubDate>Tue, 02 Oct 2007 00:26:35 +0000</pubDate>
		<guid isPermaLink="false">/blogs/colin_ramsay/archive/2007/10/01/working-with-interfaces-part-one-contracts.aspx#comment-13</guid>
		<description>When I started learning object oriented programming I was  enthralled by inheritence.  I used it as much as I could, and often when I didn&#039;t need to.  Often I would put some behavior in the ancestor that I later found that I didn&#039;t need in its descendants.  Then I&#039;d find myself overriding behavior, calling super and making a real mess of things.  Interfaces can be a nice alternative in these situations.  Allowing you to standardize certain aspects of behavior without going in for full blown inheritence.</description>
		<content:encoded><![CDATA[<p>When I started learning object oriented programming I was  enthralled by inheritence.  I used it as much as I could, and often when I didn&#8217;t need to.  Often I would put some behavior in the ancestor that I later found that I didn&#8217;t need in its descendants.  Then I&#8217;d find myself overriding behavior, calling super and making a real mess of things.  Interfaces can be a nice alternative in these situations.  Allowing you to standardize certain aspects of behavior without going in for full blown inheritence.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cramsay</title>
		<link>http://lostechies.com/colinramsay/2007/10/01/working-with-interfaces-part-one-contracts/#comment-12</link>
		<dc:creator>cramsay</dc:creator>
		<pubDate>Mon, 01 Oct 2007 21:35:03 +0000</pubDate>
		<guid isPermaLink="false">/blogs/colin_ramsay/archive/2007/10/01/working-with-interfaces-part-one-contracts.aspx#comment-12</guid>
		<description>I&#039;d really appreciate feedback (private &amp; public) on this one guys!</description>
		<content:encoded><![CDATA[<p>I&#8217;d really appreciate feedback (private &#038; public) on this one guys!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
