I have written a program which compares some xml elements using reflection to make it as generic as possible so that if a new element/attribute gets added, the comparison code need not change to accommodate the new element/attribute. I initially thought of using hashcode and equals implementation of my jaxb object but thought reflection is a much better way out as hashcode and equals would have to be regenerated to accommodate the new element. So anyone who adds a new element/attribute would have to take care of writing or generating hashcode and equals.
The concerned software is not an low latency or high frequency application so response time does not matter in terms of miliseconds or even a couple of seconds. People have this conception that reflection is slow, I agree it is if it is used vastly here and there in application which is clearly not the case.
Could someone help me demonstrate the statistics of some of the common generic third party libraries which use reflection ? The answer to this question would help people understand and get over the reflection-phobia. I always think that java has exposed reflection api to 'public', it is giving us freedom to make use of that considering the situation.
Apologies for a long description.
Aucun commentaire:
Enregistrer un commentaire