Questions tagged [reflection]

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

21 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
85 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 ...
4
votes
0answers
21 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 (...
4
votes
0answers
104 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 ...
4
votes
0answers
653 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: ...
4
votes
0answers
77 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 ...
4
votes
1answer
193 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 ...
4
votes
1answer
109 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 ...
3
votes
0answers
67 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 ...
3
votes
0answers
71 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 ...
3
votes
0answers
70 views

Request handler based solely on reflections ver. 2

This question is connected to the previous one: Request handler based solely on reflections I have edited the code, taking tim's answer in regard, editing the Kernel class cohesion. ...
2
votes
0answers
65 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, ...
2
votes
0answers
570 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: ...
2
votes
0answers
12k 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): ...
2
votes
0answers
50 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 ...
2
votes
0answers
861 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 ...
1
vote
0answers
57 views

Dependency resolver in PHP

I wrote a simple Dependency Resolver in PHP that I'm hoping to get some input on. The main problem that gave me some trouble was when it had to resolve typed arguments ( like type hinting a ...
1
vote
0answers
577 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 ...
1
vote
0answers
653 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. ...
1
vote
0answers
163 views

Saving the state of a ViewModel

I've the following scenario, I've got some viewmodel that need to persist their state on disk. I've defined a custom attribute as: ...
1
vote
0answers
93 views

Using interface for generated functions or just create plain functions

I was wondering which code might be better. I'm abstracting away the rote code as follows: ...
0
votes
1answer
68 views

Class to fill model objects with data from the database

This is a helper class that helps fill models with data obtained from the database. ...