On 06/22/2011 09:08 PM, Ricky Clarkson wrote:
For what it's worth, I try to load all language keys at least when the
class is loaded, i.e., assigning them all to static finals, and then
have a LoadAllClassesTest that goes over the classpath and attempts to
load all classes.
Not quite the same, but probably catches most of the same bugs. It
could be adapted to other kinds of resource, but perhaps you wouldn't
want to load all images eagerly.
It's also a matter of compactness of code. With standard bundles and a
bit of syntactic sugar one can write (example from my code):
|
view.notifyFeedUnavailable(notification().withCaption(_,
"unavailableNewsTitle")
.withText(_,
"unavailableNewsMessage"));|
I would prefer to avoid adding two lines for declaring two fields (even
though I agree that it's important to shrink code in the body of
methods, less important in field declarations). I'm with Sam and I would
like to see:
|
view.notifyFeedUnavailable(notification().withCaption(R.string.unavailableNewsTitle)
.withText(R.string.unavailableNewsMessage));|
Note that this would be slightly better than Android R - those plain int
constants need casts everywhere - it has been discussed here in past,
and Google's version is that plain integer constants allow faster code -
reasonable thinking of 2008, maybe not in 2011. In any case, it wouldn't
be reasonable in J2SE. So, if somebody is going to do that, please use a
special Key<T> object which would avoid casts.
In any case, it shouldn't be too complex to do that. Android has to
compile resources in a binary format that is efficient at runtime in the
device, while in J2SE we just need a wrapper on existing library classes
such as ResourceBundle or NbBundle. Probably a Maven plugin for doing
that would be quite simple.
--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
[email protected]
--
You received this message because you are subscribed to the Google Groups "The Java
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.