Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about using reflection

 
sudip narayan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it a good practice to use reflection extensively. Are there any potential issues/pitfalls in using Reflection. Has it got better in newer versions of jdk 1.5 or 1.6 compared to older versions of jdk.

regards
sudip
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't use reflection just because its the cool thing to do, but you certainly see it alot in current projects to increase flexibility and convenience.

Bill
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudip narayan wrote:Hi,
Is it a good practice to use reflection extensively. Are there any potential issues/pitfalls in using Reflection.

Readability. It should be used when you need to do something very generic - like in a utility. It's rarely extensive - more isolated to a specific layer of your application.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudip narayan wrote: Is it a good practice to use reflection extensively.


You are asking about reflection in a performance section? I see reflection as a very powerful tool, or a tool to build tools. But if you are using it a lot in production code, for me, that raises questions about your engineering tradeoffs.

With modern JIT optimizers, its probably not terrible for performance, but reflection code tends to be tricky to write and tricky to read.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic