java - Retrieve values from class: custom methods or reflection? -
for take values from class there primitive fields (no methods) list of key - value prefer use reflection (with dynamic iteration) or specific method return hashmap? prefer?
at moment there fifty classes or in future can grow twenty or thirty (in regime)
i reflection in case not necessary?
the reflection-based approach cleaner, because not require classes implement additional methods, , not liable maintain these methods when new fields added existing classes.
a hashmap
-based approach not buy in terms of performance, because primitives must wrapped in objects inserted map - same way wrapped returned reflection-based calls.
Comments
Post a Comment