commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ola Berg <>
Subject Re: [Lang][Patterns] Generic interfaces [was: ...for handling exceptions]
Date Wed, 31 Jul 2002 20:38:17 GMT
>What I am 
>saying is that I don\'t like the generic application of that pattern.  I 
>think it is much better to be specific to get the benefits you list 
>above (exact namings used and precise exception type).

I think you are both right, and that the discussion can be applied on almost every application
of a pattern.

Type safety is often needed or wanted. OTOH, having generic interfaces is also good, since
common mechanisms can be written once and used everywhere. Reusability is king, and leads
to impressed customers :-) \"You got all this functionality in, in that short time?\".

I use this approach a lot, with success. I get the best results if I can define the generic
interface as an interface, and use an abstract superclass for the specialized version. If
it is inconvenient or impossible to have an abstract superclass, I extend the interface (extending
== specializing). But that is not a nice thing to do to yourself.

My version of the ExceptionHandler (yes I have one) is a generic interface ObjectHandler that
do the handleObject( Object), and the abstract super class ThrowableHandler implements ObjectHandler
with the final method handleObject( Object o) that calls the abstract method handleThrowable(
Throwable) if the object is of the right type.

As for the patterns proposal: I think it is a misuse of the term \"patterns\" to be used as
a package name for a set of common used interfaces. But I like the idea of a package of only
interfaces. Stable and easy to import for any other project. 


0733 - 99 99 17

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message