Here is my dilemma.
1) I want to create instances of different classes depending on a single parameter --> Solution : Factory Pattern. The nice thing about Factory is zero parameter constructor.
2) Each of these classes have different constructors. For example
class PhotosProviderFacebook(val refActivity: WeakReference<Activity>)
class PhotosProviderLocal(val context: Context, val loaderManager: LoaderManager)
I thought about Builder Pattern. See how Builder pattern is done in Kotlin
Is there a design pattern that respect these constraints ?
1) First build an instance depending on a parameter. Possibly without passing yet the constructor inputs.
2) Pass parameters in constructor
Factory + Builder are just an idea. Maybe there is a simpler way.
Aucun commentaire:
Enregistrer un commentaire