My most common use of reflection in real production code is doing things like reading a config file into an annotated POJO. I like this because of its type safety - can use reflection to determine the type of a field, extract it from a config file (using the appropriate validation rules for that type), and there is no risk of things being out of sync. Adding a new config file option is just a matter of adding a new field to a class. Annotations are quite nice here to specify any additional validation rules to apply (e.g. an integer in the range 1 to 10).

So I like reflection in this case because it localizes dynamic typing to a small area in the code - everything else can be statically typed.

Alan

--
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.

Reply via email to