Re: Class.getMethod in class's static initializer block
- From: chucky <tomas.mikula@xxxxxxxxx>
- Date: Wed, 01 Aug 2007 20:56:38 -0000
Thank you for your prompt reply and elegant solution!
A couple of suggestions. One, is there something you could use that
isn't a string? int perhaps, or enum?
I think not, because that string comes from the 'outside
world' (viewed from my perspective). I was given someone else's code
that I'll have to deal with. I don't have access to this code at the
moment, I just remember that I wanted to think this out.
I'm almost sure that the application could be refactored so that it
uses enum instead of string, but that is behind my scope.
public class MyClass {
SomethingLookup lookup;
/* Iniitalize lookup in constructor */
I would still use
static SomethingLookup lookup;
and initialize it in static initializer block instead of constructor,
so that it is initialized once and not once per instance of MyClass.
Maybe you are discussing something related in the last paragraph,
which I didn't really catch on:( :
You're Something implementations can be Fly Weights, so you can pass
any state information into the methods as another class. That way you
don't have to keep different SomethingLookup and Something objects for
every object that you wish to affect.
.
- References:
- Class.getMethod in class's static initializer block
- From: chucky
- Re: Class.getMethod in class's static initializer block
- From: Daniel Pitts
- Re: Class.getMethod in class's static initializer block
- From: chucky
- Re: Class.getMethod in class's static initializer block
- From: Daniel Pitts
- Class.getMethod in class's static initializer block
- Prev by Date: Re: Discussion of why java.lang.Number does not implement Comparable
- Next by Date: AWT simple questions
- Previous by thread: Re: Class.getMethod in class's static initializer block
- Next by thread: Re: Class.getMethod in class's static initializer block
- Index(es):
Relevant Pages
|