<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" media="screen" href="/App_Themes/default/rss.xslt"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" 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:media="http://search.yahoo.com/mrss/" xmlns:evnet="http://www.mscommunities.com/rssmodule/"><channel><title>Comment Feed for Interface + Extension Methods -- any improvement on abstract classes? (TechOff on Channel 9)</title><atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/forums/techoff/426863-interface--extension-methods-any-improvement-on-abstract-classes/rss/default.aspx" /><image><url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url><title>Comment Feed for Interface + Extension Methods -- any improvement on abstract classes? (TechOff on Channel 9)</title><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/</link></image><description>Interface + Extension Methods -- any improvement on abstract classes?</description><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/</link><language>en-us</language><pubDate>Fri, 20 Feb 2009 14:50:46 GMT</pubDate><lastBuildDate>Fri, 20 Feb 2009 14:50:46 GMT</lastBuildDate><generator>EvNet (EvNet, Version=1.0.3608.3122, Culture=neutral, PublicKeyToken=null)</generator><item><title>Re: Re: Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>Again my point is that you are talking about a language feature that makes up how the CLR works, extension methods are an abstraction in the written languages.. just happens that the main two languages agreed they both needed to support them.&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458177</link><pubDate>Fri, 20 Feb 2009 14:50:46 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458177</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/458177/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Again my point is that you are talking about a language feature that makes up how the CLR works, extension methods are an abstraction in the written languages.. just happens that the main two languages agreed they both needed to support them.</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/458177/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>&lt;P&gt;var ouch = Enumerable.Reverse(null); // What should happen here?&lt;BR&gt;&lt;BR&gt;That's fine, it's more the case of&lt;BR&gt;&lt;BR&gt;((IEnumerable&amp;lt;int&amp;gt;)null).Reverse() which is the problem. If Reverse is an instance method, it's immediately a NullReferenceException (since "." on anything that is null causes a NullReferenceException), but if it's a static type extention, it'll call "object Reverse(this IEnumerable&amp;lt;T&amp;gt; thisparam)) with thisparam = null, a breach of semantics.&lt;BR&gt;&lt;BR&gt;Frankly the compiler and runtime should collude in such a way that useing type-extentions forces an explicit null-check. If you're willing to call it in it's parameterised form Enumerable.Reverse(null) then it's just a null parameter, rather than a null "this" parameter.&lt;BR&gt;&lt;BR&gt;@stevo: you can think of all non-virtual&amp;nbsp;and non-interfaced&amp;nbsp;instance&amp;nbsp;methods as static helper functions if you want (that's how they are implemented after all). The fact that "." causes a NullReferenceException is because the runtime provides an explicit check. For fields and virtual methods the check is performed by the hardware, but the principle is the same. Only static helper methods break the semantic of allowing null on the left-hand-side of a ".".&lt;/P&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458163</link><pubDate>Fri, 20 Feb 2009 11:28:39 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458163</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/458163/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>var ouch = Enumerable.Reverse(null); // What should happen here?That's fine, it's more the case of((IEnumerable&amp;lt;int&amp;gt;)null).Reverse() which is the problem. If Reverse is an instance method, it's immediately a NullReferenceException (since "." on anything that is null causes a&amp;#8230;</evnet:previewtext><dc:creator>evildictaitor</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/458163/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>&lt;p&gt;A code example to illustrate in case anyone else following the thread is lost:&lt;/p&gt;
&lt;code&gt;var values = Enumerable.Range(1, 10);&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;var reversed = values.Reverse(); // Normal use case&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;var alsoReversed = Enumerable.Reverse(values); // Also possible&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;var ouch = Enumerable.Reverse(null); // What should happen here?&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;
&lt;p&gt;Maybe one day we'll get non-nullable reference types in C# and VB.NET and not have to worry about ArgumentNullExceptions and NullReferenceExceptions any more.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458159</link><pubDate>Fri, 20 Feb 2009 10:28:32 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458159</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/458159/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>A code example to illustrate in case anyone else following the thread is lost:
var values = Enumerable.Range(1, 10);
var reversed = values.Reverse(); // Normal use case
var alsoReversed = Enumerable.Reverse(values); // Also possible
var ouch = Enumerable.Reverse(null); // What should happen&amp;#8230;</evnet:previewtext><dc:creator>Joe Chung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/458159/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>Yes but this isn't a CLR feature, its just a feature that the&amp;nbsp;interpreted languages are encouraged to use, vb and c# compiler probably only&amp;nbsp;betray extension methods in CIL because they have attributes on them.. I always think of extension methods as being static helper classes when I'm calling them, despite the fact the compiler is making me think this isn't the case..&lt;BR&gt;&lt;BR&gt;Again I think this could go either way, I'd like to see some official advise, otherwise I'm going for the safe option of treating them as static helper methods.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458067</link><pubDate>Thu, 19 Feb 2009 11:35:51 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458067</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/458067/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Yes but this isn't a CLR feature, its just a feature that the&amp;nbsp;interpreted languages are encouraged to use, vb and c# compiler probably only&amp;nbsp;betray extension methods in CIL because they have attributes on them.. I always think of extension methods as being static helper classes when I'm&amp;#8230;</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/458067/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>I just do what I do with regular methods, throw an ArgumentNullException.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458061</link><pubDate>Thu, 19 Feb 2009 10:41:10 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458061</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/458061/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I just do what I do with regular methods, throw an ArgumentNullException.</evnet:previewtext><dc:creator>Sven Groot</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/458061/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>instance methods are effectively static methods with the LHS passed as a parameter "this". The reason the NullReferenceException is thrown is because the runtime checks (for virtual methods the hardware does it, for non-virtual ones the runtime does it). It's odd that they chose not to keep this system for extention methods, but in either case you shouldn't be relying on "special-cases" where the LHS is null, because the programmer should guarrantee it at the call site (at worst, Debug.Assert(thisParameter != null) )</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458057</link><pubDate>Thu, 19 Feb 2009 09:17:44 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=458057</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/458057/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>instance methods are effectively static methods with the LHS passed as a parameter "this". The reason the NullReferenceException is thrown is because the runtime checks (for virtual methods the hardware does it, for non-virtual ones the runtime does it). It's odd that they chose not to keep this&amp;#8230;</evnet:previewtext><dc:creator>evildictaitor</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/458057/Trackback.aspx</trackback:ping></item><item><title>Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>Sounds right because these are instance calls usually, but in reality they are just static helper classes, what happens if a language calls into them directly which doesn't support extension methods? what if you just call into them directly anyway? I wonder if they wrote any official guidelines for this.&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=457936</link><pubDate>Wed, 18 Feb 2009 16:14:09 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=457936</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/457936/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Sounds right because these are instance calls usually, but in reality they are just static helper classes, what happens if a language calls into them directly which doesn't support extension methods? what if you just call into them directly anyway? I wonder if they wrote any official guidelines for this.</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/457936/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>&lt;i&gt;Calling on null object ... hmm, I must add catches for that ...&lt;/i&gt;&lt;br&gt;&lt;br&gt;Why? Extention methods are intended to look like instance calls, which throw a NullReferenceException if the instance is null:&lt;br&gt;&lt;br&gt;object o = null;&lt;br&gt;string f = o.ToString();&amp;nbsp;&amp;nbsp; // throws a NullReferenceException at runtime, but not because Object::ToString() is checking.&lt;br&gt;&lt;br&gt;If you use extention methods, then by specifically coding for the null-case you're arguably breaking the semantics:&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IMyInterface item = null&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item.ExtensionMethod().SomeProperty = 5;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;is therefore an error at the call-site and not in the method. If you do code around it, be sure to throw a NullReferenceException, but if I were you I'd just leave it in a Debug.Assert() at the top of the method. In fact, if the method returned something at all, it would be breaking the semantics of object-calls.&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=457896</link><pubDate>Wed, 18 Feb 2009 11:15:09 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=457896</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/457896/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Calling on null object ... hmm, I must add catches for that ...Why? Extention methods are intended to look like instance calls, which throw a NullReferenceException if the instance is null:object o = null;string f = o.ToString();&amp;nbsp;&amp;nbsp; // throws a NullReferenceException at runtime, but not&amp;#8230;</evnet:previewtext><dc:creator>evildictaitor</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/457896/Trackback.aspx</trackback:ping></item><item><title>Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>this is totally what i hav been looking for. awesome!&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=457872</link><pubDate>Wed, 18 Feb 2009 06:36:16 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=457872</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/457872/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>this is totally what i hav been looking for. awesome!</evnet:previewtext><dc:creator>cottsak</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/457872/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>Yea thats certainly what I use it for most, removing the weight off interfaces (arguably interfaces shouldn't enforce the overloads, but then you have to have the callers all handle overload handling theirself which is beating DRY with a stick and asking for bugs).. the best way then would be to use a utility class to make the call for you, but then that ends up looking weird.. along come extension methods and make it look natural.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426938</link><pubDate>Wed, 10 Sep 2008 21:19:41 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426938</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426938/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Yea thats certainly what I use it for most, removing the weight off interfaces (arguably interfaces shouldn't enforce the overloads, but then you have to have the callers all handle overload handling theirself which is beating DRY with a stick and asking for bugs).. the best way then would be to use&amp;#8230;</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426938/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>A good example is providing convenience "overloads".  For example, there's talk about providing a build in service locator interface to the BCL.  One proposal was:
&lt;br /&gt;
[code language="csharp"]public interface IServiceLocator
{
   object GetInstance(Type type);
   T GetInstance&amp;lt;T&amp;gt;();
   object GetInstance(Type type, string name);
   T GetInstance&amp;lt;T&amp;gt;(string name);
   object[] GetAllInstances(Type type);
   T[] GetAllInstances&amp;lt;T&amp;gt;();
}[/code]
&lt;br /&gt;
That's a lot for a concrete type to define, though, when half the methods will always just defer implementation to the other methods.  Better to use extension methods, here.
&lt;br /&gt;
[code language="csharp"]public interface IServiceLocator
{
   object GetInstance(Type type);
   object GetInstance(Type type, string name);
   object[] GetAllIntances(Type type);
}
&lt;br /&gt;
public static class ServiceLocatorExtensions
{
   public static T GetInstance&amp;lt;T&amp;gt;(this IServiceLocator self)
   {
      return (T)self.GetInstance(typeof(T));
   }
   public static T GetInstance&amp;lt;T&amp;gt;(this IServiceLocator self, string name)
   {
      return (T)self.GetInstance(typeof(T), name);
   }
   public static T[] GetAllInstances&amp;lt;T&amp;gt;()
   {
      return self.GetAllInstances(typeof(T)).Cast&amp;lt;T&amp;gt;().ToArray();
   }
}[/code]
&lt;br&gt;
Wow, Chrome doesn't post the code tags very well.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426904</link><pubDate>Wed, 10 Sep 2008 16:05:35 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426904</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426904/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>A good example is providing convenience "overloads".  For example, there's talk about providing a build in service locator interface to the BCL.  One proposal was:

[code language="csharp"]public interface IServiceLocator
{
   object GetInstance(Type type);
   T GetInstance&amp;lt;T&amp;gt;();
  &amp;#8230;</evnet:previewtext><dc:creator>William Kempf</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426904/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>Various things, when designing new classes now I tend to cull the 'ugh' properties from interfaces and then let extensions handle them (although I wish they had extension properties as well).. but theres interesting things where you can do really clean systems for attaching values to objects, similar to how the attached properties work by the property value get and set really being routed to the static part of the dependent class.&lt;BR&gt;&lt;BR&gt;Mostly I just like how they let you avoid stressing interfaces with senseless 'overloads', you can write them as extension methods instead.. I know in the end these are just calls to helper classes that we could of done before, but the syntax for how they work is so much cleaner I'm much happier using them..&lt;BR&gt;&lt;BR&gt;Interesting thing I've seen the null thing used for - lazy patterns.&lt;BR&gt;&lt;BR&gt;Edit: The coolest lazy pattern I've seen is in the TPL though, they have a lazyinit class thats a struct (and so implicitely must construct), I thought that was clever..</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426889</link><pubDate>Wed, 10 Sep 2008 13:41:34 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426889</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426889/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Various things, when designing new classes now I tend to cull the 'ugh' properties from interfaces and then let extensions handle them (although I wish they had extension properties as well).. but theres interesting things where you can do really clean systems for attaching values to objects,&amp;#8230;</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426889/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>Calling on null object ... hmm, I must add catches for that ...&lt;BR&gt;&lt;BR&gt;I'm using the extensions for flow syntax methods to match the property setters&amp;nbsp;supported by the interface (because I want to support both), so the extension method ALWAYS calls the instance it's called on. I'm using it mainly for dependency injection:&lt;BR&gt;&lt;BR&gt;[code language="csharp"]&lt;BR&gt;IMyInterface instance = new Implementation&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.WithPreProcessor(new ConcretePreprocessor())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.WithPostProcessor(new ConcretePostProcessor());&lt;BR&gt;[/code]&lt;BR&gt;&lt;BR&gt;So what were you using them for, stevo_ ?&lt;BR&gt;&lt;BR&gt;Herbie&lt;BR&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426886</link><pubDate>Wed, 10 Sep 2008 13:31:50 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426886</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426886/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Calling on null object ... hmm, I must add catches for that ...I'm using the extensions for flow syntax methods to match the property setters&amp;nbsp;supported by the interface (because I want to support both), so the extension method ALWAYS calls the instance it's called on. I'm using it mainly for&amp;#8230;</evnet:previewtext><dc:creator>Herbie Smith</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426886/Trackback.aspx</trackback:ping></item><item><title>Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>&lt;A href="http://channel9.msdn.com/forums/TechOff/258761-Wow-extension-methods--interfaces/"&gt;http://channel9.msdn.com/forums/TechOff/258761-Wow-extension-methods--interfaces/&lt;/A&gt;&amp;nbsp;you all said I was crazy! (actually you all ignored me :()...&lt;BR&gt;&lt;BR&gt;But I use this pattern a lot, I think its great.. also using extension methods are interesting because you can obviously still call the methods even on null objects..</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426881</link><pubDate>Wed, 10 Sep 2008 13:17:21 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426881</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426881/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>http://channel9.msdn.com/forums/TechOff/258761-Wow-extension-methods--interfaces/&amp;nbsp;you all said I was crazy! (actually you all ignored me :()...But I use this pattern a lot, I think its great.. also using extension methods are interesting because you can obviously still call the methods even on null objects..</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426881/Trackback.aspx</trackback:ping></item><item><title>Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>I think interfaces are great for defining a &lt;em&gt;"looks like"&lt;/em&gt; or &lt;em&gt;"can do"&lt;/em&gt; relationship. An abstract base class is great for defining a &lt;em&gt;"is a kind of"&lt;/em&gt; relationship. A class can only be derived from 1 base class but can implement multiple interfaces.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426877</link><pubDate>Wed, 10 Sep 2008 13:00:39 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426877</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426877/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I think interfaces are great for defining a "looks like" or "can do" relationship. An abstract base class is great for defining a "is a kind of" relationship. A class can only be derived from 1 base class but can implement multiple interfaces.</evnet:previewtext><dc:creator>Tommy Carlier</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426877/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>Sorry,I completely mis-read your question - will be more careful in future,&lt;br&gt;Ant&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426867</link><pubDate>Wed, 10 Sep 2008 12:27:58 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426867</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426867/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Sorry,I completely mis-read your question - will be more careful in future,Ant</evnet:previewtext><dc:creator>AnthonyJohnston</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426867/Trackback.aspx</trackback:ping></item><item><title>Re: Interface + Extension Methods -- any improvement on abstract classes?</title><description>You can scope your extensions in our out eg&lt;br&gt;&lt;br&gt;namespace Sandbox.ExtensionMethods&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class Class1&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;namespace Sandbox.ExtensionMethods.ns2&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static class Extension&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void Extend2(this Class1 item)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;namespace Sandbox.ExtensionMethods.ns1&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static class Extension&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void Extend1(this Class1 item)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;now putting a using for the namespace to the corresponding extension it will be scoped in&lt;br&gt;&lt;br&gt;eg&lt;br&gt;&lt;br&gt;using Sandbox.ExtensionMethods.ns2;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class1 item = new Class1();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item.Extend2();&lt;br&gt;&lt;br&gt;Or&lt;br&gt;&lt;br&gt;&lt;br&gt;
using Sandbox.ExtensionMethods.ns1;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class1 item = new Class1();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item.Extend1();&lt;br&gt;
&lt;br&gt;not sure where you'd use it tho, :) Ant&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426865</link><pubDate>Wed, 10 Sep 2008 12:25:00 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/?CommentID=426865</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/426865/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>You can scope your extensions in our out egnamespace Sandbox.ExtensionMethods{&amp;nbsp;&amp;nbsp;&amp;nbsp; class Class1&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; }}namespace Sandbox.ExtensionMethods.ns2{&amp;nbsp;&amp;nbsp;&amp;nbsp; static class Extension&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&amp;#8230;</evnet:previewtext><dc:creator>AnthonyJohnston</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/426865/Trackback.aspx</trackback:ping></item></channel></rss>