Thursday, September 23, 2010

Note of caution for reflections in java

First, a note of caution. Don't use the reflection API when other tools more natural to the Java programming language would suffice. For example, if you are in the habit of using function pointers in another language, you might be tempted to use the Method objects of the reflection API in the same way. Resist the temptation! In this case, your program will be easier to debug and maintain if you don't use Method objects. Instead, you should define an interface, and then implement the interface in the classes that perform the needed action. 

No comments:

Post a Comment

Chitika