Working Iteratively
Iteration is defined as “a procedure in which repetition of a sequence of operations yields results successively closer to a desired result.” 1
Fundamentally, iteration is a procedure that drives learning. Iteration allows us to learn, react, and adapt to what we have learned. Without iteration, and the closely related activity of collecting feedback, there is no opportunity to learn on an ongoing basis. Fundamentally, iteration allows us to make mistakes and to correct them, or make advances and enhance them.
This definition also reminds us that iteration allows us to progressively approach some goal. Its real power is that it allows us to do this even when we don’t really know how to approach our goals. As long as we have some way of telling whether we are closer to, or further from, our goal, we could even iterate randomly and still achieve our goal. We can discard the steps that take us further away and prefer the steps that move us nearer. This is in essence how evolution works. It is also at the heart of how modern machine learning (ML) works.
- Source: Merriam Webster Dictionary, https://www.merriam-webster.com/dictionary/iteration
The Agile Revolution
Teams were practicing more iterative, feedback-driven approaches to development from at least the 1960s. However, following a famous meeting of leading thinkers and practitioners, at a ski resort in Colorado, the Agile Manifesto outlined a shared philosophy that underpinned these more flexible, learning-centered strategies in contrast to the more heavyweight processes common at the time.
The Agile Manifesto 2 is a simple document. It is 9 lines of text and 12 principles, but it had a big impact.
Before this, the conventional wisdom, with a few quiet dissenters, was that if you were doing anything “serious” in software, then you needed the production-centered techniques of waterfall development.
Agile thinking took a while to break through, but now it, and not waterfall, is the predominant approach, at least in terms of thinking.
However, most organizations are still, at heat, culturally dominated by waterfall thinking at the organizational level, if not also at the technical level.
Nevertheless, agile thinking is built upon significantly more stable foundations than the ideas that went before it. At its heart, the phrase that best captures the ideas, maybe ideals, of the agile community is “inspect and adapt.”
This change in perception is significant, but not enough. Why was this step significant? Because it represents a step in the direction of perceiving software development as a learning exercise rather than a production problem. Waterfall processes can be effective for some kinds of production problems, but they are an extremely poor fit for problems that involve exploration.
This step is important because although Fred Brooks’ 10x step does not appear to be available in terms of technology, tooling, or process, there are some approaches that are so inefficient that improving them by an order of magnitude is perfectly possible. Waterfall, when applied to software development, is such a candidate.
Waterfall-style thinking starts from the assumption that “if we only think/work hard enough, we can get things right at the beginning.”
Agile thinking inverts this. It starts from the assumption that we will inevitably get things wrong. “We won’t understand what the users want,” “we won’t get the design right straight away,” “we won’t know if we have caught all the bugs in the code that we wrote,” and so on and so on. Because they start off assuming that they will make mistakes, agile teams work in a way that, quite intentionally, mitigates the cost of mistakes.
- The Agile Manifesto, https://agilemanifesto.org/
Agile thinking shares this idea with science. Approaching ideas from a skeptical perspective and looking to prove ideas wrong, rather than prove them right (“falsifiability”), are inherent to a more scientific mindset.
These two schools of thought, predictability versus exploration, promote quite radically different, incompatible approaches to project organization and team practice.
Based on the assumptions of agile thinking, we will approach the organization of our teams, processes, and technology to allow us to safely get things wrong, easily observe the mistake, make a change, and, ideally, do better next time.
Arguments over Scrum versus Extreme Programming or continuous integration versus feature branching or TDD versus skilled developers thinking hard, or anything else, are irrelevant. At its heart, any truly agile process is an exercise in “empirical process control.”
This is a significantly better fit for software development, of any kind, than the production-centered, prediction-based waterfall approach that preceded it.
Working iteratively is different in some fundamental ways than working in a more planned, sequential approach. It is, though, a significantly more effective strategy.
To many readers, this may seem obvious, but it is not. Much of the history of software development was spent assuming that iteration was unnecessary and that a detailed plan of all the steps was the goal of the early stages of software development.
Iteration is at the heart of all exploratory learning and is fundamental to any real knowledge acquisition.
Practical Advantages of Working Iteratively
If we approach software engineering as an exercise in discovery and learning, iteration must be at its heart. However, a variety of other advantages to working iteratively may not be evident at first.
Perhaps the most important idea is that if we start to change our working practices to work more iteratively, it automatically narrows our focus and encourages us to think in smaller batches and to take modularity and separation of concerns more seriously. These ideas start out as a natural consequence of working more iteratively, but end up being part of a virtuous circle that enhances the quality of our work.
One of the common ideas from both Scrum and Extreme Programming (XP) was that we should work on small units of work to completion. The agile thought process was, “Progress in software development is hard to measure, but we can measure finished features, so let’s work on smaller features so that we can see when they are finished.”
This reduction in batch size was a big step forward. However, it gets complicated when you want to know how long it will take to “finish.” This iterative approach to development is different from more traditional ways of thinking. For example, in continuous delivery we work so that every small change, multiple times per day, is releasable. It should be finished to the degree that we can safely and reliably release our software into production at any point. So what does “finished” really mean in that context?
Each change is finished because it is releasable, so the only sensible measure of “finished” is that it delivers some value to its users. That is a very subjective thing. How do we predict how many changes are needed to represent “value” to our users? What most organizations do is to guess at a collection of features that, in combination, represent “value,” but if I can release at any point in the life of my software, this is a somewhat blurry concept.
There is a problem with guessing the set of changes that constitute “value,” because it depends on the assumption that you know all of the features that you need when you start and can determine progress toward some idea of “completeness.” This is an over-simplification of what the founders of the agile movement meant, but it is an assumption that most traditional organizations, making the transition to agile planning, have made.
One of the more subtle advantages of working iteratively is that we have a choice. We could iterate on the products that we create and steer them, based on good feedback from our customers and users, toward higher-value outcomes. This is one of the more valuable aspects of this way of working that is often missed by more traditional organizations that attempt to adopt it.
Nevertheless, whatever the intent or the outcome, this small batch–based approach did encourage us, as an industry, to reduce the size and complexity of the features that we would work on, and that is a really important step.
Agile planning depended, to a significant degree, on decomposing work into small enough pieces that we could complete our features within a single sprint, or iteration. Initially this was promoted as a way of measuring progress, but it had the much more profound impact of delivering definitive feedback on the quality and appropriateness of our work on a regular basis. This change increases the rate at which we can learn. Does this design work? Do our users like this feature? Is the system fast enough? Have I eliminated all of the bugs? Is my code nice to work in? and so on.
Working iteratively in small, definitive, and production-ready steps provides us with great feedback!
Iteration as a Defensive Design Strategy
Working iteratively encourages us to take a defensive approach to design. (We discuss the details of this in more depth in Part III .)
An interesting take on the foundations of agile thinking was first presented to me by my friend, Dan North. Dan described the difference between waterfall and agile thinking as, effectively, a problem in economics. Waterfall thinking is promulgated on the assumption that change gets more expensive as time goes on. It classically talks about the Cost of Change model, as represented in Figure 4.1 .
Figure 4.1
The classical cost of change
This worldview is problematic. It means that if this model is correct, the only sensible solution is to make the most important decisions early in the life of a project. The difficulty with this is that early in the life of a project, we know the least that we will ever know about it. So we are making crucial decisions in the life of a project based on ill-informed guesses, however hard we work at this point to inform them.
Software development never begins with “…every piece of work being completely understood,” no matter how hard we analyze things before starting work. Given that we never begin with a “well-defined set of inputs,” no matter how diligently we plan, the defined process model, or waterfall approach, falls at the first hurdle. It is impossible to make software development fit this inappropriate mold.
Surprises, misunderstandings, and mistakes are normal in software development because it is an exercise in exploration and discovery, so we need to focus on learning to protect ourselves from the missteps that we will inevitably make along the way.
Dan North’s alternate view was this: given that the classic Cost of Change model clearly doesn’t help us, what would? How much nicer would it be if we could flatten the Cost of Change curve? (See Figure 4.2 .)
What if we could change our minds, discover new ideas, discover errors, and fix them, all at roughly the same cost whenever that happened? What if the Cost of Change curve was flat?
It would give us the freedom to discover new things and benefit from our discoveries. It would allow us to adopt an approach that would allow us to continuously improve our understanding, our code, and our user’s experience of our products.
Figure 4.2
The agile cost of change
So, what would it take to achieve a flat Cost of Change curve?
We can’t afford to spend lots of time in analysis and design without creating anything, because that means more time not learning what really works. So we need to compress things. We need to work iteratively. We need to do just enough analysis, design, coding, testing, and releasing to get our ideas out into the hands of our customers and users so that we can see what really works. We need to reflect on that and then, given that learning, adapt what we do next to take advantage of it.
This is one of the ideas at the heart of continuous delivery (see Figure 4.3 ).
Figure 4.3
Iteration in continuous delivery
The Lure of the Plan
The people who promoted waterfall thinking were well intentioned. They thought that it was the best way forward. Our industry has spent decades trying to make this approach work, and it doesn’t.
The difficulty here is that a waterfall approach sounds very sensible: “Think carefully before you start,” and “Plan carefully what you are going to do and then execute the plan diligently.” Based on our industrial-age experience, these ideas make a lot of sense. If you have a well-defined process, this defined process control approach works extremely well.
When making physical things, the problems of production engineering and the problems of scaling up often outweigh the problems of design. However, this is changing now even in the manufacture of physical things. As manufacturing gets more flexible and some manufacturing plants can change direction, then even in manufacturing this kind of rigid process has been challenged and overturned. This kind of “production-line” thinking dominated most organizations for at least a century, though, and we are somewhat programmed to think about problems this way.
It takes a difficult intellectual leap to recognize that the paradigm in which you are operating is fundamentally the wrong one. This is even more true when the whole world assumes that paradigm to be correct.
Process Wars
If there is no 10x improvement available from language, formalism, or diagramming, where else can we look?
The way in which we organize ourselves and our approach to the skills and techniques of learning and discovery that seem so inherent to our discipline seem like a fruitful avenue to explore.
In the early days of software development, the early programmers were usually highly educated in mathematics, science, or engineering. They worked as individuals or in small groups to develop systems. These people were explorers in a new domain, and like most explorers, they brought their experience and prejudices along with them. Early approaches to software development were often very mathematical.
As the computer revolution kicked in and software development became more ubiquitous, demand rapidly outstripped supply. We needed to produce more, better software faster! So we started looking at other industries to try to copy how they coped with working efficiently at scale.
This is where we made the horrible mistake of misunderstanding the fundamental nature of software development and misapplied techniques from manufacturing and production. We recruited armies of developers and tried to create the software equivalent of mass-production lines.
The people who did this were not stupid, but they did make a big mistake. The problem is multifaceted. Software is complex stuff, and the process of its creation bears no real relationship to a traditional “production problem,” which is how most people seem to have thought about it.
Initial attempts at industrializing our discipline were painful, pervasive, and very damaging. It resulted in the creation of a lot of software, but much of it was problematic. It was slow, inefficient, late, did not deliver what our users wanted, and was extremely difficult to maintain. Through the 1980s and 1990s software development exploded as a discipline, and so did the complexity of the processes applied to it in many large organizations.
These failings were despite the fact that many aspects of this problem were well understood by leading thinkers in the discipline.
The Mythical Man Month by Fred Brooks, again, described these problems and how to avoid them in some detail in 1970. If you have never read this seminal work in our discipline, you would probably be surprised at how accurately it describes the problems that you, most likely, face nearly every day in your work as a software developer. This despite the fact that it is based on Brooks’s experience of developing the operating system for the IBM 360 mainframe computer in the late 1960s using the comparatively crude technology and tools of the day. Brooks was, yet again, touching on something more important and more fundamental than language, tools, or technology.
During this period many teams produced great software, often completely ignoring the then current “wisdom” of how projects should be planned and managed. There were some common themes in these teams. They tended to be small. The developers were close to the users of their software. They tried ideas quickly and changed tack when things didn’t work as they expected. This was revolutionary stuff during this period—so revolutionary in fact that many of these teams essentially operated in stealth mode, where the organization where they worked applied heavy-weight processes that slowed them down.
By the late 1990s, in reaction to these heavyweight processes, some people began to try to define strategies that were more effective. Several different competing approaches to software development were gaining in popularity. Crystal, Scrum, Extreme Programming, and several others tried to capture this very different approach. These viewpoints were formalized into the Agile Manifesto.
In software, it took the agile revolution to overthrow that norm, but even today many, perhaps even most, organizations at heart remain plan/waterfall-driven.
In addition to the difficulty of recognizing the problem, there remains a fair bit of wishful thinking in organizations that cling to waterfall-style planning. It would be lovely if an organization could:
-
Correctly identify its users’ needs
-
Accurately assess the value to the organization if those needs were met
-
Accurately estimate how much it would cost to fulfill those needs
-
Make a rational decision on whether the benefit outweighed the cost
-
Make an accurate plan
-
Execute the plan without deviation
-
Count the money at the end
The trouble is that this is not credible either at the business level or at a technical level. The real world, and software development within it, just doesn’t work like this.
Industry data says that for the best software companies in the world, two-thirds of their ideas produce zero or negative value. 3 We are terrible at guessing what our users want. Even when we ask our users, they don’t know what they want either. The most effective approach is to iterate. It is accepting that some, maybe even many, of our ideas will be wrong and work in a way that allows us to try them out as quickly, cheaply, and efficiently as possible.
Assessing the business value of an idea is notoriously difficult, too. There is a famous quote from IBM president Thomas J. Watson, who once predicted that the world demand for computers would one day get as high as five!
This is not a technology problem; this is a human-limitation problem. To make progress we must take a chance, make a guess, be willing to take a risk. We are very bad at guessing, though. So to make progress most efficiently, we must organize ourselves so that our guesses won’t destroy us. We need to work more carefully, more defensively. We need to proceed in small steps and limit the scope, or blast radius, of our guesses and learn from them. We need to work iteratively!
Once we have an idea that we would like to execute on, we need to find a way to decide when to stop. How do we call a halt on a bad idea? Once we have decided that the idea is worth the risk of attempting it, how do we limit that blast radius in a way that means that we don’t lose everything on a terrible idea? We need to be able to spot the bad ideas as soon as we can. If we can eliminate the bad ideas just by thinking about it, great. However, many ideas aren’t that obviously bad. Success is a slippery concept. An idea may even be a good idea, but may be let down by bad timing or poor execution.
We need to find a way to try our ideas with minimum cost, so that if it is bad, we can find that out quickly and at relatively low cost. A 2012 survey of software projects carried out by the McKinsey Group in association with Oxford University found that 17% of large projects (budgets over $15M) went so badly that they threatened the existence of the company that undertook them. How can we identify these bad ideas? If we work in small steps, get real reaction to the progress or otherwise, and constantly validate and review our ideas, we can see soonest, with lowest investment, when things start to work differently to our hopes and plans. If we work iteratively in small steps, the cost of any single step going wrong is inevitably lower; therefore, the level of this risk is reduced.
In “The Beginning of Infinity,” David Deutsch describes the profound difference between ideas that are limited in scope and ideas that are not. The comparison of a planned, waterfall, defined-process approach and an iterative, exploratory, experimental approach is a comparison between two such fundamentally different ideas. Defined process control models 4 require a “defined process.” By definition this is finite in scope. At the limit of such an approach, there is, at some level, the capacity of a human brain to hold the detail of the entire process. We can be smart and use ideas like abstraction and concepts like modularity to hide some of the detail, but ultimately defining the process end to end in some kind of plan requires us to have covered everything that will happen. This is an inherently limited approach to solving problems. We can only solve the problems that we can understand up front.
-
Source: “Online Controlled Experiments at Large Scale,” https://stanford.io/2LdjvmC
-
Ken Schwaber described waterfall as a “defined process control model” that he defined as: “The defined process control model requires that every piece of work be completely understood. Given a well-defined set of inputs, the same outputs are generated every time. A defined process can be started and allowed to run until completion, with the same results every time.” Schwaber compares this to the “empirical process control model” represented by an agile approach. See https://bit.ly/2UiaZdS .
An iterative approach is very different. We can begin when we know almost nothing and yet still make useful progress. We can start with some simple, understandable facet of the system. Use this to explore how our team should work on it, try out our first thoughts on the architecture of our system, try out some technologies that we think might be promising, and so on. None of these things is necessarily fixed. We have still made progress even if we found that the tech was a bad idea and our first concept of the architecture was wrong. We now know better than we did before. This is an inherently open-ended, infinite process. As long as we have some kind of “fitness function,” a way of telling if we are heading toward our goal or away from it, we can continue in this vein forever, refining, enhancing, and improving our understanding, our ideas, our skills, and our products. We can even decide to change our “fitness function” along the way if we decide that there are better goals to aim for.
A Beginning of Infinity
In his mind-expanding book The Beginning of Infinity , physicist David Deutsch describes science and the enlightenment as the quest for “good explanations” and explains how various ideas in human history represent a “beginning of infinity” that allow us to cope with any conceivable relevant application of these good explanations.
A good example of this is the difference between an alphabet and a pictographic form of writing.
Humans began with the pictographic forms of writing, and Chinese and Japanese writing still take this form (for some writing styles). These are beautiful to look at, but they have a serious flaw. If you come across a word that is new to you, you hear it spoken; you can’t write it down until you get someone else to tell you how. Pictographic forms of writing are not really incremental; you have to know the correct symbol for each word. (There are approximately 50,000 characters in Chinese writing.)
An alphabet works in a profoundly different way. Alphabets encode sounds, not words. You can spell any word, maybe incorrectly, in a way that anyone can, at least phonetically, understand what you wrote.
This is true even if you have never heard the word spoken or seen it written before.
Equally you can read a word that you don’t know. You can even read words that you don’t understand or don’t know how to pronounce. You can’t do either of these things with pictographic writing. This means that the range of an alphabetic approach to writing is infinite, and a pictographic one is not. One is a scalable approach to representing ideas; the other is not.
This idea of infinite reach or scope is true of an agile approach to development and not true of a waterfall-based approach.
A waterfall approach is sequential. You must answer the questions of the stage that you are in before proceeding to the next stage. This means that however clever we are, there must, at some point, be a limit at which the complexity of the system as a whole goes beyond human understanding.
Human mental capacity is finite, but our capacity to understand is not necessarily so. We can address the physiological limits of our brains by using techniques that we have evolved and developed. We can abstract things, and we can compartmentalize (modularize) our thinking and so scale our understanding to a remarkable degree.
An agile approach to software development actively encourages us to start work on solving problems in smaller pieces. It encourages us to begin work before we know the answer to everything. This approach allows us to make progress, maybe sometimes in suboptimal or even bad directions, but nevertheless, after each step, we learn something new.
This allows us to refine our thinking, identify the next small step, and then take that step. Agile development is an unbounded, infinite approach because we work on small pieces of the problem before moving forward from a known and understood position. This is a profoundly more organic, evolutionary, unbounded approach to problem-solving.
This is a profound difference and explains why agile thinking represents an important and significant step forward in our ability to make progress in solving, ideally, harder and harder problems.
This doesn’t mean that agile thinking is perfect or the final answer. Rather, it is an important, significant, enabling step in the direction of better performance.
The lure of the plan is a false one. This is not a more diligent, more controlled, more professional approach. Rather, it is more limited and more based on hunch and guesswork and can, realistically, work only for small, simple, well-understood, well-defined systems.
The implications of this are significant. It means that we must, as Kent Beck famously said in the subtitle to his seminal work Extreme Programming Explained , “Embrace change”!
We must learn to have the confidence to begin work precisely when we don’t yet know the answers and when we don’t know how much work will be involved. This is disquieting for some people and for some organizations, but it is only the same as the reality of much of the human experience. When a business starts out on a new venture, they don’t really know when, or even whether, it will be a success. They don’t know how many people will like their ideas and whether they will be willing to pay for them.
Even for something as mundane as a trip in your car, you can’t be certain how long it will take or if the route that you pick will still be the best route once you have begun. These days we have wonderful tools like satellite navigation systems with radio connections that not only can plan our route at the start but can iteratively update the picture with traffic information, allowing us to “inspect and adapt” to the changing circumstances of our journey.
An iterative approach to planning and execution allows us to always have the most up-to-date picture of the situation that we are really in, rather than some predictive, theoretical, always-inaccurate version of that situation. It allows us to learn, react, and adapt as changes happen along the way. Working iteratively is the only effective strategy for a changing situation.
Practicalities of Working Iteratively
So, what can we do to work this way? The first thing is to work in smaller batches. We need to reduce the scope of each change and make change in smaller steps; in general, the smaller the better. This allows us to try out our techniques, ideas, and technology more frequently.
Working in small batches also means that we limit the time-horizon over which our assumptions need to hold. The universe has a smaller window of time within which it can intrude on our work, so things are less likely to change in damaging ways. Finally, if we make small steps, even if a small step is invalidated by changing circumstance or just misunderstanding on our part, there is less work lost. So, small steps really matter.
The obvious incarnation of this idea in agile teams is the idea of iterations or sprints. Agile disciplines promote the idea of working to completed, production-ready code, within a small, fixed period of time. This has multiple, beneficial effects, the effects described in this chapter. However, this is only one, coarse-grained incarnation of working more iteratively.
At a completely different scale, you can think of the practices of continuous integration (CI) and test-driven development (TDD) as being inherently iterative processes.
In CI we are going to commit our changes frequently, multiple times per day. This means that each change needs to be atomic, even if the feature that it contributes to is not yet complete. This changes how we approach our work but gives us more opportunities to learn and to understand if our code still works alongside everyone else’s.
TDD is often described by the practices that contribute to it: Red, Green, Refactor.
-
Red: Write a test, run it, and see it fail.
-
Green: Write just enough code to make the test pass, run it, and see it pass.
-
Refactor: Modify the code and the test to make it clear, expressive, elegant, and more general. Run the test after every tiny change and see it pass.
This is a deeply fine-grained, iterative approach. It encourages a substantially more iterative approach to the fundamental technicalities of writing code.
For example, in my own coding, I nearly always introduce new classes, variables, functions, and parameters via a multistage series of tiny refactoring steps, frequently checking that my code continues to work, by running my test, as I go.
This is iterative working at a very fine resolution. It means that my code is correct and working for more of the time, and that means that each step is safer.
At each point in the process, I can re-evaluate and change my mind and the direction of my design and code easily. I keep my options open!
These properties are why working iteratively is so valuable and such a foundationally important practice for an engineering discipline for software development.
Summary
Iteration is an important idea and a foundation of our ability to move toward a more controlled approach to learning, discovery, and better software and software products. However, as ever, there is no free lunch. If we want to work iteratively, we must change the way that we work in many ways to facilitate it.
Working iteratively has an impact on the design of the systems that we build, how we organize our work, and how we structure the organizations in which we work. The idea of iteration is woven deeply into the thinking behind this book and the model for software engineering that I present here. All the ideas are deeply interlinked, and sometimes, it may be tricky to figure out where iteration ends and feedback begins.