Talk:Reflective programming: Difference between revisions

Content deleted Content added
Kaleja (talk | contribs)
Kaleja (talk | contribs)
Line 127:
 
I'd be grateful if someone could put some example applications of Reflections - I mean an example where it's for example useful to use them, in more real-world situations.
: Say you have a class with several methods that want to be exposed to a user-facing menu. Every time you add such a method, you want it to appear in the menu. One way is to write the menu explicitly, and modify the menu code manually every time you add a method, but that's labor intensive, error-prone, and easy to forget to do. With reflection, you can implement the menu so that it inspects the class and populates itself with all the appropriate methods. I use this a lot -- any time you find yourself writing repetitive, mechanical boilerplate code, or where making a change in one place in the code requires you to make matching changes in other places, reflection might be useful. [[User:Kaleja|Kaleja]] ([[User talk:Kaleja|talk]]) 21:15, 10 February 2010 (UTC)
 
I have an idea of an example, but I don't know if I understood the Reflections ideas properly. I can be completely wrong and the example stupid. Therefore, I write it here for someone to 'certify', or change, or maybe write his own one, taking from his experience - and put on the main page: