mercredi 12 février 2020

Microservice - Definition of variables in different layers. Design best practices

I have two layers:

  1. API: exposes the different resources and objects for consumers. (jar)
  2. Service : contains all the business logic.

I have objects, constants and enums that I am repeating them since I use them in both layers

So, in the API i can have one object like

class MyObject {
      MyEnum enum;
      ...
      //getters and setters
}

and

 enum MyEnum {
       ONE, TWO
 }

In my service layer i have my MyObjectDTO (with some business variables that are exclusive to the service layer) and the same MyEnum.

I have repeated objects in both layers (with some differences but not at the enums or constants).

The question is: Is there a better approach?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire