How do you handle shared logic or common code across multiple services without creating tight coupling?

Last updated 3 July 2026

  • Share only stable, non-business code: logging, tracing, auth helpers, contracts/schemas (Protobuf, OpenAPI), and thin generated clients.

  • Never share domain logic or ORM entities across services. It forces lockstep deploys and leaks one context's model into another.

  • Publish shared code as small, independently versioned libraries (semantic versioning) so consumers upgrade on their own schedule. Prefer duplication when logic will likely diverge.

  • https://blog.devgenius.io/microservices-pitfalls-shared-libraries-d3b72c678c0b
  • https://dev.to/thesimdak/shared-library-for-micro-services-why-should-you-have-one-2jod
All Microservices interview questions