architect-handbook

Software Architect Handbook

View on GitHub

Database Wrapping Service

Overview

We hide the database behind a service that acts as a thin wrapper, moving database dependencies to become service dependencies.

Sometimes, you accept that in the near term you will not be able to make changes to some systems, so it is imperative to at least not make the problem any worse. So we need to stop people from putting more data and behavior into a problematic schema. Once we’ve done that, we could consider removing those parts of the problematic schema that are easier to extract.

To achieve this, we introduce a service that allow us to “hide” the problematic schema. This service would have very little behavior at first, but the goal is to encourage the teams writing other applications to think of the wrapped schema as someone else’s, and encourage them to store their own data locally.

Just as with our use of database views, the use of a wrapping service allows us to control what is shared and what is hidden. It presents an interface to consumers that can be fixed, while changes are made under the hood to improve the situation.

Where to Use It