Why are some HtmlHelper methods implemented as extension methods?

The reason is: we wanted to provide you with the ability to opt-out to any of the built-in HTML helpers in case you preferred to write your own or use some other 3rd party helpers instead. If they weren't extension methods in a special namespace, you wouldn't be able to ignore them.

– M4N Jan 14 '10 at 16:08 Actually, extension methods are the only way you can write HTML helpers. – Brad Wilson Jan 15 '10 at 2:14 I don't want to extend HtmlHelper! I have updated the question with some more details.

– M4N Jan 16 '10 at 21:59.

I suppose it might be because the Framework Design Guidelines mentions (4.1): Avoid having types designed for advanced scenarios in the same namespace as types intended for common programming tasks. And later on (5.6) about extension methods: Do not put extension methods in the same namespace as the extended type, unless it is for adding methods to interfaces or for dependency management. Phil Haack himself mentions on the same page that they put "more advanced" funcionality in a separate namespace in order not to "pollute" the API of the extended type.

I agree that the methods that actually are more useful (ActionLink and so on) are less discoverable, but they are all implemented using the core API of HtmlHelper (GenerateLink, etc. ) which is part of the main namespace. If you intend to follow the official design guidelines and it makes sense in your specific case, I think you should adhere to this pattern.

1 ISBN-10: 0321545613 ISBN-13: 978-0321545619 – Dan Atkinson Jan 14 '10 at 12:54.

I tend to follow that pattern by having core classes, and then extension classes for each one where needed. Regarding advantages... I'm not aware of anything apart from separating the actual classes themselves from their extensions.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions