mardi 6 décembre 2016

What's the right design pattern for a factory like pattern but different parameters?

Context: Let's say I have an uninstaller. For the different things I want to uninstall (such as reg keys and files), I'll need objects to perform those actions. I anticipate having an IUninstallAction interface, with a Uninstall function. Then my RegistryUninstallAction and FileUninstallAction classes could implement IUninstallAction.

Problem: The RegistryUninstallAction constructor needs different parameters than the FileUninstallAction constructor. And other classes implementing IUninstallAction may also need different parameters.

Question: What is the appropriate design pattern for this scenario? My first thought was the factory pattern but because of the different constructor parameters, this seems like a poor fit.

Aucun commentaire:

Enregistrer un commentaire