What is the motivation behind "Use Extension Methods Sparingly?"
Posted
by Robert Harvey
on Stack Overflow
See other posts from Stack Overflow
or by Robert Harvey
Published on 2010-03-26T15:51:59Z
Indexed on
2010/03/26
17:43 UTC
Read the original article
Hit count: 329
c#
|extension-methods
I find them a very natural way to extend existing classes, especially when you just need to "spot-weld" some functionality onto an existing class.
Microsoft says, "In general, we recommend that you implement extension methods sparingly and only when you have to." And yet extension methods form the foundation of Linq; in fact, Linq was the reason extension methods were created.
Are there specific design criteria where using extension methods are perferred over inheritance or composition? Under what criteria are they discouraged?
© Stack Overflow or respective owner