lucascordoba7 / Ecommerce

2 stars 0 forks source link

HS-02 Create the facade layer #2

Closed lucascordoba7 closed 2 years ago

lucascordoba7 commented 2 years ago

I should create a facade layer to convert the data to a xxxData.java

This layer will help to not show all the database information and future circular dependecies between models.

TODO:

sohamangoes commented 2 years ago

@lucascordoba7 may I work on this?

lucascordoba7 commented 2 years ago

@sohamangoes sure! feel free to fork 👍🏾

sohamangoes commented 2 years ago

I have a couple questions -

  1. If we use ProductFacade within GenericController, won't the GenericController become specialised? In that case, should we define a GenericFacade typed with the DTO (eg. ProductData) ?
  2. The create API would need to respond with the id field in the response if I'm not wrong. In that case, should we define separate DTOs scoped to request/response? Eg. instead of singular ProductData, a ProductResponse and a ProductRequest. ProductResponse will have the id field, but ProductRequest will not.

Let me know your thoughts on this :)

lucascordoba7 commented 2 years ago

Sorry bro, i didn't reply.. but it was 2am in my country. 😄

  1. You're right! We should create a GenericFacade.
  2. Yes, it would be the best approach to create separate ProductRequestData and ProductResponseData.

Now, if we had 2 DTOs, the generic facade should use <T,D> for the different methods.

Let me know if you have more questions