How to distribute entities between projects?

1

I doubt if there are good practices for distributing entities between projects. Let's say I have a microservice REST in java, that makes available a client (id, name, address) through the GET and another microservice that needs to consume this first microservice.

How could you avoid duplicating code between these two projects? Placing the client entity in a separate JAR and making the two microservers use this JAR as a dependency? Is there another way to minimize code duplication between these microservices in java?

    
asked by anonymous 05.05.2017 / 01:16

1 answer

1

Surely this can be a big issue when it comes to distributed systems such as microservices, you can distribute the classes in a separate JAR and use them in projects, but for this to actually work Test coverage and correct dependency versioning is key, because imagine a possible change in this lib , this could directly impact your projects.

But another important point, this libs strategy works when you have few MS in architecture, when the amount increases it becomes very complicated to control these dependencies, so the output is the creation of the specific each MS.

    
05.04.2018 / 17:23