CSE Roadmap

Core tier · about 4 hours · 8 parts

Part 2 of 8 · 2 min read

Four rules

What a good interface avoids.

Think of a power socket. The plug that fits it does not depend on how the power station works. The station can switch from coal to wind, and no appliance changes.

BM gives four rules for the interface between services:

Rule Reason
Avoid breaking changes Adding a field to a message should not harm the callers that exist
Keep the interface technology-agnostic It should not force a language or platform on the callers
Make the service simple for consumers A well built service is not worth much if using it is costly
Hide internal detail A caller bound to the inside blocks every later change

The standard way to break all four is database integration: services share a database, and others read and write the tables directly. BM calls it by far the most common form of integration, and fast to start. He lists three problems.

  1. The schema becomes a public interface. Any change to a table may break an outside reader. The database is a very large shared interface, and a brittle one.
  2. Callers are tied to a technology. They use a database driver. Moving the data to a different kind of store means rewriting them.
  3. Behaviour is spread out. Rules for changing a customer live in each caller. If three applications edit customers, a bug fix must be made and deployed in three places.

In the words of page 2, database integration loses both cohesion and coupling. BM's advice is to avoid it at nearly all costs. The rest of the chapter assumes that each service hides its own data.

Database integration

Database integration is connecting services by letting them read and write the same tables.

Example: the warehouse application runs SQL straight against the customers table that the customer team owns.

Check yourself: 1. Which of the four rules does a shared schema break most clearly? 2. A team renames a column. Who might be hurt in database integration, and who in service integration? 3. Why is behaviour spread out in database integration?