I need some insight in the correct type of design pattern to use in the following scenario:
Existing framework that will allow 3rd party developer to create modules to provide a small piece of functionality that is required by my system.
The piece of functionality involves a subset of my system that is essentially very simple: it ensures that 2 properties are available on a specific model in my system, say for example sake “Customer” and the two properties are getName and getEmailAddress.
Now, 3rd party debelopers can provide their own implementation of these which may have very complicated processes of generating these values, but my system is only concerned with the fact that these two properties must be available.
I gess the difficult part is how the 3rd party module code attaches itself to the Customer model
Create a class
CustomerInfo, containing the two customer properties, and an interfaceCustomerInfoProvidercontaining this unique method:Let the framework accept an instance of this interface, that the user will provide directly, or by configuring the name of a concrete class implementing this interface in a config file.
If the latter, load the class using
Class.forName(...).newInstance(), and cast the result to the CustomerInfoProvider interface.