The Tools of an Engineering Discipline

When I think about what a genuine engineering discipline for software should mean, I don’t think much in terms of specific tools, programming languages, processes, or diagramming techniques. Rather, I think of outcomes.

Any approach worth the name of software engineering must be built around our need to learn, to explore, and to experiment with ideas. Most importantly, if it doesn’t help us build better software faster, it is “fashion” rather than engineering. Engineering is the stuff that works; if it doesn’t work, we will change it until it does.

Although I may not be thinking of specific tools, that doesn’t mean there are none. This book is built on the idea that there are some intellectual “tools” that we can apply universally to software development that significantly improve our chances of building better software faster. All ideas are not equal; there are some ideas that are simply bad, and we should be able to discard them.

In this chapter, I examine some ideas that I have spoken about throughout this book. These ideas pull together everything else in the book. If you ignored everything else that I have written, adopted only these ideas, and treated them as the founding principles on which you undertook software development, then you would find that you got better results and that you would, over time, discover all of the other ideas that I have written about here, because they follow as a logical consequence.

What Is Software Development?

Software development is certainly more than simply knowing the syntax and libraries associated with a programming language. The ideas that we capture are in many ways more important than the tools that we use to capture them. After all, we get paid to solve problems, not wield tools.

What does it mean to write software, for any purpose, if we don’t know if it works?

If we carefully examine the code that we wrote but never run it, then we are placing ourselves as hostages to fortune. Humans just don’t work like that. Even for loosely interpreted languages like a human spoken language, we make mistakes all the time. Have you ever written anything—an email, perhaps—sent it without proofreading it, and then, only too late, spotted all the grammatical errors or spelling mistakes?

My editors and I have worked very hard to eliminate mistakes in this book, but I am pretty sure that you have found a few nonetheless. Humans are error-prone. We are particularly bad at checking things over, because we often tend to see what we expect to see, rather than what is really there. This is not a criticism of our laziness as much as a recognition of the limitations of our biology. We are built to jump to conclusions, a very good trait for wild humans in hostile environments.

Software is intolerant of errors; proofreading and code review are not enough. We need to test it to check that it works. That testing can take a variety of forms, but whether it is us informally running the code and watching what happens or running it in a debugger to watch how things change or running a battery of behavior-driven development (BDD) scenarios, it is all just us attempting to get feedback on our changes.

As discussed in Chapter 5 , feedback needs to be fast and efficient to be valuable.

If we must test it then, the only question now is, how should we do that as efficiently and effectively as possible?

We could decide to wait until we think that we are finished with our work and then test everything together. Maybe we could just release our software into production and let our users test it for us for free? That’s not the most likely route to success! There is a commercial cost to low-quality work; this is why taking an engineering approach to software development matters.

Instead of crossing our fingers and hoping that our code works, we should probably do some form of evaluation before we release changes into production. There are a few different ways that we could organize that.

If we wait until we think we are finished, we are clearly not getting high-quality, timely feedback . We will probably forget all the little nuances of what we did, so our testing will be somewhat cursory. It is also going to be quite the chore.

At this point, many organizations decide to hire people to do that chore for us. Now we are back to square one, hostages to fortune, guessing that our software will probably work and relying on others to tell us that it didn’t. This is certainly a step forward compared to waiting to hear the wails of our users in production, but it is still a low-quality outcome.

Adding separate steps into the process, in the form of separate groups of people, does not improve the speed or quality of the feedback that we can collect. This is not criticism of the people involved; all people are too slow, too variable in what they do, and too expensive to rival an automated approach to gathering the feedback that we need.

We are also going to receive this feedback too late and have no idea of how good or bad our software is while we are developing it. This means we will miss out on the valuable learning opportunities that we could have benefited from if the feedback had been more timely. Instead, we wait until we think that we are finished and then get low-quality, slow feedback from people, however skilled and however diligent they are, who don’t know the inner workings of a system that wasn’t designed with testing in mind.

I suppose that it is possible that we may end up being pleasantly surprised at the quality of our software, but I suspect that it is much more likely that we will be shocked by the dumb errors that we left in. Remember, we have done no other testing, not even run it until now.

I am sure you can tell that I don’t think this is anywhere close to good enough.

This is a bad idea, so we must build some kind of checks into our process before we get this far. This is much too late to find out that users can’t log in and that our cool new feature actually corrupts the disk.

So if we must do some testing, let’s be smart about it. How can we organize our work in a way that minimizes the amount of work that we need to do and maximizes the insight that we can gain as we proceed?

In Part II , we talked about optimizing for learning, so what is it that we wish to learn, and what is the most efficient, effective way to do it?

There are four categories of learning relevant at the point where we are about to write some code:

  • “Are we solving the right problem?”

  • “Does our solution work as we think?”

  • “What is the quality of our work?”

  • “Are we working efficiently?”

These are certainly complex questions to answer, but fundamentally that is all we are interested in when we develop software.

Testability as a Tool

If we are going to test our software, then it makes sense that, to make our lives easier, we should make our software easy to test. I already described (in Chapter 11 ) how separation of concerns and dependency injection can make our code more testable. In fact, it is hard to imagine code that is testable that is not also modular, is cohesive, has a good separation of concerns , and exhibits information hiding. If it does all these things, then it will inevitably be appropriately coupled .

Let’s look at a simple example of the impact of making our code more testable . In this example, I am not going to do anything other than follow the line of reasoning that I want to be able to test something. Listing 14.1 shows a simple Car class.

Listing 14.1 Simple Car Example

Click here to view code image

  public class Car {
    private final Engine engine = new PetrolEngine();
    public void start() {
        putIntoPark();
        applyBrakes();
        this.engine.start();
    }
    private void applyBrakes() {
    }
    private void putIntoPark() {
    }
}

This class has an engine, a PetrolEngine . When you “start the car,” it does a few things. The engine puts the Car into park, applies the brakes, and starts the Engine . That looks OK; lots of people would write code that looks something like this.

Now let’s test it, as shown in Listing 14.2.

Listing 14.2 Test for a Simple Car

Click here to view code image

@Test
public void shouldStartCarEngine() {
    Car car = new Car();
    car.start();
    // Nothing to assert!!
}

Immediately, we run into a problem. Unless we decide to break the encapsulation of our car and make the private field engine public, or provide some other nasty, backdoor hack that allows our test to read a private variable (both of which are terrible ideas by the way), then we can’t test the Car ! This code is simply not testable because we can’t see the effect of “starting the car.”

The problem here is that we have hit some kind of endpoint. Our last point of access to the Car is to call the start method. After that, the internal workings are invisible to us. If we want to test the Car , we need to allow access in some way that isn’t just a special case for testing. We’d like to be able to see the engine.

We can address that, in this case, by adding a measurement point through dependency injection . Here is an example of a better car; in this example, instead of hiding the Engine , we will pass the BetterCar an Engine that we’d like it to use. Listing 14.3 shows the BetterCar , and Listing 14.4 shows its test.

Listing 14.3 BetterCar

Click here to view code image

public class BetterCar {
    private final Engine engine;
    public BetterCar(Engine engine) {
        this.engine = engine;
    }
    public void start() {
        putIntoPark();
        applyBrakes();
        this.engine.start();
    }
    private void applyBrakes() {
    }
    private void putIntoPark() {
    }

Listing 14.3 injects an Engine . This simple step completely changes the coupling with the PetrolEngine ; now our class is more abstract because it deals in terms of Engine instead of PetrolEngine . It has improved the separation of concerns and cohesion because now the BetterCar is no longer interested in how to create a PetrolEngine .

In Listing 14.4, we see the test for the BetterCar .

Listing 14.4 Test for a BetterCar

Click here to view code image

@Test
public void shouldStartBetterCarEngine() {
    FakeEngine engine = new FakeEngine();
    BetterCar car = new BetterCar(engine);
    car.start();
    assertTrue(engine.startedSuccessfully());
}

This BetterCarTest uses a FakeEngine , shown for completeness in Listing 14.5.

Listing 14.5 FakeEngine to Help Test a BetterCar

Click here to view code image

public class FakeEngine implements Engine {
    private boolean started = false;
    @Override
    public void start() {
        started = true;
    }
    public boolean startedSuccessfully() {
        return started;
    }
}

The FakeEngine does nothing except record that start was called. 1

This simple change made our code testable and, as we have seen, better. However, as well as the perhaps seemingly abstract attributes of quality, such as modularity and cohesion, it is better in a simpler, more practical way.

Because we made our code testable, it is now more flexible. Creating a BetterCar with a PetrolEngine is simple, but so is creating a BetterCar with an ElectricEngine or a FakeEngine or even, if we are a bit crazy, a JetEngine . Our BetterCar is better code, and it is better code because we focused on making it easier to test.

Designing to improve the testability of our code makes us design higher quality code. It is, of course, no panacea. If you are bad at coding, your coding may still be bad, but it will be better than you’d normally achieve if you work to make it testable. If you are great at coding, your code will be greater because you made it testable.

Measurement Points

The FakeEngine in our example demonstrates another important idea: measurement points . If we want our code to be testable, we need to be able to control the variables. We want to be able to inject precisely the information that we need and only that information. To get our software into a state where we can test it, we invoke some behavior, and then we need the results to be visible and measurable.

  1. In a real test, we’d choose to use a Mocking library rather than write this code ourselves. I included the FakeEngine code here to make the example clear.

This is really what I mean when I say “design for testability.” We are going to design our systems so that there are many measurement points, places where we can examine the behavior of our system without compromising its integrity. These measurement points will take different forms, depending on the nature of the component and the level at which we are thinking about testability.

For fine-grained testing, we will rely on parameters and return values from functions or methods, but we will also use dependency injection , as demonstrated in Listing 14.4.

For larger-scale, system-level testing, we will fake external dependencies so that we can insert our measurement point probes into the system allowing us to inject test inputs or collect test outputs, as I described in Chapter 9 .

Problems with Achieving Testability

Many teams struggle to achieve the kind of testability that I am describing here, and there are two primary reasons for that. One is a technical difficulty; the other is a more cultural problem.

As we have already explored, any form of testing needs us to have access to some sensible measurement points. This is fine for most of our code. With techniques like dependency injection and good modular design, we can organize our code to be testable, but this becomes difficult at the edges of our system, the points at which our system interacts in some way with the real world (or at least a close computer facsimile of it).

If we write code that writes to disk, draws on a screen, or controls or reacts to some other hardware device, then that edge of the system is difficult to test, because how do we inject some test code to either inject test data or collect test results?

The obvious answer to this problem is to design our systems so that these “edges” in our code are pushed to the margins and minimized in their complexity. This is really about reducing the coupling of the bulk of the system with respect to these edges. This, in turn, reduces our dependence on third-party software elements and leaves our code more flexible, for little extra work.

We create some suitable abstraction that represents our interaction at this edge, write tests that evaluate the interaction of our system to a fake version of this abstraction, and then write some simple code to translate the abstraction into a real interaction with the edge technology. That is a lengthy way of saying that we add a level of indirection.

Listing 14.6 shows a simple example of some code that needs to display something. We could create a robot with a camera to record the output on a screen of some kind, but that would be overkill. Instead, we abstract the act of showing some result by injecting a piece of my code that provides the ability to “display” some text.

Listing 14.6 Stuff to Display

Click here to view code image

public interface Display
{
    void show(String stringToDisplay);
}
public class MyClassWithStuffToDisplay
{
    private final Display display;
    public MyClassWithStuffToDisplay(Display display)
    {
        this.display = display;
    }
    public void showStuff(String stuff)
    {
        display.show(stuff);
    }
}

By abstracting the act of displaying information, I have gained the nice side effect that my class with stuff to display is now decoupled from any actual display device, at least outside of the bounds of the abstraction that I have provided. Obviously, this also means that now we can test this code in the absence of a real Display . I have included an example of such a test in Listing 14.7.

Listing 14.7 Testing Stuff to Display

Click here to view code image

@Test
public void shouldDisplayOutput() throws Exception
{
    Display display = mock(Display.class);
    MyClassWithStuffToDisplay displayable = new MyClassWithStuffToDisplay(display);
    displayable.showStuff("My stuff");
    verify(display).show(eq("My stuff"));
}

Finally, we can create a concrete implementation of Display . In this simple case shown in Listing 14.8, it’s a ConsoleDisplay , but we could imagine replacing this with all kinds of different options if the need arose, such as LaserDisplayBoard , MindImprintDisplay , 3DGameEngineDisplay , and so on.

Listing 14.8 Displaying Stuff

Click here to view code image

public class ConsoleDisplay implements Display
{
    @Override
    public void show(String stringToDisplay)
    {
        System.out.println(stringToDisplay);
    }
}

Listings 14.5 to 14.8 are trivial, and the abstraction would clearly need to be more complex if the technology that we are interacting with at this edge was more complex, but the principle remains.

Testing at the Edges

On one project that I worked on, we abstracted the web DOM in this way in order to make our web page logic unit testable.

There are better options now, but at the time it was tricky to unit test web applications in the absence of a real browser. We didn’t want to slow down our testing by having to start up a browser instance for each test case, so we changed how we wrote our UI.

We wrote a library of UI components that “sat in front of the DOM” (Ports & Adapters for the DOM), so if we needed a table, we created a JavaScript Table via our own DOM factory. At runtime, that gave us a thin facade object that gave us a table we could use. At test time, it gave us a stub we could test against but didn’t require the presence of a real browser or DOM.

You can always do this. It is really only a matter of how easy, or difficult, the tech that you are trying to abstract is and the degree to which you think this is important enough to expend the effort.

For these “edges of the system,” it is nearly always worth the effort. Sometimes, in a web UI or mobile app testing, for example, other people may have done the work for you, but this is how to unit test to the edges.

The problem with this approach, and any approach to solving this problem really, is cultural. If we take testability seriously and adopt it in our approach to design from the outset, this is all pretty easy.

It gets much more difficult when we hit code that wasn’t built with testability in mind, or people don’t think it’s important. This clash of cultures is a tough problem.

The code is probably the easier part of the problem to deal with, though easier does not necessarily mean “easy.” We can always add our own abstractions, even if they are leaky ones, and make it easier to test. If we really must, we can include the intransigent “edge” code within the scope of our test. This is an unpleasant compromise, but it’s workable in some circumstances.

The difficult problem is people. I am not arrogant enough to state that there has never been a team that has practiced true TDD, in the sense of “Write a test before you write the code-driven development,” and found it didn’t work, but I have never met one.

I have met lots of teams that have told me that “We tried TDD, and it didn’t work,” but what all of the groups that I have met meant when they said that was that they had tried writing unit tests after they had written the code. This is not the same thing by a long margin.

The difference is that TDD encourages the design of testable code and unit testing does not. Unit testing, after the code is written, encourages us to cut corners, break encapsulation, and tightly couple our test to the code that we already wrote.

TDD is essential as a cornerstone for an engineering approach to software development. I don’t know of any other practice that is as effective at encouraging and amplifying our ability to create good design in line with the ideas in this book.

The strongest argument against TDD that I sometimes hear is that it compromises the quality of design and limits our ability to change code, because the tests are coupled to the code. I have simply never seen this in a codebase created with “test-first TDD.” It is common—I’d say inevitable—as a result of “test-after unit testing,” though. So my suspicion is that when people say “TDD doesn’t work,”  what they really mean is that they haven’t really tried TDD, and while I am sure that this is probably not true in all cases, I am equally certain that it is true in the majority and so a good approximation for truth.

The criticism on the quality of design is particularly close to my heart because, as I suspect you can see from this book, I care very much about the quality of design.

I would be disingenuous if I pretended that I don’t have some skill at software development, software design, and TDD. I am pretty good at it, and I can only guess at the reasons why. I am experienced, sure. I probably have some natural talent, but much more importantly than all these things, I have some good habits that keep me out of trouble. TDD gives me clearer feedback on the quality of my design as it evolves than anything else that I am aware of and is a cornerstone of the way that I work and recommend others to work.

How to Improve Testability

Part II describes the importance of optimizing for learning. I don’t mean this in some grandiose, academic sense. I mean it in the fine-grained, practical sense of everyday engineering. So we will work iteratively, adding a test for the piece of work in front of us. We want fast, efficient, clear feedback from our test so that we can learn quickly, on tiny timescales, every few minutes that our code is doing exactly what we expect.

To do that, we want to compartmentalize our system so that we can clearly see what that feedback means. We will work incrementally on small, separate pieces of code, limiting the scope of our evaluations so that it is clear what is happening as we proceed.

We can work experimentally, structuring each test case as a small experiment that predicts and verifies the behavior that we want of our code. We write a test to capture that hypothesis of how the software should behave. We predict how the test will fail before we run it so that we can verify that our test is in fact testing what we expect it to. Then we can create code that makes the test pass and use the stable, passing combination of code and test as a platform to review our design and make small, safe, behavior-preserving changes to optimize the quality of our code and our tests.

This approach gives us deep insight into our design as it progresses in a much more profound sense than merely “does it pass a test?” If we pay attention, the testability of our code guides us in the direction of a higher-quality outcome.

We don’t have enough tools that do this kind of thing for us, and we ignore this one at our peril. Too many developers and development teams ignore this and produce worse software, more slowly, than they could and should.

If the test before you is difficult to write, the design of the code that you are working with is poor and needs to be improved.

The testability of our system is fractal. We can observe it and use it as a tool, at both the level of whole enterprise systems and at the narrow focus of a few lines of code, but it is one of the most powerful tools in our tool chest.

At the fine-grained level of functions and classes, the most important aspect of testability to focus on is the measurement points. They define the ease with which we can establish our code in a particular state and the ease with which we can observe and evaluate the results of its behavior.

At a more systemic and multisystemic level, the focus is more on the scope of evaluation and testing. The fundamentals of measurement points still matter, but the scope of evaluation is an important tool.

Deployability

In my book Continuous Delivery , we described an approach to development based on the idea of working so that our software is always in a releasable state. After each small change, we evaluate our software to determine its releasability, and we gain that feedback multiple times per day.

To achieve this, we employ a mechanism called a deployment pipeline . The deployment pipeline is intended to determine releasability, as far as practical, through high levels of automation.

So what does “releasable” mean? Inevitably that is somewhat contextual.

We’d certainly need to know that the code did what the developers thought it did, and then it would be good to know that it did what the users needed it to do. After that, we’d like to know if the software was fast enough, secure enough, resilient enough, and maybe compliant with any applicable regulations.

These are all tasks for a deployment pipeline. So far I have described the deployment pipeline in terms of releasability, but there is a small nuance that I want to get out of the way before we move on.

Actually, when describing deployment pipelines, I make a distinction between releasable and deployable . It is a subtle point, but from a development perspective, I want to separate the idea of being “ready to deploy a change into production” from “releasing a feature to users.”

In continuous delivery we want the freedom to create new features over a series of deployments. So at this point I am going to switch from talking about releasability , which implies some feature completeness and utility to users, to deployability , which means that the software is safe to release into production, even if some features are not yet ready for use and are hidden in some way.

So the deployability of our system consists of a number of different attributes; the unit of software must be capable of deployment, and it must fulfil all of the properties of releasability that make sense in the context of that system: fast enough, secure enough, resilient enough, working, and so on.

This idea of deployability is an extremely useful tool at the system and architectural level. If the deployment pipeline says that the system is deployable, it is ready to be deployed into production.

Lots of people misunderstand this about continuous delivery, but this is what a deployment pipeline is for. If the deployment pipeline says that the change is good, there is no more testing to be done, no more sign-offs, and no further integration testing with other parts of the system before we deploy the change into production. We don’t have to deploy into production, but if the change was approved by the pipeline, it is ready, if we choose to.

This discipline says something important. It defines deployability as there being “no more work to do,” and that means to achieve a deployable outcome, we must take the ideas of modularity, cohesion, separation of concerns, coupling, and information hiding seriously at the level of deployable units of software .

The scope of our evaluation should always be an independently deployable unit of software . If we can’t confidently release our change into production without further work, then our unit of evaluation, the scope of our deployment pipeline, is incorrect.

There are a variety of ways to approach this. We can choose to include everything in our system within the scope of evaluation, within the scope of our deployment pipeline, or we can choose to decompose our system into independently deployable units of software, but nothing else makes sense.

We can organize multiple components of our system to be built in separate places, from separate repos, but the scope of evaluation is driven by the demands of deployability. So if we choose this path and feel it essential to evaluate these components together before release, then the scope of evaluation, the scope of the deployment pipeline, is still the whole system. This is important because however fast the evaluation of a small part of the system, it is the time it takes to evaluate the deployability of a change that really matters. So this is the scope that should be the target for our optimization.

This means that deployability is a vital concern in creating systems. Thinking in these terms means that it helps to focus us on the problem that we must address. How do we get feedback in a sensible timeframe that allows us to direct our development efforts?

Speed

This brings us to speed . As we discussed in Part II, the speed and quality of the feedback that we get in our development process are essential to allowing us to optimize for learning. In Chapter 3 we discussed the importance of measurement and focused on the use of stability , and throughput . Throughput, as a measure of the efficiency of our development process, is clearly speed-related.

When I consult with teams to help them adopt continuous delivery, I advise them to focus on working to reduce the time it takes to gain feedback.

I usually offer some guidelines: I tell them to work to optimize their development process so that they can achieve a releasable outcome, a production-quality deployable unit of software, multiple times per day, with a strong preference for shorter times. As a target, I generally recommend aiming to have something that you could deploy into production in less than one hour from the commit of any change.

This can be a challenging target, but just consider what such a target implies. You can’t have teams that are too large, because the communication overhead will slow them down too much. You can’t have siloed teams, because the cost of coordination between teams will be too slow. You have to have a great position on automated testing, you need feedback mechanisms like continuous integration and continuous delivery, you have to have good architecture to support these kinds of strategies, and you need to be evaluating independently deployable units of software and many more things to get to a releasable outcome in less than one hour.

If you take an iterative, experimental approach to only improving the speed of feedback in your development process, it acts as a kind of fitness function for all of agile theory, all of lean theory, and all of continuous delivery and DevOps.

This focus on speed and feedback leads you inexorably to these ideas. That is a much more powerful, measurable guide in the direction of better outcomes than following some rituals or recipes from some off-the-shelf development process. This is the kind of idea that I mean when I talk about engineering for software .

Speed is a tool that we can use to guide us toward higher-quality, more efficient outcomes.

Controlling the Variables

If we want to be able to quickly, reliably, and repeatably test and deploy our systems, we need to limit variance, and we need to control the variables . We want the same results every time that we deploy our software, so we need to automate the deployment and manage the configuration of the systems that we deploy as far as we are able to do so.

Where we can’t exert control, then we have to treat those margins of the system that touch on the uncontrolled world with great care. If we are deploying software to an environment outside of our control, we want to depend on it to the least degree that we can. Abstraction, separation of concerns, and loose coupling are key ideas to limit our exposure to anything outside of our direct control.

We want the tests that we create to give precisely the same results every time that we run them for the same version of the software under test. If test results vary, then we should work to exert greater control to better isolate the test from outside influences or to improve the determinism in our code. Modularity and cohesion, separation of concerns, abstraction, and coupling are yet again key ideas in allowing us to exert this control.

Where there is a temptation to have long-running tests, or manual tests, these are often symptoms of an inappropriate lack of controlling variables.

We often don’t take this idea sufficiently seriously.

Cost of Poor Control

I once consulted for a large organization building a large complex, distributed software system. They had more than 100 teams of developers working on the project. They asked me to advise them on performance testing.

They had created a large complex suite of end-to-end performance tests for the whole system.

They had attempted to run their performance test suite on four occasions, but now they didn’t know what the results meant.

The results were so variable that there was no way to compare them between test runs.

One of the reasons for this was that they had run the test on the corporate network, so depending on what else was going on at the time, the results were completely skewed.

All the work to create these tests and to execute them was essentially waste because no one could tell what the results meant.

Computers give us a fantastic opportunity. Ignoring cosmic rays and neutrino collisions with our NAND gates (both catered for by hardware error-correction protocols), computers, and the software that runs on them, are deterministic. Given the same inputs, computers will generate the same outputs every time. The only limit to this truth is concurrency.

Computers are also incredibly fast, providing us with an unprecedentedly fantastic, experimental platform. We can choose to give up these advantages or to take control and make use of them to our advantage.

How we design and test our systems has a big impact on the degree of control that we can exert. This is yet another advantage of driving our designs from tests.

Reliably testable code is not multithreaded within the scope of a test, except for some very particular kinds of test.

Concurrent code is difficult to test because it is not deterministic. So if we design our code to be testable, we will think carefully about concurrency and work to move it to controlled, well-understood edges of our system.

In my experience, this results in code that is much easier to test because it is deterministic, but also code that is much easier to understand and, certainly in the places where I work, code that is, computationally, much more efficient.

Continuous Delivery

Continuous delivery is an organizing philosophy that helps us bring these ideas together into an effective, efficient, workable approach to development. Working so that our software is always releasable focuses our minds on the scope of evaluation in a deployment pipeline and the deployability of our software. This gives us some tools that we can use to structure our code and our organizations to create these independently deployable units of software .

Continuous delivery is not about automating deployment, though that is part of it; it is about the much more important idea of organizing our work so that we create a semi-continuous flow of changes.

If we take this idea seriously, then it demands of us that we structure all aspects of our development approach to achieve this flow. It has impacts on the structures of our organizations, minimizing organizational dependencies and promoting the autonomy of small teams that can work quickly and with high quality without the need to coordinate their efforts with others.

It demands that we apply high levels of automation, particularly in testing our software, so that we can understand quickly and efficiently that our changes are safe. As a result, it encourages us to take this testing very seriously so we end up with testable software and can benefit from all of the advantages that that brings.

Continuous delivery guides us to test the deployment and configuration of our systems and forces us to take seriously the ideas of controlling the variables so that we can achieve repeatability and reliability in our tests and, as a side effect, in our production deployments.

Continuous delivery is a highly effective strategy around which to build a strong engineering discipline for software development.

General Tools to Support Engineering

These are general tools. These ideas are applicable for any problem in software.

Let’s look at a simple example. Imagine that we want to add some software to our system—a third-party component, subsystem, or framework perhaps. How do we evaluate it?

Of course, it is going to have to work and deliver some kind of value to our system, but before that, I believe that you can use the ideas in this chapter, and the rest of the book, as qualifiers.

Is the tech deployable? Can we automate the deployment of the system so that we can deploy it reliably and repeatably?

Is it testable? Can we confirm that it is doing what we need it to do? It is not our job to test third-party software exhaustively; if we have to do that, it is probably not good enough, not of sufficient high quality, for us to use. However, to the degree that we want to test that it is doing what it needs to in the context of our system, is it configured correctly, is it up and running when we need it to be, and so on? Can we test it?

Does it allow us to control the variables? Can we reliably and repeatably deploy this? Can we version control the deployment and any configuration?

Is it fast enough to work in a continuous delivery setting? Can we deploy it in a reasonable amount of time and get things up and running quickly enough to be able to use it and evaluate it multiple times per day?

If it is a software component that we will be writing code to interface to, does it allow us to maintain a modular approach to the design of our code, or does it force a programming model of its own on us that compromises our design in some way?

The wrong answer to any of these questions should almost certainly disqualify the technology for us before we even look at whether it did a good job and was useful in other contexts.

Unless the service this third-party tech provides is indispensable, I recommend that we seek alternatives. If the service is indispensable, we will need to do work to try to achieve these properties despite the tech. This is a cost that needs to be factored in to the cost-benefit calculation for this tech.

This little example is meant to give a model for the generality of this style of thinking. We can use the tools of learning, the tools of managing complexity, and these tools to support an engineering approach to inform decisions and choices in every aspect of our work.

Summary

This chapter brings together the interlinked ideas that I have presented in this book into a coherent model for developing software more effectively. By adopting the ideas in this chapter as organizing principles for the way that we approach software development, we will get a better outcome than if we ignore them.

That is the best that we can ever hope for from any tool, process, or discipline. There is no guarantee of success, but by applying the thinking that I have described here and throughout this book, I believe that you will create higher-quality code more quickly.