Have you ever looked at the architecture of your application and wondered, why did I/we do it this way? If you have, then you’ve probably also cursed under your breath for not having documented the reasoning somewhere. I know I have!

As developers we are pathologically averse to writing documentation because we mistakenly (and selfishly) think, that its duplication of effort.

I’ve already written code once, now why I do need to repeat the same thing in text?

Sometimes the comeback has a slight air of arrogance about it:

My code is self-documenting, I don’t need to write documentation separately!”

All of this is just sheer laziness masquerading as some misplaced sense of superiority or downright selfishness.

You are not the only one on the team and your memory will eventually fail you at the worst possible times. Architectural Decision Records alleviate some of those problems by providing a (semi) formal document of key architectural decisions that you & your team make in the early phases of a project or piece of work.

It also serves as a reference compendium not just for you to refresh your own memory but also for the new members on the team who need to learn about the system architecture in order to contribute effectively but also keep that discipline alive.

Writing ADRs/decision logs gives the reader a sense that the team had been deliberate and intentional about doing something in a certain way with good reason, it wasn’t just accidental and haphazard.

One of the other advantages for ADRs is that in order to write it coherently you really have to think through the options properly and cut out what doesn’t make sense! In other words, you learn how to articulate your ideas in a concise manner for written consumption.

Format of ADRs

I personally quite like the simple (yet effective) Michael Nygard format as prescribed on his blog and have been using this at work for about a year now and it has definitely helped.

Essentially, you want to keep the document brief and to the point. Followed to its prescribed style, you would create a document with architectural option(s) in a “Proposed” state which the team will use as a base to discuss further options. At the end of the discussion, the ADR will either be “Accepted” or it will be “Superseded”. At each stage, you push this document to your code repository (right next to the code that this document pertains to).

This of course could be a bit laborious and could also isolate you as the developer/architect into a corner using only text files to communicate. I’ve found more value in the following approach (of our own invention):

  1. For architecturally significant* work, we put an investigation/spike story (timeboxed to 2 days max) on our backlog with goals and outcomes defined.
  2. Somebody will then pick up this investigation work (this should ideally be rotated amongst team members so they get a chance to shape and contribute to, the architecture and learn in the process).
  3. During the investigation this “architect” will explore various architectural/design options to solve the problem, write PoCs (Proofs of Concept) to make ideas a bit more concrete and then share the findings with the team.
  4. Team will then deep dive into these findings and pick the option that fits the bill based on domain requirements and any technical constraints (for e.g. our security posture doesn’t support containers as a deployment option so we can’t Dockerise our app so a solution calling for it won’t work, or the domain requirement is to have an audit trail of changes made to the state of the system so the architecture needs to cater for that). This collective brainstorming gives everyone a chance to contribute actively and is simply indispensable.

    Your team could even propose alternatives that you as an investigator didn’t consider yourself. Its this collaborative evolution of a design that leads to more effective knowledge sharing all the while destroying the ivory towers.
  5. Once the decision has been made, the original “architect” will then log the decision in the ADR highlighting all the “also ran” options so the reader has perspective. This decision will then be pushed to the code repository in an “Accepted” state. It should not always be the same person who does this, others need to learn it as well.
  6. You can log auxiliary decisions that are not necessarily architecturally significant but its good to log them anyway, in a separate decision log. For e.g.

    10-Dec-2019 Don’t use DI for the Calculation Engine in the Shipment Tracking Domain Model
    We’ve chosen to forego dependency injecting the ShipmentTrackingApproximator into the ShipmentTracker use case because the dependency is internal to it and only contains stateless computational algorithms of which there is only ever going to be one implementation. This also simplifies the dependency graph of the use case.

You could come up with a variation of your own that works for you and your team.

There is a whole host of architectural document types that you can get into but the point of this is not to get bogged down by the ceremony of it but get started with the simplest possible tool and cultivate a discipline around this.

We don’t even use any command line tools for this, simply copy and paste a template Markdown file and fill it up! Couldn’t be simpler!

*Architecturally significant work/decisions are those that have a high cost of fixing if done the wrong way. For e.g. splitting a simple CRUD application into microservices could be a costly mistake to undo. Or even worse, choosing an outdated/not fit for purpose language for development work.

Modern architectural styles like Ports and Adapters (which I very much like and have written about) could allow you to reduce this significance to some level by decoupling the volatile components of your architecture from the domain model.

This way, if you realise that the datastore you picked initially is not going to be able to meet the future needs, then you can write a new “adapter” for a different data store and migrate to it incrementally. Regardless, there is going to be time, effort and risk involved so the goal is to minimise that kind of back-tracking too late into the project by investing some time doing just enough up-front design & investigation work, having a fallback in-case things don’t pan out & documenting this analysis in an ADR.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Category

architecture, design, best practices, software architecture, Uncategorized

Tags

, , , , , , , , , ,