Java Reflection provides a mechanism to introspect an Object at runtime. No second thoughts, this is a great feature, but it breaks all the Refactoring conventions!
There is no easy way (other than File Search
) even in modern IDE's to know which attribute is referenced and where. This makes Refactorings much more complex (tiresome!) and error prone.
To be frank, it's not just the Reflection API
; Hibernate mapping files (hbm.xml)
and JSP files
both refer to the attributes as String and when you refactor your attribute name, then you have to manually change in all these places.
Worse, the changes in Hibernate mapping files or JSP files result in runtime errors.
I am interested in knowing how other programmers handle this in Java. Are there some tools? I use Eclipse/IBM RAD as main development platform. Normally we use a constant
to define the attribute and use it whenever possible but its not always possible.
I would also be interested how other languages handle this!