dimanche 19 janvier 2020

Is it good idea to replace reflection calls with static Dictionaries in the whole application?

I have designed and implemented an enterprise application development framework in which I have used Reflection in different layers (especially in the UI layer where I have created several generic User controls that use reflection almost on any HttpRequest that users make.) a lot!

When I compare forms that do not use reflection at all to the ones that do, it is obvious to me that Reflection has become a performance bottleneck.

After doing some research and reviewing answers such as caching reflected properties and their custom attributes in c#

I have came up with the idea to create a utility ReflectionService which will perform the reflection for the first time it is required and then store it in a static Dictionary. In this way further reflection calls by any users will retrieve the result from the static dictionaries.So the static dictionaries are acting as some kind of application state here.

From a Design and Performance perspective, will it be a good idea to create such a service (ReflectionService) and move all the required reflection calls into this service?





Aucun commentaire:

Enregistrer un commentaire