An episode compiled from earlier material on evolutionary design
The episode opens by noting that it differs from usual: it is a compilation of previous episodes on evolutionary design and architecture.
Dave Farley's compilation argues for designing incrementally, treating guesses as experiments, and keeping the ability to change software as its core design goal
The episode opens by noting that it differs from usual: it is a compilation of previous episodes on evolutionary design and architecture.
Farley says that building a system for millions of users when only 10 people show up wastes effort, and building it for 10 when a million arrive will not work either. Because software is complex, teams almost never get it right first time. Requirements will be wrong, the problem will be misunderstood, the solution will fall short of expectations, and first attempts may not land with users.
He adds that new ideas will keep changing understanding and prompt changes to the code. In his view this is normal and inevitable, a fundamental part of the creative process of software production, so the only sensible response is an evolutionary, incremental approach to design.
Farley says he has never thought agile development meant that teams should stop designing; he argues the reverse. In his view, coding is all about design, so whenever a team is coding it is already designing. Working in an agile way means designing incrementally all the time.
He notes the difficulty is the fine line between good design done continuously and a naive floundering with no real design direction. Some upfront thinking is therefore needed to get started.
Farley describes two extremes. At one end is big upfront design, an old but still common antipattern that attempts to specify the design, sometimes in great detail, before work on the code begins. At the other end is doing no design. He says both extremes are wrong and probably doomed to failure, and sums up the point with the line: "Big upfront design is dumb. No upfront design is dumber."
The practical starting point, he says, is a guess based on your understanding of the problem so far and your experience. A capable practitioner treats that guess as an experiment and asks how they could show it is wrong. Working incrementally, whether in fine-grained design or big-picture architecture, is essential to doing a good job on anything complex.
Farley cautions against a naive reading of YAGNI, under which one need not think about good design yet because the code is simple enough that any design will work. He agrees this holds for the first step, where putting everything into one class is no big deal. The problem is that after a few more steps it becomes a pain, and it is not clear when that line has been crossed.
His advice is to adopt heuristics that guide design decisions and apply them from day one and every time a design problem comes up. Otherwise, the investment in code and tests will eventually stop a team from changing things when it should. He does not think YAGNI was meant to work against good design; rather, it was aimed at the problems of overengineering.
Farley gives an example of a bookshop. If he starts from the belief that the shop will one day need to scale to millions of users and builds it that way from scratch, but only three users ever show up, he has wasted a huge amount of time and money. YAGNI steers teams away from designing for scale they do not need, toward the simplest thing that can possibly work.
He adds that smart design keeps the door open. Even if scalability is not built now, the system should be designed so that, on the day it is needed, the team is not scared to death and can evolve what already exists.
Before continuing, the episode presents a sponsor segment for Equal Experts, Transfix, Octopus Deploy, Zoole and Smartbear, which is separate from the design discussion.
Farley says he can write a social media system or a web-based bookshop application in less than a week if it only needs to serve a few hundred people and does not need to be resilient, secure, scalable or auditable. Yet companies such as Amazon, Twitter and Facebook took years to reach their current states. The reason, he says, is not that they kept adding functional features, since that is not the hard part. It is the non-functional work that makes the problem genuinely difficult, and that can only be solved by trying things out and seeing what really works.
He states that the difference in effort between a simple functional-only version and a real-world whole system is orders of magnitude more on the non-functional side.
Farley uses a trading system as an example. One requirement may be that the system reliably and repeatably responds within a fixed and usually very small period of time. He says this is not a separate quality but a fundamental behavior or need, one that will define success or failure for this kind of software. A maximum latency of 1 millisecond, he says, is as real a business requirement as being able to place an order, and there is nothing non-functional about it.
He also suggests that such technical stories are really another category of user stories. Behind every technical story there are user values trying to get out, such as wanting results of orders returned quickly or continuing to place orders even when a data center is struck.
Farley recounts a conversation with his friend Kevlyn Henny about design. Henny said that as soon as someone says "I don't know," there is a seam in the design, which Farley calls a good way to think. Teams should start the design with their best guesses based on what they know and watch for things they do not know or are unsure about.
They do not need to explore those unknowns depth-first, and in fact should not. Instead, they should insulate what they understand from what they do not. Crude sketches in code and abstraction can act as placeholders while understanding grows.
Farley advises not to build world-class security into the first sketches of a system, and not to take on the burden of making it perfectly scalable from day one. But the system should be designed as well as one can imagine so that security can be enhanced later without undoing the progress already made, and so that the existing work can be allocated differently to scale if demand arises.
He acknowledges that these things are complicated and slippery, and suggests the answer comes in three parts: model, compartmentalize and assert.
Farley says teams should model their current understanding using techniques for managing complexity, and design the system to stay easy to change as they learn more. They should begin by designing it as though it were a small, simple system focused on satisfying basic user needs, and where possible defer decisions on details, particularly non-functional requirements.
He describes this as a fairly nuanced approach. The aim is to think enough about what might be difficult in the future to insulate oneself from it, so progress can be made without solving every problem now.
To illustrate, Farley considers the storage problem of a bookstore. Rather than fixing a storage decision before enough is known, he proposes writing a version that does not fix it. The current understanding is that each book needs at least a title and an author to support searching, and probably a price to support buying later.
He suggests creating a separate module for supplying books, a book repository or book list, with an interface that, given a title and an author, can find a book. This module can start out backed by a file if that is the simplest choice. The core bookstore code then knows nothing about the file or how it works; it only asks for books and gets them when needed.
Later the file-based version could be replaced with a database or a globally scalable cloud data store without changing the store code. Farley says that if you start by refusing to let any notion of how storage works leak into the store, it usually pushes you toward nicer design directions and more flexible code. He acknowledges that this information hiding at module boundaries costs some more code, but says it is a better design and the extra code is mostly trivial.
The episode also describes facades in this context as usually very simple, concretely encoding only the essential dependencies that matter to the application. They are never globally generic and are always a subset of the underlying storage technology, so they are simpler. They provide seams that make code more testable and let teams defer the complex parts of a problem until they need to worry about them.
Farley returns to replacing something like Twitter. One feature is populating a user's timeline with messages they are interested in. A simple approach would be to send all messages to every user and then filter out what they do not care about. That would be relatively easy to start with and would probably work for small numbers of users, but Farley guesses it would not scale well, and says he would not start by writing it that way.
Instead, he suggests treating this as two separate problems. One is the list of things a user is interested in. The other is dealing with all the messages so that a timeline can be built for each user. If the system succeeds, the second group could become a firehose of millions or billions of messages, and that part may one day become very complicated, with no current idea of how to solve it.
The user's preferences, such as who they follow and who follows them, are different. Mostly only the user is interested in these, so the system can be basically relatively simple for this part. Each user could have dedicated storage, a shard tied to them, holding everything relevant to them. To support more users, one adds more storage. These are very different kinds of scaling problems, and separating them keeps options open.
Farley says separation of concerns, informed by thinking about non-functional properties, means that however complicated the firehose and popularity problems become, they are at least somewhat distinct from one another. Where choices do not work out, this can be discovered later, and a compartmentalized system will be easier to change.
The other thing that helps spot wrong assumptions is asserting them, which clearly takes the form of tests. For example, if a system today processes 100 users and is expected to work for a thousand one day, one should write a test today that verifies it works for 100. When ready to grow it to a thousand, the test shows what happens.
Farley describes a team that designed and developed a multi-data-center messaging and clustering system with full disaster recovery and predictable minimal data loss for their exchange. As he recalls, it was done over a period of a month or two and released progressively in a series of tiny steps.
Each step was seen in production and learned from as its capabilities grew. Each step added some form of user value, and that is how the team organized and planned all the work.
When building the exchange at Elmax, Farley says there were three different fundamental attempts at the basic architecture of the system. Because the team had taken an incremental approach to design, only a small part of the effort was lost on each change.
He says he has long thought that a sign of a well-designed system and a good team is that if any team member is asked to add a new feature, they will answer with very similar solutions. Because the system has structure, each feature has a natural home, and the team shares a big-picture model of how the system works that helps decision-making and keeps the code readable in bite-sized sentences. Many systems and teams cannot pass this test, but the good ones can.
Farley argues that however smart people are, and even if they perfectly understand the problem, the real world is not that simple. It will change behind our backs and invalidate our assumptions. Software is not built once and then stands perfect forever; real software is much more organic. So the ability to change it is a fundamental aspect of its quality.
He goes further: once a system works, maintaining the ability to change it is what good design is really all about. All that is required is enough understanding to isolate concerns so they can be examined in more detail separately later. This takes some skill but does not rely on being an omniscient genius.
자막에서 근거가 되는 대목을 찾아 답합니다.
Modern Software Engineering의 다음 글도 받아볼까요?
Modern Software Engineering에 새 영상이 올라오면, 방금 읽으신 것처럼 정리해서 메일로 보내 드릴게요.
이 채널은 지난 7일 동안 1편 올렸어요.
사람 없이 소프트웨어 팩토리가 돌아갈 수 있을까? Matt Wynne이 직접 만들어 본 교훈6시간 전 게시 · 14:00 · 조회 1,129 · 5시간 전 생성
런던 핀테크 팀이 AI와 페어링하면서도 통제를 잃지 않는 방법, 그리고 신입에게 의미하는 것Modern Software Engineering1주 전 게시 · 13:37 · 조회 8,446 · 6일 전 생성
당신의 소프트웨어만큼 안전한 소프트웨어로 움직이는 자동차를 탈 것인가?Modern Software Engineering1주 전 게시 · 23:42 · 조회 1.1만 · 1주 전 생성