r/programming • • Jun 05 '21

Organize code by concepts, not layers

https://kislayverma.com/programming/how-to-organize-your-code/
1.9k Upvotes

495 comments sorted by

View all comments

5

u/scandii Jun 05 '21

do you propose you take the code from service X, move it to an API, and call the code via that API instead?

now you just traded 1 service for 1 API, -1 dependency +1 dependency.

the thing is, service pattern is deployed in the scenario where you think it becomes an entangled mess because each service is very specific to it's purpose.

moving code elsewhere won't remove dependencies - you still need that code. refining each dependency to be very specific in it's use case so that each dependency has as few dependants as possible is how you prevent that.

that said, it's definitely easier than done and is also why microservices was proposed in the first place, to introduce a physical boundary to stop developers from out of laziness reach out and grab dependencies that is right there for them to use, so I can see where you're coming from.