As programmers, we've all seen source code that’s so ugly and buggy it makes our brain ache. Over the last five years, authors Dustin Boswell and Trevor Foucher have analyzed hundreds of examples of "bad code" (much of it their own) to determine why they're bad and how they could be improved. Their conclusion? You need to write code that minimizes the time it would take someone else to understand it—even if that someone else is you.
This book focuses on basic principles and practical techniques you can apply every time you write code. Using easy-to-digest code examples from different languages, each chapter dives into a different aspect of coding, and demonstrates how you can make your code easy to understand.
• Simplify naming, commenting, and formatting with tips that apply to every line of code
• Refine your program’s loops, logic, and variables to reduce complexity and confusion
• Attack problems at the function level, such as reorganizing blocks of code to do one task at a time
• Write effective test code that is thorough and concise—as well as readable
Dustin Boswell graduated from CalTech, and worked at Google for five years on web crawling infrastructure and ad programs. He's built several websites and enjoys working on big data and machine learning.
Trevor Foucher has spent the past decade at Microsoft as an engineer, manager, and tech lead on Windows and security products, and at Google working on ad programs and search infrastructure.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A compact, example-driven manual for making code easier to understand, built around one measurable goal: reducing the time someone else—often your future self—needs to read and safely change your code. Best for working programmers and reviewers who want concrete habits rather than abstract style doctrine.
【Book Arc】
- **Opening (~0%–10%)**: Frames the whole book around the “Fundamental Theorem of Readability”—minimize time-till-understanding—and sets expectations that chapters are largely self-contained, moving from basics to more advanced topics.
- **Early (~10%–30%)**: Focuses on the smallest units: packing information into names, preferring concrete over abstract names, encoding critical attributes (e.g., untrusted vs. safe data), avoiding misleading names, and using layout, spacing, alignment, and “paragraphs” to make code easy on the eyes.
- **Middle (~30%–55%)**: Turns to comments—what not to comment, when a comment earns its space, documenting implementation details and caveats, “big picture” comments for newcomers, and tightening comments so they are precise and compact.
- **Late (~55%–85%)**: Moves up a level to simplifying loops, logic, and variables, then to function-level restructuring so each block does one task at a time; excerpts indicate this is where complexity reduction and reorganization are treated.
- **Ending (~85%–100%)**: Closes with writing less code and with testing—how to write test code that is thorough, concise, and itself readable; the excerpts do not cover the detailed contents of these final chapters.
【Key Takeaways】
- **Readability is measured in comprehension time** (Opening): the book’s central metric is how long a colleague needs to understand, modify, and debug your code—not how short or clever it is. This reframes style debates as a practical cost question.
- **Names should carry the information a reader needs** (Early): prefer concrete names like `CanListenOnPort()` over vague ones, and encode critical attributes such as `unescaped_comment` or `html_utf8` where a mistake would be costly. The authors distinguish this informal “English Notation” from strict Hungarian notation.
- **Misleading names are worse than dull ones** (Early): respect conventions users already hold (e.g., `get*()` as a lightweight accessor), avoid negations like `disable_ssl = false`, and test names against how a new teammate would interpret them.
- **Layout is a readability tool, not decoration** (Early): consistent patterns, similar-looking code for similar logic, grouped blocks, and code “paragraphs” let readers skim structure before details—sometimes more lines are clearer than fewer.
- **Most comments are noise; some are essential** (Middle): restating what the code says wastes reading time, while caveats, timeouts, complexity warnings, and system-level “big picture” notes are exactly what newcomers cannot infer.
- **Precision beats prose in comments** (Middle): a comment like “count newline bytes” is better than “count lines” because it resolves corner cases; compact, direct sentences and well-chosen input/output examples outperform long explanations.
- **Complexity should be attacked at the logic and function level** (Late): simplifying loops, variables, and conditions, then reorganizing code so each function or block does one task, reduces the mental load that naming and formatting alone cannot fix.
- **Tests are code too** (Ending): test code should be readable and concise as well as thorough—the excerpts do not detail specific test techniques, so treat this as a principle rather than a recipe.
【Reading Tips】
- Read the naming and commenting chapters closely; they offer the highest density of immediately applicable rules and are easy to revisit as checklists during code review.
- Skim the layout chapter if you already follow a formatter, but slow down on “make similar code look similar” and code paragraphs—these survive auto-formatting.
- Treat the later chapters on simplifying logic and restructuring functions as the harder material; read them with your own codebase open and rewrite one function as you go.
- Because chapters are self-contained, jump to the topic matching your current pain point (names, comments, or tests) rather than reading strictly front to back.
- Take away one habit: before finishing a change, ask how long a teammate would need to understand it, and revise the name, comment, or structure that costs the most time.
【Coverage Limits】
This guide is based on stratified excerpts covering the preface, naming, layout, and commenting chapters plus brief signals of later topics; the detailed content of the simplification, function-level, less-code, and testing chapters is not covered, so those sections are described at the level of their stated aims only.
Page 4
Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editi...
g can easily sneak in if someone mistakes what the variable is, especially if the consequences are dire, as with a security bug. Essentially, if it’s a criti...
o make and often improve readability quite a bit. There are times when larger refactoring of your code (such as splitting out new functions or classes) can h...
tain that information. Describe Function Behavior Precisely Imagine you just wrote a function that counts the number of lines in a file: // Return the number...
// document is read-only... } The expression request.user.id == document.owner_id may not seem that big, but it has five variables, so it takes a little extr...
retty(obj) doesn’t handle: • It expects obj to be an object. If instead it’s a plain string (or undefined), the current code will throw an exception. • It ex...
d” the problem in a different direction. Both solutions are highly readable, as they require the reader to think about only one task at a time. Summary This...
duplicates Clearly, set is the right tool for the job here. But if you weren’t aware of the set type, you might produce code like unique() above. Why Reusing...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
The Art of Readable Code Simple and Practical Techniques for Writing Better Code (Dustin Boswell Trevor Foucher) (z-library.sk, 1lib.sk, z-lib.sk)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
The Art of Readable Code Simple and Practical Techniques for Writing Better Code (Dustin Boswell Trevor Foucher) (z-library.sk, 1lib.sk, z-lib.sk)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
The Art of Readable Code Simple and Practical Techniques for Writing Better Code (Dustin Boswell Trevor Foucher) (z-library.sk, 1lib.sk, z-lib.sk)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment