Hi,
Are there any performance implications with using the provider pattern?
Does it rely on reflection for each instantiation or anything?
Hi,
Are there any performance implications with using the provider pattern?
Does it rely on reflection for each instantiation or anything?
Yes, the provider model usually involves a small amount of reflection, and therefore, there is going to be a little bit of a performance hit, however, it is only in the instantiation of the provider object. Once the object is instantiated, it is accessed as normal (usually via an interface). The performance versus a hard-coded model should have very little difference, but the gain you get from the programming perspective far outweighs any performance penalty. Assuming the provider actually may change one day. If not, just hard-code it.
Providers are instanced once per app-domain. Although newing up an object via reflection is slower than doing it inline, it is still very, very fast. I would say there is no performance concern for most business apps.