Questions tagged [reflection]

Reflection is the process by which a program can observe and modify its own structure and behavior at runtime.

22 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
233 views

Factory class that uses reflection to instantiate objects by class name

In this SO post Dynamically choose class from string Alexander Platonov creates a Function on the fly and then uses Application.Run() to instantiate an Object by ...
TinMan's user avatar
  • 4,133
4 votes
0 answers
81 views

Inherit docstrings from specified parent

I was recently working on some python where I was working with multiple inheritance and mixins and stuff like that, and I wanted to inherit docstrings for specific functions, from specific parents (...
Andrew's user avatar
  • 61
4 votes
0 answers
133 views

Dynamically creating login screen on Android devices

This has been an experience. I'm well above "hello world" java is not a language I use often when programming and I don't program too much. I find myself a lot on Google.... basically just about for ...
Nolan Robidoux's user avatar
4 votes
0 answers
2k views

Get n-th data member of a struct

To get n-th member of a struct without non-empty bases and w/o non-public members C++ now have a pretty way: ...
Tomilov Anatoliy's user avatar
4 votes
0 answers
88 views

Creating companion classes that are `inherited` onto any sub-classes

The idea for the code I have written came about due to the acts_as_versioned gem which automatically nests a Version class onto ...
br3nt's user avatar
  • 242
4 votes
1 answer
287 views

Enumerations via reflection in AS3

I'm very much used to enumerations a la Java, where each value in an enum is a distinct object. You can call functions on these objects, and they're generally ...
Pimgd's user avatar
  • 22.3k
4 votes
1 answer
124 views

Porting a web-based POS system to Android

I'm currently porting a web-based POS system to Android. The Android version uses NavigationDrawer to navigate between menus. What I need a code review on is my ...
TtT23's user avatar
  • 1,040
3 votes
0 answers
188 views

Simple Java IoC container for dependency injection

I have come up with a quick and simple IoC container to enable minimal dependency injection support in one of my Java projects. The container supports services with: A transient lifetime, meaning, a ...
Amal K's user avatar
  • 173
3 votes
0 answers
100 views

Yet another reflection library

Tried to do my own implementation of reflection(introspection) for using in my next projects. Is it optimized at compile time? If no, how can I improve it? This macro is good interface for adapting ...
Vladyslav Mozhvylo's user avatar
3 votes
0 answers
586 views

Generic object-to-XML mapper

This code is part of a larger mapping library I'm working on to address some business concerns of transforming data. I was inspired by mapstruct in Java, but opted for users to annotate / add ...
Igneous01's user avatar
  • 131
3 votes
0 answers
83 views

Scala code that loops through Java annotations decorating Scala classes

I have code written in Scala that reads annotations decorating other Scala classes. These annotations are written in Java. The sticking point is that annotations don't allow advanced data structures, ...
bendl's user avatar
  • 131
3 votes
0 answers
104 views

Print Python docstrings when module is executed interactively

I have written a module, which should only be used by means of import, then call the functions as required. I do not want this module to do anything when ran interactively, other than printing out ...
Edwin van Mierlo's user avatar
2 votes
0 answers
47 views

Performance impact of using reflection instead of an "Options" class

I am trying to refactor a service by providing some options on what to bring back. I can't decide what is best way to go between the below A. Use a class for the options Create a new class for the ...
Anastasios Selmani's user avatar
2 votes
0 answers
56 views

Library/API: simple springboot / jdbc query builder and ORM

I have been using and developing a simple ORM and query builder library that I have found useful in it's practical application. I am pretty sure there are improvements to be made, and I welcome any ...
rmalchow's user avatar
  • 121
2 votes
0 answers
678 views

Pagination links for various lists using Spring-HATEOAS

I'm using Spring HATEOAS to create some links on my REST API. However, the entities i'm returning are very close, so the code to generate the links are the same: ...
Kaidjin's user avatar
  • 123
2 votes
0 answers
14k views

Retrieving Primary Key from Entity Framework entity

Entity Framework (version 6) generates classes based on your tables that look like this (where each property represents a field in the table): ...
Kai's user avatar
  • 449
2 votes
0 answers
57 views

'Tag' packages and make them discoverable

We have another team who is going to expose class packages for use to scan and pickup details from. If they should add some new packages or rename old ones I don't want to have to recode a thing. I am ...
Christian Bongiorno's user avatar
2 votes
0 answers
875 views

ORM with magic getters/setters

I'm playing around with PHP, trying to write a small ORM. Having worked with Magento quite a bit lately, I've fallen in love with the automagic getters/setters that Magento, I think, inherited from ...
vzwick's user avatar
  • 119
1 vote
0 answers
402 views

Entity Component System (ECS) in Java

While trying to write a game engine, I came up with this ECS / Component Based Architecture for its physics and drawing logic. I want to get some feedback on its architecture. I am using reflection ...
Quadslab's user avatar
  • 113
1 vote
0 answers
216 views

Generics and aggregated evaluation of validation rules

I have a custom system for data validation; it handles anything from method parameters, return values, objects, etc. The core of this system is IValidationRule and ...
pikausp's user avatar
  • 219
1 vote
0 answers
979 views

C# MVC Generic Custom Model Binder

I recently created a custom model binder as a training exercise and wanted to see how I could improve it. It currently uses recursion and works great, but I was wondering how I could convert this to ...
MattyMc's user avatar
  • 33
1 vote
0 answers
2k views

Generate random instance of given Class

I was running some rightsizing tests and had to blast random objects of my various class types. Here is the code I came up with. ...
Dexter's user avatar
  • 415