3

I'm building an Mvc application with microservices that retrieve information from the database.

I have a question related the microservices. I want an entity from database with some property in a page of the application. So I've build the method of the service that retrieve the information.

In another page, i want the same entity but with other properties in addition.

I have two possible way:

  1. implement another method that return a new dto
  2. Add the properties to the method that already exist.

In the first case i have a new method and a new dto to mantain but any change is possible and under control, in the second one i have a unique dto but with properties not used by the first client pages.

Which is the best "Scholastic" microservices solution ?

4
  • Were do the different properties come from, are the from the same database, same schema, same table?
    – Jon Raynor
    Jan 19, 2018 at 15:05
  • Yes they are on the same table, schema and database. Jan 19, 2018 at 15:10
  • Is this a school assignment? Since when is "scholastic" a desirable quality in software development? Jan 19, 2018 at 15:51
  • The question has nothing to do with Microservices. Microservices is an architectural style. The "scholastic" of Microservices operates in abstraction layers far beyond from how do I support different formats for the same DTO.
    – Laiv
    Feb 21, 2018 at 21:23

1 Answer 1

1

Since this is the same table, schema, and database one method would suffice as the data is all in the same bounded context from a micro-service point of view. Consider breaking into 2 services if the data is not part of the same bounded context.

I would consider breaking into two methods if the number of properties on the second retrieval is large enough to warrant a 2nd call. In that case I would make an initial call to fill a "slim" object and then the secondary call to fill the "full" object. But if there are only a few properties that are different, just make one call.

For example, if the first call retrieved 3 properties and the next call retrieved 5 properties, just one call.

If the first call retrieved 3 properties and the 2nd call retrieved 20 properties, then having 2 separate calls would make sense, whether using micro-services or not. Also, if the user is always going to get all the data regardless, just one call up front.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.