Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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: 40722
827
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: 4686
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.
 
No, tomorrow we rule the world! With this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic