dimanche 18 août 2019

Should I always have a separate "DataService" that make invokes another service?

I am building a new RESTful service that interacts with other microservices.

The routine task is to fetch some data from another RESTful service, filter it, match it against existing data and return a response.

My question is is it a good design pattern to always separate steps "get data" and "filter it" in two different classes and name one is as EntityDataService and the second one is simply EntityService?

For instance, I can make a call to a service that returns a list of countries that has to be filtered against some conditions as inclusion in EU or date of creation, etc.

In this case, which option is better:

  • separate CountryDataService class that only have one method getAllCountries and EUCountryService that filters them
  • make one class CountryService with public methods getEUCountries and getCountriesCreatedInDateRange and private getAllCountries

Which one is better?

I'm trying to follow KISS pattern but also want to make my solution maintainable and extensible.

Aucun commentaire:

Enregistrer un commentaire