The reflection tag has no wiki summary.
17
votes
4answers
2k views
Is Java instanceof operator considered reflection, and what defines reflection?
I had a discussion with a coworker today, whether usage of using the Java operator instanceof is a kind of reflection. And the discussion quickly evolved into what actually defines reflection.
So, ...
12
votes
3answers
6k views
Reflection: Is using reflection still “bad” or “slow”? What has changed with reflection since 2002?
I've noticed when dealing with Expressions or Expression Trees I'm using reflection a lot to set and get values in properties and what have you. It has occurred to me that the use of reflection seems ...
11
votes
3answers
247 views
Do I need to deal with the situation where private methods are called through reflection?
When creating a library, must I ensure that the private methods must work as expected when called not by other methods of the same class, but by another library through reflection?
For example, if a ...
10
votes
5answers
17k views
Why should I use reflection?
I am new to Java; through my studies, I read that reflection is used to invoke classes and methods, and to know which methods are implemented or not.
When should I use reflection, and what is the ...
8
votes
1answer
664 views
Why isn't reflection on the SCJP / OCJP?
I read through Kathy Sierra's SCJP study guide and I will read it again more throughly to improve myself as a Java programmer and be able to take the certification either Java 6 or wait for the Java 7 ...
8
votes
1answer
291 views
What's the relationship between meta-circular interpreters, virtual machines and increased performance?
I've read about meta-circular interpreters on the web (including SICP) and I've looked into the code of some implementations (such as PyPy and Narcissus).
I've read quite a bit about two languages ...
7
votes
2answers
3k views
Is it a bad habit to (over)use reflection?
Is it a good practice to use reflection if greatly reduces the quantity of boilerplate code?
Basically there is a trade-off between performance and maybe readability on one side and ...
6
votes
2answers
439 views
Are there any reliable solutions for annotations/reflection/code-metadata in C?
Not all languages support java-like annotations or C#-like attributes or code metadata in general, however that doesn't mean it is not possible to have in languages that don't have this.
An example ...
5
votes
2answers
830 views
How to create contracts in python
I am currently learning Python (from Java) and have a question on contracts.
Example: an application defines an interface that all plugins must implement and then the main application can call it.
...
4
votes
4answers
882 views
Is it bad programming practice to check if a class referenced by its interface is an instance of another class?
I have a class (Timer) with an array list of Timable objects. Timeable is an interface. There is some specific functionality that I need for the Trigger class (implements Timable), which has a ...
4
votes
1answer
363 views
Should reflection be part of design?
I'm currently designing a somewhat large program that will involve the simulation of math/physics models and collection of data (I have not implemented any code yet). One of the main problems I'm ...
4
votes
2answers
283 views
Is it bad practice to use reflection to do DB inserts with data from an external service?
Our supplier's webservice is returning address objects (~30 fields) and I'm using LINQ and reflection to store the returned data straight into the databse. I loop over the attributes and set the value ...
3
votes
6answers
793 views
In Java, would you sacrifice type safety for a nicer programming interface
When and why would you generally sacrifice typesafety for a nicer programming interface?
Let me give you an example: if you had the choice between two event aggregators, which one would you prefer ...
3
votes
2answers
237 views
Using reflection vs creating a new class
I and a friend are having an argument on what is the better technique to use in the following scenario:
An application we need to test has a number of components (lets call them Eggs); each component ...
3
votes
2answers
112 views
Determining which decorator classes are available via reflection
I'm creating a pizza place application where employees will be able to create orders for customers(pizza and any number of toppings). This is for a school project but the requirements have nothing to ...
3
votes
4answers
425 views
Is storing types in the database an anti pattern?
A little background on where this question is coming from. In my current .NET application I'm working on some features related to archiving a certain type of business entity called a "Project". ...
3
votes
2answers
331 views
C# static practices coming from dynamic background
I have been dappling in C# after coming from several years in PHP.
I don't find the language particularly difficult, although there are considerably more constructs for me to get used to.
My question ...
3
votes
2answers
481 views
Reason for a reflection error
I’m working on an Eclipse plug-in project.
Using this plug-in, users can create Eclipse Java projects with some specificities. For example, they can add Java classes’ names which will be saved in a ...
2
votes
2answers
343 views
Reflection and the LGPL
Simply, If I use reflection to add methods or functionality to a class defined in a LGPL'd library I'm linking to, does that count as a modification to the existing library and would my reflective ...
1
vote
4answers
527 views
Using Java Reflection to decouple code modules
I'm involved in a project with several modules. I found that programmers have designed one module to be easily decoupled from its dependent modules using Java Reflection. If other modules need to call ...
1
vote
1answer
159 views
Debugging xml and annotations
By now, most web containers have an annotation variant of their xml configurations for Java EE. I'm guessing this is because it's better to keep things in Java where they can be managed, coded with ...
1
vote
3answers
232 views
How do I support interfaces for different devices in the same input scenario?
I asked this question on SO but someone pointed out that I would be better off here. He's most likely right. So here I go!
So I just wanted an opinion. I have 2 different ways to approach the ...
0
votes
1answer
68 views
Reflection performance in this iteration of a (probably) large excel file
I'm wondering the performance of reflection in this situation. I'm iterating a (probably) large excel file (let's say 3000 max) which it's going to be done from time to time, and the implementation ...
-1
votes
1answer
111 views
Writing data driven reflection based tests to ensure design completeness [closed]
When writing software I'm often forced to at some point to make a decision that involves a design pattern of "by convention" naming and behavioral patterns. This normally makes me feel kind of slimy ...
-1
votes
1answer
311 views
assembly.GetTypes() vs assembly.DefinedTypes.Select(t => t.AsType());
public static IEnumerable<Type> GetAccessibleTypes(this Assembly assembly)
{
try
{
#if NET40
return assembly.GetTypes();
#else
return ...