> A part from the fact that there's nothing magic, that these design
> patterns are not NetBeans specific, but just based on the old SOLID
> principles by Bob Martin (e.g. the Interface Segregation Principle plus
> composition vs inheritance), that if people discussed more about these
> things rather than language features discovered that most of the
> problems can be solved with techniques that have been around for
> decades, etc.... your analogy is rather unfortunate, since thanks to
> generics the Lookup idiom can take advantage of IDE autocompletion. :-)

It's true that generics really comes to its right here. But the core
problem remains, how does one know what to query for? You are
essentially using dynamic has-a relationships on everything, which can
never be statically explored (is-a). Extensions methods are a way of
adding additional functionality to an existing class without
subclassing it or having access to the source code. It should be
obvious, that I am mostly concerned with what help I can get while
coding, putting my trust in the type system - liking the fact that I
don't have to ask an object about what it can do and checking for null
all over.

> But I find that many discussions here get too subjective and anecdotic:
> it's much better to talk with code. I'm blogging about these patterns /
> idioms and I should have completed the series in a few weeks (depending
> on my job load). They are focused by some concrete code from a concrete
> application. It will demonstrate what can be done with this approach and
> what cannot. I could challenge others to show how they would design the
> same thing (*). That sounds as the good way to discuss these topics.

It's not that I don't see the power in the lookup pattern, I just
question whether it's worth the trouble outside of extremely flexible
and long-lived architectures (i.e. NetBeans). Should we make EVERY
Object in Java extend Lookup? The beauty of extension methods is that
you gain the power to evolve (statically), by injecting domain
specific utilities through the import scope. Image what Joda-time
could do to a gazillion code-bases all using their own buddy
DateUtils.

I don't know Bob Martin's opinion on this, but considering what he has
written in Code Complete about "Using Third-Party Code" and "Exploring
and Learning Boundaries" I'm not convinced he would favor a dynamic
lookup over extension methods.

/Casper

--

You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=.


Reply via email to