I have two Classes that have similar methods however in one Class - there are some different mandatory parameters. For Eg:
Class NamespacedScoped:
def get_object(self, name,namespace):
pass
def delete_object(self, name,namespace):
pass
Class ClusterScoped:
def get_object(self, name):
pass
def delete_object(self, name):
pass
I am needing to create an interface for the above classes. Since the methods are more or less the same with only the signature varying a bit - is it a good design to have an Abstract class with the same operations but allow the implementation class to have a different signature?
for eg:
Class InterfaceClient(ABC):
def get_object(self, name):
pass
def get_object(self, name):
pass
In Pycharm - I get the warning that the signature is different for Class NamespaceScoped.
I could technically do **kwargs but I don't think I can enforce the mandatory params easily
Is it an ok design to go with the above approach? An alternative to this is to have two abstract classes (one with namespace mandatory and the other with not) however I see the declaration of the methods are kind of duplicate
Aucun commentaire:
Enregistrer un commentaire