[OCP 11 Complete Study Guide] [OCP 11 Programmer I Book] [OCP 11 Programmer II Book] [OCP 11 Practice Tests Book] [OCA 8 Book] [OCP 8 Book] [OCP 8 Practice Tests Book] [Blog]
Originally posted by Scott Selikoff:
I don't know the precise tradeoffs, so I can't answer your question directly. But, have you thought about adding interfaces to a lot of your classes? I know in lot of situations where I've considered using reflection, I've instead set up a public interface and worked off that.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
The cost of reflection is known to be very low in modern JVMs. It's unlikely to be the bottleneck when you compare it to the costs of transmitting information via http or accessing a database...
Originally posted by Paul Clapham:
I have never found reflection-using code to be "convenient". It's quite hard to understand and get right, in my opinion. So this equivalent non-reflection code would have to be quite ugly for reflection to beat it out. That's from the code-writing and code-maintaining point of view. I can't comment on the performance question, knowing nothing about the actual code.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
And when was the last time anyone actually got a defined non-functional requirement of "this application must manage X transactions per whatever" or "this application must respond subsecond for X concurrent users"?
Can an argument be made that the zreo reflection system would perform better (again, given well written code) than an app the relied heavily on reflection?
Originally posted by u johansson:
Reflection in Java is very stupid really.
One of the major benefits of Java is strong typing. If you don't want strong typing, why use Java at all? Use a scripting language instead.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Gregg Bolinger:
The "stupidity" factor of reflection is not what this discussion is about. Start a new thread if you want to discuss that topic further.
Thanks.
Originally posted by u johansson:
Well "stupid" may be a little strong, but reflection basically is a "sin" in a language like Java and should be avoided.
Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Originally posted by Michael Ernest:
How can you say that? Why should it be avoided?
Originally posted by uj johansson:
The reason reflection should be avoided is because it makes code less type-safe and thus more error-prone. If you're not aware of this then reflection becomes just another useful facility without any appearant drawbacks.
Type-safety is a main objective of Java.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Don't get me started about those stupid light bulbs. |