In the previous lesson we saw the symptoms of RouteManager: outages during peak season, slow changes, a domino effect between functions that should not affect one another. Symptoms tell you something is wrong, but they do not tell you what should be done differently. That is what design principles are for: general rules, distilled from decades of experience, that let you judge whether a structure is good before you build it. In this lesson we will study eight fundamental principles. For each one we will look at its definition, how to recognize its violation in RouteManager, and how to apply it. At the end you will learn to write an organization's architecture principles, which is one of the first deliverables of any architecture team.

Contents

  1. What a design principle is and what it is for
  2. Modularity and separation of concerns
  3. Low coupling and high cohesion
  4. Abstraction and encapsulation through interfaces and contracts
  5. Simplicity: KISS and YAGNI
  6. Design for failure
  7. Design for change
  8. Automate by default
  9. Security by design
  10. How to write an organization's architecture principles

  1. What a design principle is and what it is for

A design principle is a general rule that guides decisions without dictating a specific solution. "Every module must be the single owner of its data" is a principle; "we will use database X" is a decision.

Principles serve three purposes:

  • They guide: faced with two options, they tip the balance toward the one that respects them.
  • They align: they allow different teams to make consistent decisions without checking everything with each other.
  • They explain: when someone asks "why can't I do it this way?", the principle gives the reason.

One important warning before we start: principles are not absolute laws. Sometimes they conflict with one another (simplicity and design for change, for example), and part of the craft is knowing which one carries more weight in each case.

  1. Modularity and separation of concerns

Definition. Modularity means dividing a system into parts (modules) with clear boundaries. Separation of concerns adds the criterion for making that division: each module takes care of one thing and one thing only. The practical test is simple: if you can describe what a module does in one sentence without using the word "and," it is probably well delimited.

How to recognize its violation in RouteManager. On paper, RouteManager has eight functional modules. In reality, the boundaries do not exist:

  • The 180 tables in the database sit in a single schema, with no indication of which module each one belongs to.
  • The main shipment management class is over 6,000 lines long and contains rate, notification, and billing logic.
  • The Reports module queries the tables of all the others directly.

The result is that nobody can change one part with any confidence that they will not break another.

How to apply it.

  • Define the modules based on business capabilities (shipments, delivery, billing), not on technical layers.
  • Assign each table a single owning module.
  • Give each module a responsible team.

  1. Low coupling and high cohesion

Definition. These are two complementary measures of the quality of a division into modules:

  • Coupling measures how much a module depends on the others. We want it to be low: a change in one module should not force changes in others.
  • Cohesion measures how closely related the things inside a module are. We want it to be high: what changes together should live together.
High coupling Low coupling
Low cohesion The worst case: everything mixed together and everything dependent Isolated modules that make no sense on their own
High cohesion Modules that make sense, but break one another The goal: modules that make sense and are independent

How to recognize its violation in RouteManager. Two real examples from the system:

  • Data coupling. Billing reads the shipments table directly. A few months ago, the Shipments team renamed a column and the monthly billing run failed without anyone expecting it.
  • Temporal coupling. When a courier confirms a delivery, the application sends the SMS to the recipient within the same operation. If the SMS provider responds slowly, the courier's app is left waiting.

The second case shows up very clearly in a sequence diagram, which displays the messages between participants ordered in time, from top to bottom:

sequenceDiagram
    participant App as Courier app
    participant RM as RouteManager
    participant DB as Database
    participant SMS as SMS provider
    App->>RM: Confirm delivery
    RM->>DB: Save delivery
    DB-->>RM: Saved
    RM->>SMS: Send SMS to the recipient
    Note over RM,SMS: If the provider takes 20 seconds, everything waits 20 seconds
    SMS-->>RM: Sent
    RM-->>App: Delivery confirmed

The courier, who only needs to know that the delivery has been saved, depends on an external provider that has nothing to do with their job.

How to apply it.

  • Forbid one module from reading another's tables: it must ask for the data through an interface.
  • Separate what the user needs immediately (saving the delivery) from what can be done later (notifying). The specific techniques for achieving this, based on asynchronous communication, are covered in Module 2.
  • Review cohesion whenever a business change forces you to touch many modules at once: it is a sign that the division does not follow the business.

  1. Abstraction and encapsulation through interfaces and contracts

Definition.

  • Abstraction: showing only what is essential about a component and hiding the details.
  • Encapsulation: preventing those details from being accessed from outside.
  • Interface: the set of operations a component offers to the others.
  • Contract: the precise description of that interface (what is sent, what is received, what errors can occur) that both parties commit to honoring.

The central idea is that others should depend on the contract, not on the implementation. As long as the contract holds, the inside can change freely.

How to recognize its violation in RouteManager.

  • The API that merchants use returns the data exactly as it is stored in the database, with internal names such as stat_cd or int_route_id. Any reorganization of tables would break customers' integrations.
  • The code calls the SMS provider's library directly from 14 different places. Switching providers would mean modifying all 14.

How to apply it. Define explicit, stable contracts. This is a fragment of the contract Marta proposes for querying the status of a shipment, expressed in YAML:

operation: get_shipment_status
input:
  tracking_code: text   # the shipment's public code, not the internal identifier
output:
  status: one of [REGISTERED, AT_WAREHOUSE, OUT_FOR_DELIVERY, DELIVERED, INCIDENT]
  last_updated: date and time
  estimated_delivery: date and time, optional
errors:
  - SHIPMENT_NOT_FOUND
version: 1

Let's go through it line by line:

  • operation gives a business name to what is being offered.
  • input states the only thing that has to be sent: a public tracking code. The comment after # clarifies that the internal database identifier is not exposed.
  • output defines three pieces of data with understandable names. The status can take only five known values, so whoever consumes the contract knows exactly what to expect.
  • errors lists what can go wrong.
  • version allows for evolution: if one day an incompatible change is needed, version 2 is published and version 1 is kept for a while.

Nothing in this contract reveals how shipments are stored internally. That is encapsulation.

  1. Simplicity: KISS and YAGNI

Definition. Two acronyms sum up this principle:

  • KISS (Keep It Simple): between two solutions that solve the problem, choose the simpler one. Complexity is a cost you pay every day in operations, training, and errors.
  • YAGNI (You Aren't Gonna Need It): do not build today what might be needed tomorrow. Most imagined future needs never arrive, or arrive in a different form than expected.

How to recognize its violation in RouteManager. Years ago a fully configurable rate engine was built, designed to operate in several countries and currencies. Rutaverde never left Spain. The engine is still there: nobody fully understands it, every rate change takes two weeks, and it contains bugs that nobody dares to fix.

How to apply it.

  • Require that every piece of complexity respond to a real, current requirement.
  • Prefer technologies the team already knows over novelties with no proven need.
  • For every new component, ask: who is going to operate it at three in the morning?

Beware of the opposite extreme: simple does not mean simplistic. A system with no backup is simpler, but it does not deliver what the business needs.

  1. Design for failure

Definition. In a sufficiently large system, something is always failing: a disk, a network, a provider. Designing for failure means assuming this from the outset and deciding in advance how the system will behave when it happens, instead of trusting that it will not happen.

How to recognize its violation in RouteManager.

  • There is a single database and a single active instance of the application: they are single points of failure.
  • Activating the standby server is a manual process that takes about 40 minutes.
  • Calls to the maps provider have no timeout. When that provider is slow, requests pile up until they exhaust the application's resources.

How to apply it. For every dependency, ask three questions: what happens if it fails? How do I find out? And what do I do in the meantime? This pseudocode illustrates the difference:

# Without design for failure
coordinates = maps_provider.geocode(address)

# With design for failure
try for a maximum of 2 seconds:
    coordinates = maps_provider.geocode(address)
if it fails or times out:
    mark the shipment as "pending geocoding"
    continue creating the shipment

In the first version, creating a shipment depends entirely on the maps provider. In the second, a wait limit is set (2 seconds) and, if it is exceeded, graceful degradation is applied: the shipment is registered anyway and geocoding is retried later. The merchant can keep working even though a secondary piece is down. The specific resilience patterns are developed in Module 2.

  1. Design for change

Definition. The only certainty about a system is that it will change: new customers, new regulations, new providers. Designing for change means structuring the system so that the most likely changes are cheap and localized.

It does not contradict YAGNI if properly understood: the point is not to build future features, but to avoid closing doors. Isolating the SMS provider behind an interface is not overbuilding; it is leaving open the possibility of replacing it.

How to recognize its violation in RouteManager.

  • Deployment is possible only once a month and with two hours of downtime, so every change waits for weeks.
  • Configuration parameters (provider addresses, limits, texts) are written inside the code.
  • The list of cities is hard-coded: adding a city requires development work and a deployment.

This last point is especially serious in the face of a plan to expand from 6 to 20 cities.

How to apply it.

  • Identify the likely axes of change (more cities, more customers, new providers) and isolate them.
  • Move configuration out of the code.
  • Make deploying a routine operation with no downtime.

  1. Automate by default

Definition. Every task that repeats should be carried out by a machine, not by a person. Manual work is slow, does not scale, and, above all, produces different errors every time. Automated work is repeatable, leaves a record, and can be reviewed.

How to recognize its violation in RouteManager.

  • Deployment follows a document of 37 manual steps that Íñigo's team carries out in the early hours of the morning.
  • The servers were configured by hand over the years; nobody could rebuild an identical one from scratch.
  • Onboarding a merchant that integrates through the API requires a technician to create the credentials manually.

How to apply it.

  • Describe infrastructure and deployments in version-controlled files, so that creating an environment means running a process.
  • Treat a manual procedure as an outstanding debt, not as a solution.
  • Start with what hurts the most: the most frequent and the most error-prone tasks.

Automation techniques are covered in detail in Module 4.

  1. Security by design

Definition. Security is a property of the structure, not a layer added at the end. Security by design means that every architecture decision considers, from the very first moment, who can access what, what happens if a component is compromised, and what data is exposed. Two related ideas are least privilege (each piece has only the permissions it needs) and defense in depth (several barriers, not just one).

How to recognize its violation in RouteManager.

  • All the modules access the database with the same user, which has all permissions. A bug in Reports could delete the shipments table.
  • Tracking codes are consecutive numbers. Anyone can change the number on the tracking page and see the data of other people's shipments.

How to apply it. In this lesson we will stick to the principle: involve security (Clara, in our case) in the design from day one, and ask with every decision what attack surface it opens up. The specific mechanisms take up all of Module 3.

  1. How to write an organization's architecture principles

The general principles we have seen are universal. Every organization must turn them into its own principles: few, specific, and accepted by everyone. A well-written principle has four parts:

Part What it contains Question it answers
Name A short, memorable phrase How do we refer to it in a meeting?
Statement The rule, in one or two unambiguous sentences What has to be complied with?
Rationale The benefit to the business Why do we care?
Implications What changes in practice, including the costs What does it force us to do or to stop doing?

The implications are the most valuable part and the one most often forgotten. A principle without implications is a nice sentence; with them, it is a commitment.

These are two of the principles Marta has written for Rutaverde:

- id: P1
  name: Every piece of data has a single owner
  statement: >
    Every piece of data belongs to a single module. The other modules
    access it only through the interface published by its owner.
  rationale: >
    Direct access to other modules' tables has caused cascading
    failures, such as billing breaking when the shipments table
    changed, and prevents each part from evolving separately.
  implications:
    - Each table is assigned to an owning module.
    - Reports stops reading other modules' tables and receives the data through an interface.
    - There will be a transition period with registered exceptions.
    - Some queries will be more expensive to develop than with direct access.

- id: P4
  name: Everything fails, and we plan for it
  statement: >
    Every dependency, internal or external, is designed on the
    assumption that it will fail. Every call has a timeout and a
    defined behavior on failure.
  rationale: >
    A slow external provider cannot be allowed to stop shipment
    creation or the couriers' work.
  implications:
    - No call to another component without a timeout.
    - Every design documents what happens if each dependency fails.
    - Single points of failure are progressively eliminated.
    - Design and testing require more up-front effort.

Notice that each principle cites a real RouteManager problem in its rationale, and that the implications always include at least one cost. That is what makes it credible.

The complete catalog of Rutaverde's principles, which we will cite by identifier for the rest of the course, is this:

Id Name General principle it derives from
P1 Every piece of data has a single owner Modularity, low coupling
P2 Contracts before implementations Abstraction and encapsulation
P3 Simple first KISS and YAGNI
P4 Everything fails, and we plan for it Design for failure
P5 Adding a city is configuration, not development Design for change
P6 If it repeats, automate it Automate by default
P7 Secure by design Security by design

Seven principles is a good number: more than ten cannot be remembered, and those that are not remembered are not applied.

Common Mistakes and Tips

  • Applying the principles as dogma. Taking modularity to the extreme produces hundreds of tiny pieces that are impossible to operate. The principles balance one another.
  • Confusing "design for change" with building for every possible future. That is exactly what gave rise to the multi-country rate engine. Isolate the likely axes of change; do not implement what nobody has asked for.
  • Writing generic principles. "Systems must be high quality" does not help anyone decide anything. A good principle lets you reject a specific proposal.
  • Leaving out the uncomfortable implications. If a principle costs nothing, it changes nothing either.
  • Imposing the principles without building consensus. Principles work when teams feel they own them. Write them together with the teams.
  • Tip: when you find a problem in a system, ask yourself which principle was violated. You will turn a list of issues into a diagnosis.

Exercises

Exercise 1

State which principle or principles are violated in each of these situations:

  1. To change the text of the SMS messages, you have to modify the code and wait for the monthly deployment.
  2. The Planning module writes directly to the tables of the Delivery module.
  3. The team proposes introducing a translation system for twelve languages now, "in case we ever go abroad."
  4. Backups are launched by hand by a technician every night.
  5. If the accounting ERP does not respond, the courier's route-closing screen freezes.

Exercise 2

Write out in full, with its four parts, principle P6 "If it repeats, automate it" for Rutaverde. Use a real RouteManager problem in the rationale.

Exercise 3

A colleague claims: "Isolating the SMS provider behind an interface violates YAGNI, because we have no plans to switch providers." Reason through whether they are right.

Solutions

Solution 1

  1. Design for change: a piece of data that changes frequently is hard-coded. The lack of automation, which makes deployments slow, also plays a part.
  2. Modularity and low coupling (and, at Rutaverde, principle P1): a module modifies data it does not own.
  3. Simplicity (YAGNI): something is being built for a hypothetical need.
  4. Automate by default: a repetitive, critical task depends on a person remembering to do it. It also affects design for failure: what happens the day it is not launched?
  5. Design for failure and low coupling: a secondary dependency stops a primary operation. It is the same pattern as the SMS case.

Solution 2

One valid wording:

- id: P6
  name: If it repeats, automate it
  statement: >
    Every operational task that is performed more than twice must be
    automated, version-controlled, and runnable without manual intervention.
  rationale: >
    The 37-step manual deployment limits releases to one a month,
    requires two hours of downtime, and has caused human errors. With 20
    cities, manual operations are not sustainable.
  implications:
    - Deployments are run by an automated process.
    - Server configuration is described in version-controlled files.
    - Onboarding merchants through the API no longer requires a technician.
    - Operations team time must be invested in automation,
      at the expense of other tasks in the short term.

What matters is that the statement is verifiable (the "more than twice" threshold), that the rationale talks about the business, and that the implications include a cost.

Solution 3

They are not right, although the objection is understandable. YAGNI warns against building functionality that is not needed. Isolating the provider adds no new feature; it only concentrates in one place what is currently scattered across 14. The cost is small and the benefits are immediate, even without switching providers: the timeout can be set in a single place, the system can be tested without sending real SMS messages, and coupling is reduced. What would violate YAGNI is building, right now, a system that distributes messages among five providers based on price. The difference lies between not closing a door and building the room behind it.

Conclusion

Design principles give us a vocabulary for judging an architecture: modules with a single responsibility, loosely coupled and highly cohesive; contracts that hide the details; simplicity over speculative complexity; planning for failure and for change; automation and security as starting points. With them we have been able to explain why RouteManager struggles, not just observe that it does, and we have set out Rutaverde's seven principles, P1 through P7, which will guide the rest of the course. Principles say what a good design should look like, but not what pieces it is built from. In the next lesson we will review those building blocks: compute, storage, networking, integration, and platforms.

© Copyright 2026. All rights reserved