Extension vs defender methods

Francis Devereux francis at devrx.org
Thu Nov 10 08:12:06 PST 2011


On 10 Nov 2011, at 12:16, Llewellyn Falco wrote:

> Everyone is using the term. Now to be fair, if you ask a rubist  about extension methods you will get a response about mix ins, ask a JavaScript person, you will hear about prototypes, but the understanding is uniform -- extension method == adding methods to a classes you don't own

It seems to me that virtual defender methods as described by JEP 126 and C# extension methods are mainly useful to different audiences. JEP 126 virtual defender methods are mainly useful to authors of APIs, so that they can add methods to their interfaces in a backward compatible fashion. C# extension methods are mainly useful to application developers who want to extend libraries or APIs that they can't change.

I think that if Java uses the name "extension method" then a lot of application developers with experience languages other than java will be disappointed that they can't use them like C# extension methods. On the other hand if they are called something different ("defender methods" for example) then these developers won't have preconceived ideas about what can be done with them so they won't be as disappointed.

Francis



More information about the lambda-dev mailing list