mardi 2 août 2016

How to avoid reflection?

I have abstract class BaseClass with MyClassA and MyClassB implementations. The user can extend these two subclasses or use them, e.g. he creates only UserExtensionClassA and uses MyClassB as it is. There is a class ClassC responsible for the initialization of the classes. It receives configuration (e.g. containing the full class names of the needed implementation classes) and decides when and whether the classes are initialized (e.g. already 3 existing instances of BaseClass implementations => reject creation request).

Question: How can I avoid the reflection in the example? ClassC can create the classes from the names in the configuration. But I can still change almost everything in the library implementation and I don't like reflection stuff.

Aucun commentaire:

Enregistrer un commentaire