mardi 22 octobre 2019

What GOF pattern is implemented for the code?

Is there any matching GOF pattern in the code below?

The sense is that there will be 2 consumers and a lot of workers. ConsumerA will use only DoA() method, ConsumberB will use only DoB() method . inputA and inputB will be different classes that have some key property.

interface IWorker()
{
    DoA(object inputA);
    DoB(object inputB);
}

class ConcreteWorker1 : IWorker
{
    DoA(object inputA){}
    DoB(object inputB){}
}

class ConcreteWorker2 : IWorker
{
    DoA(object inputA){}
    DoB(object inputB){}
}

class ConsumerA
{
    HandleA(object inputA)
    {
        var worker = factory.GetByKeyA(inputA.Key);
        worker.DoA(inputA);
    }
}

class ConsumerB
{
    HandleB(object inputB)
    {
        var worker = factory.GetByKeyB(inputB.Key)
        worker.DoB(inputB)
    }
}

Aucun commentaire:

Enregistrer un commentaire