lundi 17 mai 2021

Is 'duck typing' in Python also a 'Facade Design Pattern'?

Whenever we are able to call one function from different classes, would it be considered as Facade design pattern?

class Mobile_1:
    def __init__(self, name, ram, memory):
        self.name = name
        self.ram = ram
        self.memory = memory
    
    def info(self):
        return self.name, self.ram, self.memory
    
class Mobile_2:
    def __init__(self, name, ram, memory):
        self.name = name
        self.ram = ram
        self.memory = memory
    
    def info(self):
        return self.name, self.ram, self.memory    
    
    
mob1 = Mobile_1("Dark", 8, 128)        
mob2 = Mobile_2("Alpine", 16, 128)   

print(mob1.info())
print(mob2.info())

In the above code we are using the same function for both the classes. Would this be considered as a Facade design pattern?

Aucun commentaire:

Enregistrer un commentaire