vendredi 3 décembre 2021

Design Pattern for reducing quantity of "pass-through" functions in multiple layer solution

I want to know if there's some design pattern for solving this problem.

Problem: We've multiple layers (MVC).

  1. Controller =>
  2. Project Service (logic proper to the whole service) =>
  3. Common Data Service (BLL - common logic to all services for same solution) =>
  4. Data access =>
  5. DB.

There are many services in the application, let's say: API, Web service, Mobile service, etc.

In this scenario, i want to know if there's some way of reduce the amount of "pass-through" functions that i need to implement (and also create interfaces for testing) in the "Data Service" of each service. The common Data service is the one that serves and resolve the business logic for all kind of services in the application. This means that functions are "Common" to all services in the application. The particularity of this functions, is that they do not add extra logic, they only call the proper method to the next layer.

Example of the application design

Example of code extracted from one of the Data Service (Proyect service)

public IList<TipoDocumento> GetDocumentTypes()
{
    return SEMService.ObtenerListaTipoDocumento();
}

public IList<EstadoCivil> GetCivilStatusTypes()
{
    return SEMService.ObtenerListaEstadoCivil();
}

public IList<TipoContribuyenteIVA> GetTipoContribuyenteIva()
{
    return SEMService.ObtenerListaTipoContribuyenteIVA();
}

public IList<TipoContribuyenteIB> GetTipoContribuyenteIIBB()
{
    return SEMService.ObtenerListTipoContribuyenteIB();
}

TLDR: design pattern for reducing the amount of "pass-through" functions (that do not add no extra logic) in a solution that requires many layers to maintain consistency and encapsulation

Aucun commentaire:

Enregistrer un commentaire