mardi 10 octobre 2017

How can I let my framework create instances of user defined subclasses

My framework will create objects which have interface A.

The user is responsible for defining concrete subclasses B, C, D...

What is the correct way for me to tell the framework here are my concrete classes which you can create yourself (as many as you wish).

My initial thoughts were something like the command design pattern. The difference is that it would be a generic class (B, C, D...) and it would return A. Would this be appropriate? Another approach would be to do something similar with a factory method.

Is there an alternative pattern to solve this problem?

The user should be able to create as many alternative subclasses as they wish without modification to the framework. The framework should only know about interface A.

Aucun commentaire:

Enregistrer un commentaire