3 ms·
The problem with Java is because there aren't any strongly typed functions, only strongly typed classes. Therefore to handle a mouseClick event requires a clas
by teyc 15y ago
The problem with Java is because there aren't any strongly typed functions, only strongly typed classes.
Therefore to handle a mouseClick event requires a class. However, it doesn't make sense to have a IMouseClick interface that has only one method, right? That would seem too wasteful.
So the natural thing to do is to group all the mouse events into a single interface.
Before you know it, you have the abomination of MouseClickListeners, MouseAdapters, and anonymous classes.
About overusing patterns - GOF is really a book of anti patterns that is particularly useful for language designers, because it points out the glaring contortions that people have to do to get their work done.
On the other hand, being a good programmer requires learning and subsequent unlearning of GOF patterns. I'm reminded of Bruce Lee when he started with Wing Chun, but then found the "form" too rigid. Quote from http://www.cavendishscience.org/phys/brucelee/brucelee.htm http://www.cavendishscience.org/phys/brucelee/brucelee.htm
In describing his style, Bruce Lee made a clear
distinction between "having no form" and "having no
form." To have no form was to transcend form from a
position of mastery that enabled one to see when the
rules could be-in fact, needed to be-broken. No form
was highly disciplined in its execution. In essence,
to have no form was to have access to all forms; to
understand all forms at their most essential level
and to see and be able to act on the connections among
forms. On the other hand, "having no form" implied an
undisciplined approach, an inability to master any form.
Lee discovered that he could not teach no form directly
to novices in the martial arts. A student first had to
master the form of karate, tae kwon do, or some other
school; only from a position of mastery could the
student begin to experiment with abandoning the form.