About this book
Code Complete was published by Microsoft Press in 1993. Its author, Steve McConnell, was then a working software developer in the Seattle area. He had noticed a gap. There were books on programming languages, on algorithms, on high-level design, and on project management. There was a large and growing body of research on how software is actually built and where its defects come from. But there was no single book that took the everyday work of writing code, the work that fills most of a programmer's days, and treated it as a serious subject with its own body of knowledge. Code Complete set out to be that book.
McConnell gave this everyday work a name: construction. In his usage construction covers detailed design, coding, debugging, unit testing, integration and the small decisions that go with them. It sits between the high-level architecture of a system and its final delivery. It is the part of software work that every project must do, however it is organised, and it is the part where most of the actual lines of code and most of the defects come into being. The book's claim is that construction deserves the same careful attention that had been given to requirements and architecture, and that doing it well has large effects on cost, schedule and quality.
The question the book answers is practical: what does the accumulated experience and research of the field say about how to write good code? McConnell's method is to gather that knowledge from many sources, including published studies, industry experience and the writing of other practitioners, and to organise it into a coherent guide. He cites evidence often, which gave the book a distinctive authority. Where others asserted that a practice was good, McConnell tried to show what studies had found about it.
The book is long, around eight hundred pages in its first edition and somewhat more in its second, and it is organised as a handbook rather than a narrative. It can be read cover to cover, but it is also designed to be consulted. Many chapters end with checklists that a programmer can use when reviewing their own or others' work. The examples are written in several languages so that the advice is not tied to one.
Editions
A second edition appeared in 2004. It updated the examples for the object-oriented languages then dominant, gave more attention to classes and design, added material on refactoring and on writing tests before code, and revised the discussion of the software process in light of the agile methods that had appeared since the first edition. The core of the book, its view of construction and most of its advice on routines, variables, control structures, quality and debugging, remained the same. This companion describes the book in a way that applies to both editions and notes differences only where they are well known.
The title carries a double sense. Code that is complete in the narrow sense compiles and runs. Code that is complete in McConnell's sense is also readable, tested, reviewed, integrated and ready to be changed by someone else. Much of the book is about the distance between those two meanings, and about the work that closes it.
Who it is for
The primary audience is the working programmer who has learned a language and written some code, and now wants to write code that is clearer, more reliable and easier to change. It is also widely used by technical leads and teachers as a reference for standards. Students sometimes find it overwhelming on a first reading because of its size. Experienced developers often find in it a careful statement of things they learned the hard way, along with evidence for practices they had followed on instinct, and occasionally evidence against habits they had thought were good.
The author
Steve McConnell worked as a developer on a range of projects, including software for desktop applications and other commercial systems, before Code Complete made his name. After its success he founded Construx Software, a consulting and training company based in the Seattle area that works with organisations on software development practices. He has served on the editorial board of IEEE Software and was for some years its editor in chief, a role that kept him close to both research and industrial practice.
His later books extend the themes of Code Complete into other areas of software work. Rapid Development, published in 1996, turned to schedule-oriented project practices and the common mistakes that make projects slow. Software Project Survival Guide in 1998 offered a compact plan for running a medium-sized project. After the Gold Rush in 1999, later expanded as Professional Software Development, argued that software development should mature into a profession with recognised bodies of knowledge and standards, much as engineering and medicine had. Software Estimation, published in 2006, dealt with the difficult art of predicting how long software will take. More recently he has written on adopting agile practices in a disciplined way.
Across these books McConnell shows a consistent approach. He is a synthesiser more than an originator. His strength is reading widely, sorting good evidence from bad, and presenting the results in a clear, organised form that practitioners can use. He is also consistently moderate. He tends to resist fashions, both the heavy methodologies of the 1980s and the more extreme claims of some later movements, and to ask what the evidence actually supports. That temperament is visible in Code Complete, which is earnest, thorough and rarely dramatic.
The book also shows his belief that programming is a craft with a large teachable component. Some people are more gifted than others, but much of what distinguishes good code from bad can be learned, described and checked. This conviction is what makes the checklists possible. It also explains the book's moral tone, which treats careful construction as a matter of professional responsibility rather than personal style.
The shape of the argument
The book moves from the large to the small and back again. It opens with foundations: what construction is, why it matters, and how metaphors for software development shape the way people think about it. It then deals with the work that should be done before construction begins, the prerequisites of clear requirements and a sound architecture, and with the key choices made at the start of construction, such as language and conventions.
The central parts of the book descend into the material of code itself. First design at the level of construction: how to break a problem into classes and routines, how to hide information, how to keep pieces loosely connected. Then the building blocks of programs: routines, variables and their names, data types, statements, and the control structures of conditionals and loops. At each level McConnell asks what makes code at that level easy or hard to understand and to change, and what tends to cause defects.
After these parts on the material of code, the book turns to quality: the different techniques for finding and preventing defects, including reviews and inspections, testing by developers, debugging, and improving code that already works. A further part covers performance, explaining when and how to tune code for speed, and when not to. Then comes system-level matters: the effect of program size on construction, the management of construction work, integration of parts into a whole, and the tools programmers use.
The book closes with a part on what might be called software craftsmanship: the layout of code on the page, comments and self-documenting code, the personal character traits that make good programmers, and a set of general themes that run through the whole book. These closing chapters pull the many specific pieces of advice together into a few principles.
How the parts fit
The organisation follows a simple logic. Start with the context in which code is written. Then look at the smallest units and work upward, because good large structures depend on good small ones. Then look at the activities that find and fix problems in what has been built. Then look at the larger systems and teams in which construction takes place. Finally, step back and see the common principles. A reader can enter at any point, but reading in order shows how the same few concerns recur at every level.
Those concerns are few: managing complexity so that a person can understand the code; writing for the human reader as much as for the machine; finding defects early when they are cheap; using several quality practices together because each catches different problems; and basing decisions on evidence where evidence exists. Almost every piece of advice in the book can be traced to one or more of these.
The voice of the book
McConnell writes as a careful colleague rather than a prophet. He states a recommendation, explains the reasoning, cites what evidence he has, notes the exceptions, and moves on. He often presents both sides of a long-running argument among programmers, such as how long routines should be or how code should be laid out, and then says which way the evidence leans and how strongly. Small boxed notes and cross-references connect each topic to related ones elsewhere in the book, and short lists of further reading point to the sources he drew on.
This style has a cost and a benefit. The cost is that the book rarely produces the jolt of a bold, memorable claim; it persuades by accumulation rather than by force. The benefit is trust. A reader who disagrees with a recommendation can see where it came from and judge the evidence for themselves. Over many hundreds of pages, that openness builds a habit in the reader: to ask, of any piece of programming advice, what supports it and how far it applies.
Idea one: construction is central
The first idea is that construction is the core of software development, not a mechanical afterthought. In some older models of software work, the important thinking happened in requirements and design, and coding was seen as a matter of translating the design into a programming language, something that could be handed to less experienced people. McConnell argues against that picture.
His reasons are straightforward. Construction is the one activity every project must perform; a project can skip formal requirements or design documents, but it cannot skip writing code. Construction typically takes a large share of a project's effort. It is where many defects are introduced. And the code is often the only fully accurate description of what the system does, because documents fall out of date while the code keeps running. If construction is done poorly, no amount of good design will save the project.
An analogy helps. In building a house, an architect's plans matter greatly, but the quality of the carpentry, plumbing and wiring determines whether the house leaks, creaks or burns. A good plan carried out by careless builders produces a bad house. Software is similar, except that in software the line between design and building is even more blurred, because programmers make countless small design decisions as they write each routine.
This idea is often confused with a claim that design does not matter. McConnell says the opposite: design is part of construction, and good construction includes a great deal of design at a small scale. The point is to raise the status of the work of writing code, not to lower the status of planning. The idea leads to everything else in the book. If construction is central, then its techniques deserve careful study, and that study is what the rest of the book provides.
Idea two: managing complexity is the main technical goal
If one idea ties Code Complete together, it is that the central technical problem of software is managing complexity. The second edition states this explicitly as the primary technical imperative. Human minds can hold only a limited amount at once. Software systems quickly grow far larger than any mind can grasp in full. The purpose of nearly every good practice, from the choice of names to the organisation of modules, is to arrange code so that a person can think about one part at a time and ignore the rest safely.
Two kinds of complexity are distinguished, an idea McConnell draws from Fred Brooks. Essential complexity belongs to the problem itself; a tax calculation is complex because tax law is complex. Accidental complexity is added by the way the solution is built: confusing names, tangled control flow, needless dependencies. Good construction cannot remove essential complexity, but it can minimise accidental complexity and prevent essential complexity from spreading across the whole program.
An analogy is the design of a large library. The number of books is fixed by what the library holds. That is essential complexity. But whether a reader can find a book depends on how the shelves are organised, how the catalogue is arranged, and whether the labels are clear. A badly organised library with the same books is far harder to use. Programs are similar. The same functionality can be organised so that each part is easy to find and understand, or so that every part is tangled with every other.
The practical tools for managing complexity recur throughout the book. Abstraction, which lets a programmer work with a concept without its details. Encapsulation and information hiding, which keep details inside a module so that other modules cannot depend on them. Loose coupling, so that changes in one part do not ripple through others. Strong cohesion, so that each module has a single clear purpose. Consistent conventions, so that a reader who understands one part can predict how others work.
This idea is often confused with a preference for brevity or cleverness. Short code is not necessarily simple; a dense one-line trick can be far harder to understand than five plain lines. The test is not length but how much a reader must hold in mind to understand and safely change the code. Where the idea leads is a habit of asking, at every decision, whether the choice makes the code easier or harder to think about.
Idea three: prerequisites and the cost of late defects
McConnell gives considerable attention to the work that should precede construction: understanding the problem, defining requirements, and choosing an architecture. His argument rests on a widely cited finding in software engineering research. A defect introduced early, for example a misunderstanding in the requirements, costs much more to fix the later it is found. If the misunderstanding is caught while discussing requirements, fixing it takes a conversation. If it is caught after the system is built and in use, fixing it may require changing design, code, tests and documentation, and perhaps compensating users.
The book uses this finding to argue that some upfront investment pays off, in proportion to the risk and size of the project. A small exploratory program may need little preparation. A large system with many users and serious consequences of failure needs much more. McConnell is careful to say that the right amount of preparation depends on the kind of project, and in the second edition he discusses how iterative and agile approaches handle prerequisites differently, by doing them in smaller increments throughout the project rather than all at the start.
An analogy is a long journey by road. A wrong turn noticed at the first junction costs a minute. The same wrong turn noticed after three hours costs six hours. The cost of the mistake is not in making it but in how far one travels before noticing. Software defects behave in the same way. The aim is not to avoid all mistakes, which is impossible, but to notice them as close as possible to the point where they were made.
This idea is often confused with an argument for heavy documentation or rigid sequential processes. McConnell does not argue for either. He argues for reducing the distance between the introduction of a defect and its discovery, by whatever means suit the project. Short iterations, early prototypes, close contact with users and frequent reviews can all serve this purpose. In later decades the precise numbers in the original cost studies were questioned by researchers who re-examined them, but the general pattern, that late discovery tends to be expensive, is still widely accepted.
Idea four: metaphors shape practice
Early in the book McConnell discusses the metaphors people use to think about software development, and argues that these metaphors are not idle. They shape what people expect and how they work. He considers several. Software as writing suggests an individual author producing a text, perhaps rewriting it freely. Software as farming suggests something that grows by itself with care. Software as accretion, like the slow growth of a pearl, suggests building a system bit by bit. Software as building construction suggests planning, foundations, structure and finishing.
He favours the construction metaphor for most purposes, which is why the book uses the word construction. Building a doghouse needs little planning; building a skyscraper needs a great deal. The amount of preparation depends on the size and risk of the structure. Builders use existing components where possible rather than making everything from scratch. Mistakes in the foundation are expensive to fix later. These are useful lessons for software.
But McConnell does not treat any metaphor as the truth. He uses them as tools for thinking, to be picked up when they illuminate and put down when they mislead. The accretion metaphor, for example, captures well the practice of growing a system incrementally, adding a small working piece at a time. The writing metaphor captures the importance of clarity and revision. No single metaphor covers everything.
An analogy for the use of metaphors is the use of maps. A road map, a topographic map and a political map show the same land in different ways. Each is useful for some purposes and misleading for others. A traveller who believed any one of them was the whole truth would make mistakes. Metaphors for software are maps of the activity, and the skill is in knowing which one to use for which question.
This discussion is often skipped by readers eager for practical advice, but it is worth reading. It trains a habit of examining the assumptions behind one's practices. When a manager says a project is behind and more people should be added, they may be using a factory metaphor that does not fit. When a developer refuses all planning, they may be using a growth metaphor too literally. Noticing the metaphor is the first step to judging whether it fits.
Idea five: code is written for people
A theme that runs through every chapter on the material of code is that programs are read far more often than they are written, and must be written for their human readers. The compiler does not care about names, layout or structure, as long as the syntax is correct. People care a great deal. The programmer who must fix a defect, add a feature or understand a system months later depends entirely on how readable the code is.
From this follows much of the book's detailed advice. Names of variables and routines should say what they mean, at an appropriate length, without cryptic abbreviations. Routines should do one thing that can be described in a short phrase, and their names should state that thing. Control structures should be simple: conditions stated positively where possible, nesting kept shallow, loops with clear entry and exit. Layout should reveal the logical structure of the code, so that what is grouped together on the page is grouped together in meaning.
On comments, McConnell takes a balanced view. Code should be written to explain itself as far as possible, through good names and clear structure. Comments should then explain what the code cannot: the intent behind it, the reason a non-obvious approach was chosen, the assumptions it depends on. Comments that merely repeat what the code says add clutter and fall out of date. Comments that explain why are valuable.
An analogy is the difference between a well-written instruction manual and a list of part numbers. Both may contain the same facts, but only the manual can be used by a person who did not already know the answer. Code that is written for people is like a good manual. Code that is written only for the machine is like a list of part numbers: correct, but useful only to its author, and even to the author only for a short time.
This idea is sometimes confused with a demand for elegant prose or extensive documentation. It is neither. Readable code is often plain and repetitive in its conventions. The aim is predictability: a reader who has seen one routine should know what to expect in the next. The idea leads to an important practice McConnell recommends: write the explanation of a routine in plain language first, then write the code beneath it, so that the code follows the reasoning rather than the other way round.
Idea six: design in the small
Code Complete treats design as something that happens continuously during construction, not only in a separate phase before it. Every time a programmer creates a class, decides what a routine should do, or chooses how to represent data, they are designing. The book offers a set of heuristics for this small-scale design rather than a single method, because McConnell judges that design is a heuristic process, one of trial, judgement and revision, not the mechanical application of rules.
Among the heuristics are finding real-world objects and concepts that the program must represent, forming consistent abstractions, hiding information that is likely to change behind stable interfaces, identifying areas of likely change and isolating them, keeping coupling loose, and looking for common design patterns that fit the problem. He emphasises iteration: trying a design, looking at it, trying another, and choosing among them, rather than accepting the first that comes to mind.
Information hiding deserves special mention. The idea, which comes from David Parnas's work in the early 1970s, is that each module should hide a design decision, especially one likely to change, behind an interface that does not reveal it. Other parts of the program depend only on the interface. When the decision changes, only the module that hides it needs to change. McConnell regards this as one of the most powerful ideas in software design, and the book returns to it often.
An analogy is a power socket. Devices plugged into it do not know whether the electricity comes from coal, sun or wind, or how the wiring behind the wall is arranged. They depend only on the shape of the socket and the voltage it provides. The power company can change everything behind the wall without anyone rewiring their lamps. Information hiding gives software the same freedom.
The book also describes a particular way of writing routines, built around describing each routine in plain language before coding it. In the second edition this is called the Pseudocode Programming Process. The programmer writes a short description of what the routine does, refines it into a series of steps in ordinary language, checks the design, then turns each step into code, leaving the original descriptions as comments. The method forces thinking before typing, and it produces routines whose structure follows a clear line of reasoning.
Idea seven: quality comes from several practices together
One of the most valuable parts of the book is its survey of techniques for finding defects. McConnell compares formal inspections, informal reviews, walkthroughs, pair programming, unit testing, integration testing, system testing, beta testing and others, drawing on studies of how effective each is at finding defects. The pattern he reports is that no single technique finds most defects on its own, and that different techniques tend to find different kinds of defects.
The practical conclusion is that a serious quality programme combines several methods. Testing alone, which many programmers rely on, finds only a portion of the defects present. Reviews of code by other people find defects that testing misses, including problems of design and clarity that tests cannot see. Combining reviews with testing, and doing both early, finds far more than either alone. The book gives particular attention to formal inspections, a structured review method developed by Michael Fagan at IBM in the 1970s, which studies had found especially effective.
McConnell also makes an argument about the economics of quality that many managers find surprising. Improving quality usually reduces development cost rather than increasing it. The reason is that finding and fixing defects is a large part of the cost of most projects. Practices that prevent defects, or find them early, reduce the time spent on debugging and rework later. Quality, in this view, is not a luxury paid for at the expense of schedule. It is one of the main ways of keeping the schedule.
An analogy is a set of different sieves. One sieve catches large stones. Another catches gravel. Another catches sand. Using only one, however carefully, lets the others through. A good quality programme uses several sieves of different kinds, so that what one misses another catches.
This idea is often confused with a demand for maximum process. McConnell does not say every project needs every technique. He says that relying on one technique leaves predictable gaps, and that the right combination depends on the cost of defects in a given system. The idea leads to an honest question every team can ask: which kinds of defects do our current practices catch, and which kinds slip through?
Idea eight: debugging as a scientific method
Many programmers debug by guessing: changing something that might be the cause, running the program, and changing something else if the problem persists. McConnell argues that this approach is slow, unreliable and often introduces new defects. He proposes instead that debugging follow the pattern of scientific inquiry: gather data, form a hypothesis about the cause, design an experiment to test it, run the experiment, and either confirm or reject the hypothesis.
The book offers concrete techniques that follow from this view. Reproduce the defect reliably before trying to fix it. Narrow down the region of code where the cause must lie, for example by dividing the input or the code in halves. Check the most recent changes first. Look for patterns in when the defect occurs. Talk the problem through with someone else, which often reveals the answer before they say anything. Take a break when stuck, because the mind often solves problems when it stops trying directly.
On fixing, the book is equally careful. Understand the problem fully before changing code. Fix the cause, not the symptom. Make one change at a time. Check the fix, and add a test that would catch the defect if it returned. Look for similar defects elsewhere, because a mistake made once is often made more than once.
McConnell also stresses the psychological side. Programmers tend to see what they expect to see in their own code, so they overlook defects that are plain to others. They become attached to a hypothesis and ignore evidence against it. Recognising these tendencies is part of debugging well. An analogy is a detective who settles on a suspect too early and stops noticing clues that point elsewhere. The good detective, like the good debugger, keeps several possibilities open until the evidence settles the matter.
This idea is sometimes confused with using a debugger tool. Tools help, and the book discusses them, but the method matters more than the tool. A careful thinker with print statements will often find a defect faster than a careless one with the most sophisticated debugger. The idea leads beyond programming: the same method applies to diagnosing any complex system that behaves unexpectedly.
Idea nine: measured performance tuning
The book's treatment of performance is a model of measured judgement. McConnell begins by placing code tuning in context. Performance depends first on requirements, architecture, design, choice of algorithms and data structures, and the environment in which the program runs. Tuning individual lines of code is only one way to improve speed, and often not the most effective. Before tuning, a programmer should ask whether the program is actually too slow, and whether a change at a higher level would help more.
When tuning is needed, the book's central advice is to measure. Programs typically spend most of their time in a small part of their code. Programmers are notoriously poor at guessing which part. Changing code for speed without measuring where the time goes wastes effort on parts that do not matter, while making the code harder to read. A profiler, a tool that reports where a program spends its time, should be used first, and each change should be measured to see whether it actually helped.
The book also warns that many traditional tuning tricks do not help with modern compilers, which already perform many optimisations. A change that made code faster on one machine or with one compiler may make no difference, or even slow things down, on another. This again argues for measurement over folklore.
An analogy is a household trying to reduce spending. Cutting small items at random may save a little, but if most of the money goes on rent and transport, the real savings lie there. A household that first looks at where the money actually goes will make better decisions than one that cuts what seems wasteful. Performance tuning is the same: find where the time goes, then act.
This idea is often confused with indifference to performance. McConnell is not indifferent. He argues that performance should be designed for at the right level, and tuned with evidence where needed, rather than pursued everywhere through premature tricks that sacrifice clarity. The idea leads to a sound general principle: do not optimise what you have not measured.
Idea ten: integrate in small steps
A program built from many parts must eventually be assembled into a whole. McConnell discusses the ways this can be done and argues strongly for incremental integration over what he and others call big-bang integration. In a big-bang approach, parts are developed separately and then combined all at once near the end. When the combined system fails, as it nearly always does at first, it is very hard to tell which part or which interaction is at fault, because everything changed at once.
In incremental integration, the system is assembled a piece at a time. A small skeleton is made to work first, and parts are added one or a few at a time, with the whole system tested after each addition. When something breaks, the cause is almost certainly in the part just added or in its interaction with what was already there. Defects are found sooner, located more easily, and the team has a working system at every stage, which helps morale and gives early warning of trouble.
The book describes several orders in which parts can be integrated: from the top of the structure down, from the bottom up, by slices through the system that deliver a feature, or by risk, tackling the most uncertain parts first. Each has advantages, and the choice depends on the system. It also describes the practice of the daily build and smoke test: building the whole system every day and running a quick test to check that nothing basic is broken. This practice, used at some large software companies in the 1990s, keeps the system healthy and makes integration problems visible within a day of their cause.
An analogy is assembling a long train. Coupling all the carriages at once and then trying to move the train makes any fault hard to find. Adding one carriage at a time and moving the train a little after each makes it obvious which coupling is wrong. The cost of checking after each step is small compared with the cost of searching an entire train for the fault.
This idea is often confused with a particular tool or process. It is a principle: keep the distance between a change and its test short. Later practices of continuous integration, in which every change is built and tested automatically within minutes, take the daily build to its logical end. The underlying reasoning is the same as McConnell's.
Idea eleven: character and the craft
Unusually for a technical handbook, Code Complete contains a discussion of the personal qualities of good programmers. McConnell argues that character matters more than raw intelligence. Nobody is clever enough to hold an entire large program in mind. The programmers who do well are those who know this and organise their work to compensate, by writing clear code, testing carefully, and seeking review. Humility about one's own limits is therefore a technical virtue, not merely a social one.
Other qualities he discusses include curiosity, the habit of continuing to learn about one's tools, field and craft; intellectual honesty, which means admitting mistakes, not pretending to understand what one does not, and giving realistic estimates rather than hopeful ones; good communication and cooperation; and creativity tempered by discipline. He also discusses habits, observing that much of what makes a programmer good or bad is a set of habits formed early, and that changing a bad habit requires deliberately forming a good one in its place.
A related idea that recurs in the book is that programmers should program into a language rather than merely in it. A programmer working in a given language should decide what good programming practices they want to follow and then find ways to express them in that language, even if the language does not directly support them. If the language lacks a feature for, say, named constants or assertions, the programmer can adopt conventions that achieve the same effect. The practices come first; the language is a medium.
An analogy is a skilled craftsman in a poorly equipped workshop. A poor craftsman blames the tools and produces poor work. A good one knows what the work requires and finds ways to achieve it with what is available, improvising jigs and methods where needed. The quality of the result reflects the craftsman's standards more than the shop's equipment.
This part of the book is easy to dismiss as moralising. It is better read as an honest description of what actually distinguishes people in a field where intelligence is common and discipline is rare. It leads to a conclusion with wide application: the most important tool a programmer has is a set of good habits, and those can be cultivated by anyone willing to work at them.
The material of code: data and control
A large share of the book is given to the smallest units of programs: variables, data types, statements and control structures. These chapters are the least glamorous and among the most useful, because they deal with the decisions a programmer makes dozens of times an hour.
Variables and data
McConnell's advice on variables rests on a simple observation: the more of a program a variable touches, and the longer it lives, the more a reader must keep in mind. He therefore recommends declaring and initialising variables close to where they are first used, keeping their scope as small as possible, using each variable for one purpose only, and avoiding hidden meanings, such as a number that sometimes means a count and sometimes signals an error. Global data, available everywhere, is treated with suspicion, because any part of the program might change it and a reader cannot easily see which.
The book also urges the use of named constants rather than unexplained literal numbers scattered through code, and the creation of types that match concepts in the problem rather than the bare types the language provides. A value that represents money, a distance or a date should be handled as such, not as a loose number. This makes errors easier to detect and the code easier to read.
Control
On control structures, the advice aims at keeping the paths through a routine few and visible. Conditions should be arranged so that the normal case is clear and the unusual cases are handled plainly. Deep nesting of conditions and loops should be reduced, by restructuring, by splitting routines, or by handling special cases early. Loops should have a single clear purpose, obvious entry and exit, and a body short enough to see at once. McConnell discusses ways of measuring how many paths a routine contains, such as the count of decision points, and uses them as warning signs rather than as hard limits.
He also describes table-driven methods, in which a lookup in a data table replaces a long chain of conditions. Where the logic of a program is really a mapping from inputs to outputs, such as rates by category or days in each month, a table makes that mapping explicit, easier to check and easier to change. It is a good example of the book's general method: find the representation that makes the problem's own structure visible.
Construction when code is generated
A modern reader will ask how the book's advice applies when much code is produced by templates, frameworks or AI assistants rather than typed line by line. The answer is that the book's standards become more important, not less. Generated code still has to be read, reviewed, debugged, integrated and maintained by people. Its names, structure, error handling and complexity must still meet the criteria the book sets out.
In this setting the programmer's role shifts toward specification and review. Writing a clear plain-language description of what a routine should do, as the book recommends before coding, becomes a way of instructing a tool. Applying a checklist becomes the main way of judging what the tool produced. Debugging by hypothesis and test remains necessary when generated code fails in ways nobody predicted. Information hiding and loose coupling remain the best defence against code that works today and resists change tomorrow.
The risk the book would point to is accepting code without understanding it. A program assembled from pieces nobody has read has accidental complexity hidden everywhere. The remedy is the old one: read the code, hold it to clear standards, test it in several ways, and integrate it in small steps.
Seen this way, the book is a description of what good code looks like, whoever or whatever wrote it. That makes it a durable reference for anyone whose job increasingly consists of judging code rather than producing every line of it.
The checklists in particular translate well. Each question they ask of a routine, about its purpose, its names, its error handling and its paths, can be asked just as usefully of a routine a tool produced as of one a colleague wrote.
The checklists and how to use them
The checklists at the ends of chapters are among the book's most practical features. Each gathers the main points of a chapter into a series of questions a programmer can ask about a piece of code: whether a routine has a single clear purpose, whether its name describes it, whether variables are initialised close to their use, whether loops terminate under all conditions, whether error cases are handled, and so on. They turn the book's advice into a tool for review.
Used well, the checklists serve several purposes. A programmer can apply them to their own code before asking others to review it, catching many problems early. A team can use them as a starting point for agreed standards, adapting them to its own language and domain. A reviewer can use them to give feedback that is specific and impersonal, pointing to an agreed criterion rather than personal taste. A learner can use them to see what experienced programmers look for.
Used badly, they become bureaucracy: long forms filled out mechanically with ticks that mean nothing. McConnell's own view is that checklists support judgement rather than replace it. They are best treated as memory aids, reminders of things easily forgotten, not as tests that code must pass. A team that takes the time to choose the items that matter most for its own work, and to drop the rest, will get far more from them than one that applies all of them to everything.
There is also a lesson in the checklists about the nature of expertise. Much of what experienced programmers know is not deep theory but a large number of small, specific lessons about what goes wrong. Writing these down, as other professions such as aviation and surgery have done with their own checklists, makes them available to everyone, and protects even experts against the lapses of attention that cause many errors.
The tradition around it
What came before
Code Complete stands on a large body of earlier writing. From The Elements of Programming Style by Kernighan and Plauger it inherits the idea that clarity in code can be taught by example, and that small decisions about expression matter. From the structured programming movement of the late 1960s and 1970s, associated with Edsger Dijkstra and others, it inherits the emphasis on simple control flow and disciplined structure. From Niklaus Wirth, whose Algorithms + Data Structures = Programs is on this shelf, it inherits the method of stepwise refinement, in which a program is developed by refining a description in successive steps.
From David Parnas it takes information hiding. From Fred Brooks it takes the distinction between essential and accidental complexity and much thinking about large projects. From Michael Fagan it takes the evidence for inspections. From Gerald Weinberg it takes concern for the psychology of programming and the value of review. McConnell's contribution was to gather these strands, along with many empirical studies, into a single coherent handbook aimed at working programmers.
What came after
The book appeared shortly before a wave of influential works on software craft. Design Patterns by Gamma, Helm, Johnson and Vlissides appeared in 1994 and gave a vocabulary for recurring object-oriented designs. The Pragmatic Programmer in 1999 offered a personal, practical guide to the habits of good programmers. Refactoring by Martin Fowler in 1999 described how to improve the design of existing code safely in small steps. Extreme Programming Explained by Kent Beck in the same year proposed a set of team practices including pair programming and writing tests before code. The second edition of Code Complete took account of several of these.
Later books such as Clean Code by Robert C. Martin took up the theme of readable code with more prescriptive rules, and A Philosophy of Software Design by John Ousterhout returned to the theme of complexity with a sharper focus on module design. Code Complete remains the most comprehensive single volume of the group, and the one most explicitly grounded in published research.
Connections on this shelf
On this shelf, Code Complete is a hub. It connects backward to The Elements of Programming Style, The Psychology of Computer Programming and Algorithms + Data Structures = Programs, and forward to The Pragmatic Programmer, Refactoring, Clean Code and A Philosophy of Software Design. It complements Peopleware, which argues that human factors dominate project outcomes; Code Complete supplies the technical practices that good teams in good conditions use. Working Effectively with Legacy Code by Michael Feathers deals with the situation Code Complete hopes to prevent, code that has become hard to change, and gives techniques for recovering it. A reader who studies Code Complete will find echoes of it throughout the bay.
Questions and criticisms
On the evidence
The book's use of research is one of its strengths and also a point of criticism. Many of the studies it cites were conducted decades ago, on small samples, in particular environments, often with student programmers or in specific companies. Some figures widely repeated in the field, including claims about the rising cost of late defects and about large differences in programmer productivity, have been re-examined by later researchers who found the original evidence thinner or more ambiguous than the citations suggested. McConnell generally reports such findings fairly, but readers may take the numbers more precisely than they deserve. The general patterns are better supported than the specific ratios.
On size and density
The book is very long. Its thoroughness is valuable as a reference but can be daunting as a first introduction, and some readers find that its many lists and recommendations blur together. A beginner may struggle to tell which advice is fundamental and which is a matter of local convention. Shorter books on the same shelf, such as The Elements of Programming Style or A Philosophy of Software Design, make fewer points with more force.
What has aged
Some material has aged with the languages and tools of its time. The first edition's examples in languages such as C, Pascal and Basic, and the second edition's in C++, Java and Visual Basic, look dated to readers working in more recent languages. Some discussions, such as detailed debates about layout styles or the use of particular language features, matter less now that automatic formatters and linters settle many such questions. The treatment of testing, though sound, predates the full development of automated testing practices and continuous integration as they are now used. The discussion of process has been overtaken by later developments in agile and iterative methods.
Disagreements
Some readers object to particular recommendations: on comment style, on the length of routines, on naming conventions, or on the place of upfront design. Others find the book too cautious, preferring the bolder positions of writers who argue for very short functions or test-first development as an absolute rule. These disagreements are healthy. McConnell's tendency to present balanced evidence leaves room for teams to choose, and the book rarely claims more certainty than its sources support.
What has held up
What has held up is the core: that construction is central, that complexity must be managed, that code is for human readers, that defects should be found early by several means, that debugging is a disciplined inquiry, that performance should be measured before it is tuned, and that integration should happen in small steps. These are as true for code written in any modern language as for the languages of the book's examples. They are also exactly the standards one needs when reviewing code written by someone else, including code produced by automated tools.
Why it is on this shelf
This shelf gathers books on Vedanta, Jyotish, science, economics and technology. Code Complete is here because it is an example of how a practical craft can be studied with care: its practices gathered, compared against evidence, and organised into a body of knowledge that can be taught. That approach is valuable in any field where tradition, experience and evidence must be weighed together.
We keep it for its standards. Whenever code must be written or reviewed, whether a small script for working with astronomical data, a model for an economic question, or a larger system, the book provides concrete criteria for judging whether the work is clear, correct and maintainable. Its checklists are among the most useful tools on the shelf for that purpose.
We also keep it for its temperament. McConnell is patient, thorough and honest about uncertainty. He neither dismisses tradition nor accepts it without evidence. He treats careful work as a form of responsibility to others: to colleagues who will read the code, to users who will depend on it, and to one's future self. That combination of rigour and modesty is worth having in view, whatever the subject.
How to read it
A first pass
Do not try to read Code Complete straight through on a first attempt unless you have a long, quiet period and a strong appetite for detail. Instead, read it in layers.
- Start with the chapters on routines, variable names and control structures. These are the material of everyday code and give the quickest return. Read them with a piece of your own code open beside you.
- Next, read the chapter on managing complexity and the chapters on design in construction, including information hiding.
- Then read the chapters on debugging and developer testing, and try the scientific approach on the next real defect you meet.
- Read the chapters on layout, comments and personal character when you are ready to think about the craft as a whole.
A second pass
- Read the chapters on prerequisites and the software process with a particular project in mind, asking what preparation it needed and what it got.
- Read the chapters on quality techniques and collaborative construction before introducing reviews or inspections to a team.
- Read the chapters on code tuning when you face a real performance problem, with a profiler at hand.
- Read the chapters on integration and project size when working on systems larger than one person can hold.
What to work through with a pencil
Take one routine of your own, ideally one you find awkward, and apply the relevant checklists item by item. Rewrite it, then compare the two versions. Try the method of writing a plain-language description before code on three new routines and note whether the results differ from your usual work. Keep a log of defects for two weeks, recording how each was found and how long it took to fix; compare the log with the book's discussion of quality techniques. For one performance problem, write down your guess about where the time is spent, then measure with a profiler and compare.
What to skip on a first pass
On a first pass, the detailed treatment of particular language features, the longer discussions of layout styles, and the material on tools can be skimmed. They are useful as reference but not essential for grasping the book's main lessons.
What to read next from this shelf
For a sharper treatment of complexity and module design, read A Philosophy of Software Design. For changing existing code safely, read Refactoring and then Working Effectively with Legacy Code. For the habits of the individual programmer, read The Pragmatic Programmer. For the human conditions in which good construction happens, read Peopleware. For the older roots of the book's concern with clarity, read The Elements of Programming Style.
Questions to carry
- What, in your own code, is essential complexity, and what is accidental complexity you added?
- Could a colleague understand your last routine without asking you anything?
- Which design decisions in your current work are most likely to change, and are they hidden behind stable interfaces?
- How long, on average, is the distance between the moment you introduce a defect and the moment you find it?
- Which kinds of defects do your current quality practices catch, and which slip through?
- When you last debugged a hard problem, did you form and test hypotheses, or did you guess?
- Have you ever optimised code without measuring first, and what did it cost?
- What metaphor do you or your team use for software work, and where does it mislead you?
- Which practices do you follow because of evidence, and which because of habit or fashion?
- What would it mean for you to program into your language rather than in it?
- Which personal habits most improve or most damage the quality of your work?
- How would you adapt one of the book's checklists to fit your own team and domain?
- Where does the book's evidence seem strongest to you, and where would you want newer research?
Words to know
- Construction: the detailed design, coding, debugging, unit testing and integration that turn a design into working software.
- Prerequisites: the work done before construction, chiefly understanding the problem, defining requirements and choosing an architecture.
- Essential complexity: complexity inherent in the problem being solved.
- Accidental complexity: complexity added by the way a solution is built, which good practice tries to minimise.
- Abstraction: the ability to work with a concept while ignoring its details.
- Encapsulation: keeping the internal details of a module out of reach of other modules.
- Information hiding: designing modules so that each hides a decision, especially one likely to change, behind a stable interface.
- Coupling: the degree to which modules depend on each other; looser is generally better.
- Cohesion: the degree to which the parts of a module belong together and serve one purpose; stronger is generally better.
- Routine: a named, callable unit of code, such as a function, procedure or method.
- Pseudocode Programming Process: writing a routine's logic in plain language first, refining it, then coding beneath it.
- Defensive programming: writing code that anticipates and handles invalid inputs and unexpected conditions.
- Assertion: a statement in code that checks an assumption during development and signals clearly if it is false.
- Inspection: a formal, structured review of code or design by several people, with defined roles and checklists.
- Unit testing: testing individual routines or classes in isolation by the developer who wrote them.
- Debugging: the process of locating and correcting the cause of a known defect.
- Refactoring: changing the internal structure of code to improve it without changing its behaviour.
- Code tuning: small-scale changes to code to make it run faster or use fewer resources.
- Profiler: a tool that measures where a program spends its time or resources.
- Incremental integration: combining parts of a system one or a few at a time, testing after each step.
- Daily build and smoke test: building the whole system every day and running a quick check that its basic functions work.
- Self-documenting code: code whose names and structure make its meaning clear without extensive comments.
- Checklist: a list of questions or criteria used to review work and catch common errors.
A note on this edition
This is a study edition written for this shelf in our own words. It describes and comments on Code Complete but does not reproduce its text, examples or checklists. The book itself is still in copyright. It is long, practical and full of detail this companion leaves out, and it is well worth getting from a library or a bookshop, especially for its checklists, which reward use on real code.