Comments on: Extension Methods, Nulls, Namespaces and Precedence in C# http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/ Towards Intelligent Systems Wed, 11 Jul 2012 12:59:08 +0000 hourly 1 http://wordpress.org/?v=3.0.3 By: Paul Houle http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/comment-page-1/#comment-1720 Paul Houle Sun, 30 Nov 2008 17:09:47 +0000 http://gen5.info/q/?p=36#comment-1720 @ecards, one advantage of an extension methods is that the original class doesn't have to be "partial;" it can even be sealed. You can also put extension methods on an interface or on an enum. Extension methods were introduced to make LINQ possible: LINQ adds a large number of extension methods to classes that implement collection interfaces. @ecards,

one advantage of an extension methods is that the original class doesn’t have to be “partial;” it can even be sealed. You can also put extension methods on an interface or on an enum.

Extension methods were introduced to make LINQ possible: LINQ adds a large number of extension methods to classes that implement collection interfaces.

]]>
By: ecards http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/comment-page-1/#comment-1582 ecards Fri, 21 Nov 2008 02:26:54 +0000 http://gen5.info/q/?p=36#comment-1582 Nice article. But what I'm not clear on is what's the difference between: 1) adding an extension method foobar for class A 2) adding a method foobar to a partial class A I get the semantic differences like null checking, but there must be a more fundamental difference i'm missing... Nice article. But what I’m not clear on is what’s the difference between:
1) adding an extension method foobar for class A
2) adding a method foobar to a partial class A

I get the semantic differences like null checking, but there must be a more fundamental difference i’m missing…

]]>
By: Kaveh Shahbazian http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/comment-page-1/#comment-565 Kaveh Shahbazian Wed, 09 Jul 2008 22:08:47 +0000 http://gen5.info/q/?p=36#comment-565 I have found even crazier uses for extension methods (http://hcoding.blogspot.com/2008/07/foop.html)! I think separating the namespace for extension methods is enough for working safely with them. And the current design of extension methods is just for being usable in C# 2; that static class is totally un-necessary. I have found even crazier uses for extension methods (http://hcoding.blogspot.com/2008/07/foop.html)!
I think separating the namespace for extension methods is enough for working safely with them.
And the current design of extension methods is just for being usable in C# 2; that static class is totally un-necessary.

]]>
By: Jason Olson http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/comment-page-1/#comment-564 Jason Olson Wed, 09 Jul 2008 18:20:29 +0000 http://gen5.info/q/?p=36#comment-564 I think the concerns behind "writing bad code" being enabled by extension methods is the same concern that arrived with the introduction of partial classes. Yes, they can be abused, but they are also tremendously useful. There are two current reasons why I love extension methods: 1) enabling of fluent interfaces built on top of a "normal" canonical API and 2) a "poor man's" .NET version of monkey-patching from the Ruby world. So, for unit testing frameworks, instead of having code like "Assert.Equal(foo, bar);", I could have "foo.ShouldEqual(bar);" instead due to an extension method on object. I think the concerns behind “writing bad code” being enabled by extension methods is the same concern that arrived with the introduction of partial classes. Yes, they can be abused, but they are also tremendously useful.

There are two current reasons why I love extension methods: 1) enabling of fluent interfaces built on top of a “normal” canonical API and 2) a “poor man’s” .NET version of monkey-patching from the Ruby world. So, for unit testing frameworks, instead of having code like “Assert.Equal(foo, bar);”, I could have “foo.ShouldEqual(bar);” instead due to an extension method on object.

]]>
By: admin http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/comment-page-1/#comment-563 admin Wed, 09 Jul 2008 14:19:52 +0000 http://gen5.info/q/?p=36#comment-563 @Will, I'm with you. In my viewpoint, "sugar" is pretty important. Programmers spend a lot of our days doing little tasks again and again -- out of the box APIs often mean that we need to use 5 lines of code to do one line worth of work the 'obvious' way, and that we need 15 to do it the correct way. Extension methods are a great way to codify correct practices and put them on our fingertips -- so it's easier to do things right than to do things wrong. @Will,

I’m with you. In my viewpoint, “sugar” is pretty important. Programmers spend a lot of our days doing little tasks again and again — out of the box APIs often mean that we need to use 5 lines of code to do one line worth of work the ‘obvious’ way, and that we need 15 to do it the correct way.

Extension methods are a great way to codify correct practices and put them on our fingertips — so it’s easier to do things right than to do things wrong.

]]>
By: superjason http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/comment-page-1/#comment-562 superjason Wed, 09 Jul 2008 12:18:31 +0000 http://gen5.info/q/?p=36#comment-562 I wasn't aware of these. Thanks for putting this together. I wasn’t aware of these. Thanks for putting this together.

]]>
By: Will http://gen5.info/q/2008/07/03/extension-methods-nulls-namespaces-and-precedence-in-c/comment-page-1/#comment-561 Will Wed, 09 Jul 2008 11:51:54 +0000 http://gen5.info/q/?p=36#comment-561 I was reserved at first, because I was concerned that people would use extension methods for business logic rather than sugar. I haven't seen any examples of this kind of abuse yet, but I'm sure somebody is doing it somewhere. Extension methods: Good for sugar, bad for logic. I was reserved at first, because I was concerned that people would use extension methods for business logic rather than sugar. I haven’t seen any examples of this kind of abuse yet, but I’m sure somebody is doing it somewhere.

Extension methods: Good for sugar, bad for logic.

]]>

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /hosting/sites/gen5.info/htdocs/q/wp-includes/class-snoopy.php on line 1148

Warning: fsockopen(): unable to connect to :80 (php_network_getaddresses: getaddrinfo failed: No address associated with hostname) in /hosting/sites/gen5.info/htdocs/q/wp-includes/class-snoopy.php on line 1148