Monday, August 11, 2008

NO to Extension Methods

Extension Methods are the coolest features of C# 3.0. Although it looks very power full, it is to be used stingily. There are multiple reasons behind that with Maintainability being the first.
  • You have to search the whole code base to find where you extension method is implemented.
  • There are complex rule based on which overriding of extension method works
  • Little more complex methods and you may put yourself into cyclic reference problem
  • For me and other users of Rhino Mocks beware as you cannot mock (fake) out extension method yet.

So you may ask me ‘When to use?’ If you come on conclusion that the usage of extension method in your case is die hard and alternatives are way too ugly, perffer oldschool otherwise… Happy Coding!!

No comments: