geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Blewitt <Alex.Blew...@ioshq.com>
Subject Re: Reflection Bad, OO and direct Method invocation Good...
Date Sat, 09 Aug 2003 23:48:53 GMT

On Saturday, Aug 9, 2003, at 14:16 Europe/London, John C. Dale wrote:

> Although reflection allows an incredibly generic way to solve many 
> difficult problems, and really opens the door to completely grandios 
> perfectly idealistic genericititousness ;)  , a straight-forward OO 
> approach to solving the problems would 1) be faster and 2) be easier 
> to read and maintain.  I've seen reflection based approaches work, and 
> I've seen them bomb.

I'd like to disagree with 1). Sun have done a lot of work in the more 
recent VMs making reflection fly, just for this kind of purpose. With a 
Method.invoke() you get a call-time similar to calling static methods 
(which don't require any messy inheritance searching for the correct 
method call in sub/super classes). Since the Method contains the 
reference to the class that it's defined in, inheritance doesn't play a 
part (unless that Method is defined as abstract, such as an interface 
or abstract class, obviously ;-)

I'd completely agree with 2), though -- but I'd suggest that reflection 
has its uses in low-level routines rather than in every step.


Mime
View raw message