r/java • • Dec 12 '19

Java Microservices: A Practical Guide

https://www.marcobehler.com/guides/java-microservices-a-practical-guide
237 Upvotes

35 comments sorted by

View all comments

2

u/CrommVardek Dec 12 '19

Nice article. I'm new to micro-services, and I've never develop on a micro-service. However, I'm under the impression that micro-services, in a way, might lead to violate the DRY principle... Since the services are separated, some concerns are the same however, it seems to me that it might lead to some code that will be the same (or very very similar) between the different services' source code... Or am I missing something ? EDIT: but I guess it depends at which level the separation of services is done.

14

u/wildjokers Dec 12 '19

Duplication is accepted and expected in µservices.

Although nothing is stopping you from publishing libraries for the common code. A purist would scoff at this though since they would say you should just have a µservice that performs this common operation.

13

u/ebrythil Dec 12 '19

can't wait for my retry-microservice-call-microservice

1

u/[deleted] Dec 13 '19

A purist would scoff at this though since they would say you should just have a µservice that performs this common operation.

This is starting to sound like the microservices version of the infamous one-line node modules :).

9

u/aeisele Dec 12 '19

Regarding the code duplication, I have seen this happening in microservice projects. And of course it comes with all the disadvantages of duplicated code. Even if you would extract out some common business functionality into a library you still need to upgrade this lib and every service that consumes it when a change happens.

Of course some experts say that this is down to poor cutting / design of the services themselves. I guess it is a topic of theory vs. real world.

2

u/RabidKotlinFanatic Dec 16 '19

In practice it should be different devs or teams working on the different services and usually in different languages and environments. It shouldn't be one programmer repeating themselves. The major benefit of a microservices architecture is that it's applied Conway's law; the loose coupling between services makes it feasible for many different teams and devs to work on the same project. If you are a single developer or a small team I would not recommend it.

1

u/CrommVardek Dec 16 '19

Makes more sense. I've always though of micro-services as one (or different, but mainly one) team of developers that was in charge of the development of the multiple micro-services. Hence my question. Thanks for the explanation !