mardi 23 juin 2015

Facade Design Pattern: Transforming client request

Consider the following design, I doubt if I implemented Facade design pattern in correct way. My concern is that I manipulated the simple request coming from client; and not naively delegate the request to the encapsulated type: ComplexWorker. Is it ok? Isn't it actually the Wrapper design pattern?

class WorkFacade
{
   public void Work(SimpleRequest request)
   {
       ComplexRequest = new ComplexRequest(SimpleRequest);
       ComplexRequest.RequestTime = DateTime.Now;
       ComplexRequest.UserId = 120;
       new ComplexWorker().Work(ComplexRequest, 2015, 6, 7, 23, 12, 1);
    }
}
class ComplexRequest()
{
    ComplexRequest(SimpleRequest request)
    {
          // Code to convert simple request to complex request
          // understandable by ComplexRequest
    }
}

class ComplexWorker
{
   void Work(ComplexRequest request)
   {
      //...
    }
}

Aucun commentaire:

Enregistrer un commentaire