Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
An old professor of mine once said "If you need reflection, you're doing it wrong."
I'm inclined to agree in all but a few specialist cases tbh.
@AlmondSauce So its an old application based on swing, I was writing a custom UI framework based on graphs. We can create a BaseUIPanel which may contain various UI elements.
Now to decouple actual code from listeners attached to these components I wrote another interface IActionTask which actually does the job but this has BaseUIPanel (an interface) as a param, so in this task, we cant extract any value from the UI elements.
To remedy this (and avoid bad casting), I wrote a method that takes the obj, and field name and returns the object.