Coffeehouse Post

Single Post Permalink

View Thread: Java value types Vs .NET
  • User profile image

    , Bass wrote

    In Java people do similar things using static imports. It's not quite as 'object-oriented' as extension methods, but I think when used intelligently it makes code look really succinct (eg: in the case of JUnit).

    It's good that Java got static imports so you don't need to write Math.bla all the time. Extension methods, on the other hand, usually come with natural auto-complete (Intellisense) support so you automatically see what methods apply to a value of a given type.

    That said, you could probably cook up some nice auto-complete tool support for static imports so they act like extension methods: dot into a type and you see static imports as well. Select the static method and it rewrites from bla.method() to method(bla).