Moving past the monolith, Part 5 – Minimizing sharing between modules

This is part of a series of posts about Moving Past The Monolith. To start at the beginning, click here.


We’ve been talking about how you can break your application up into modules, which are groupings of functionality that can function (and potentially be deployed) as a semi-independent unit. In most cases, you’re probably still going to have a decent amount of shared code, database tables, CSS, and JavaScript code that needs to be shared across all modules.

I have no problem with the “shared module” that everyone ends up creating. This is a necessary part of every application, and by no means would I encourage you to copy and paste code. :) As always, there are some things to consider:

  • Are you putting something in a shared module just because you think it will be shared or because you know it will be shared?
  • These shared modules are for sharing within your application, never outside your application. If you need to share things with other teams, create services, database schemas, or something special for those teams.
  • Understand that every time you put something in a shared module, any changes to that code could impact any number of modules using it, which may involve you having to change, refactor, and deploy many other modules. The benefits will typically outweigh the downsides, but make this a conscious decision.
  • Pay attention to situations where you starting seeing so much related functionality in the shared module that maybe you need to birth a new module out of it.

One of the goals of modular software is making change, refactoring, and replacement easier. Shared modules can help you achieve your goals when used within reason, but make sure you remain aware of what’s going on so that you don’t end up with too much tight coupling.


Read the next post in this series, Using package managers to share common code.