255 reputation
29
bio website
location Australia
age
visits member for 3 years, 9 months
seen Mar 16 at 2:09

Sep
11
awarded  Notable Question
Feb
3
awarded  Popular Question
Oct
9
awarded  Critic
Aug
29
awarded  Nice Question
Jun
7
awarded  Yearling
Jun
7
answered If immutable objects are good, why do people keep creating mutable objects?
May
3
accepted Should a string constant be defined if it's only going to be used once?
May
3
revised Should a string constant be defined if it's only going to be used once?
Added conclusion
Apr
27
comment Should a string constant be defined if it's only going to be used once?
A very good point; if it performs well it might be worth moving to Java 7 just for this...
Apr
27
comment Should a string constant be defined if it's only going to be used once?
I like the idea of a wrapper object with the methods called via .invoke(), because it does away with string constants entirely. I'm not so keen on runtime reflection to set up the map, though maybe executing getMethodMapping() in a static block would be OK so that it happens on startup instead of once the system is running.
Apr
27
comment Should a string constant be defined if it's only going to be used once?
@MichaelK I don't think XStream is appropriate for our scenario because the purpose here is to handle XPath queries — an XPath query comes in from an external system, and we have to return some data objects in response. AFAIK XStream doesn't support XPath queries; instead it would have to serialise our data into XML that is then loaded into a DOM where XPath queries can be made. That would mean serialising gigabytes and gigabytes of data into a DOM just in case an XPath query needs it... something many orders of magnitude slower than using a Jaxen adapter.
Apr
24
awarded  Commentator
Apr
24
comment Should a string constant be defined if it's only going to be used once?
You're right about the potential for typos and errors; my only defence there is unit tests. Of course that means yet more code...
Apr
24
comment Should a string constant be defined if it's only going to be used once?
I have no problem writing it in another language if it compiles to JVM bytecode... any suggestions?
Apr
24
comment Should a string constant be defined if it's only going to be used once?
We considered annotating existing methods, but some mappings traverse multiple objects (for example "country" mapping to object.getAddress().getCountry()) which is difficult to represent with annotations. The if/else string comparisons aren't pretty, but they're fast, flexible, easy to understand and easy to unit test.
Apr
24
comment Should a string constant be defined if it's only going to be used once?
Yes we do! No matter how we do implement this, we somehow have to define each unique mapping. We could, say, use Java annotations but then we'd need 1000 annotations... not necessarily an improvement.
Apr
24
asked Should a string constant be defined if it's only going to be used once?
Aug
3
awarded  Teacher
Jun
28
answered How do you cope with change in open source frameworks that you use for your projects?
Mar
18
comment What is the general definition of something that can be included or excluded?
The wowhead system is certainly powerful... and it's interesting that rather than have 'include' and 'exclude', it only has 'include' in combination with 'not'. So you can't do "exclude items that bind when equipped", instead you do "include items that do not bind when equipped". In the end I decided that the concepts of 'exclude' is easier to understand than 'include not'.