• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

question about using reflection

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic