The Art of Clean Code

Book description

Most software developers waste thousands of hours working with overly complex code. The eight core principles in The Art of Clean Code will teach you how to write clear, maintainable code without compromising functionality. The book’s guiding principle is simplicity: reduce and simplify, then reinvest energy in the important parts to save you countless hours and ease the often onerous task of code maintenance.

Bestselling author Christian Mayer leverages his experience helping thousands perfect their coding skills in this new book. With expert advice and real-world examples, he’ll show you how to:

•Concentrate on the important stuff with the 80/20 principle — focus on the 20% of your code that matters most
•Avoid coding in isolation: create a minimum viable product to get early feedback
•Write code cleanly and simply to eliminate clutter
•Avoid premature optimization that risks over-complicating code
•Balance your goals, capacity, and feedback to achieve the productive state of Flow
•Apply the Do One Thing Well philosophy to vastly improve functionality
•Design efficient user interfaces with the Less is More principle
•Tie your new skills together into one unifying principle: Focus

This Python-based guide is suitable for programmers at any level, with ideas presented in a language-agnostic manner.

Table of contents

  1. Title Page
  2. Copyright
  3. Dedication
  4. About the Author
  5. Foreword
  6. Acknowledgments
  7. Introduction
    1. Who Is This Book For?
    2. What Will You Learn?
  8. Chapter 1: How Complexity Harms Your Productivity
    1. What Is Complexity?
    2. Complexity in a Project Life Cycle
      1. Planning
      2. Defining
      3. Designing
      4. Building
      5. Testing
      6. Deployment
    3. Complexity in Software and Algorithmic Theory
    4. Complexity in Learning
    5. Complexity in Processes
    6. Complexity in Your Daily Life, or Death by a Thousand Cuts
    7. Conclusion
  9. Chapter 2: The 80/20 Principle
    1. 80/20 Principle Basics
    2. Application Software Optimization
    3. Productivity
    4. Success Metrics
    5. Focus and the Pareto Distribution
    6. Implications for Coders
      1. A Success Metric for Programmers
      2. Pareto Distributions in the Real World
    7. Pareto Is Fractal
    8. 80/20 Practice Tips
    9. Resources
  10. Chapter 3: Build a Minimum Viable Product
    1. A Problem Scenario
      1. Loss of Motivation
      2. Distraction
      3. Running Over Time
      4. Lack of Response
      5. Wrong Assumptions
      6. Unnecessary Complexity
    2. Building a Minimum Viable Product
      1. Four Pillars of Building a Minimum Viable Product
      2. Advantages of the Minimum Viable Product
      3. Stealth vs. Minimum Viable Product Approach
    3. Conclusion
  11. Chapter 4: Write Clean and Simple Code
    1. Why Write Clean Code?
    2. Writing Clean Code: The Principles
      1. Principle 1: Think About the Big Picture
      2. Principle 2: Stand on the Shoulders of Giants
      3. Principle 3: Code for People, Not Machines
      4. Principle 4: Use the Right Names
      5. Principle 5: Adhere to Standards and Be Consistent
      6. Principle 6: Use Comments
      7. Principle 7: Avoid Unnecessary Comments
      8. Principle 8: The Principle of Least Surprise
      9. Principle 9: Don’t Repeat Yourself
      10. Principle 10: Single Responsibility Principle
      11. Principle 11: Test
      12. Principle 12: Small Is Beautiful
      13. Principle 13: The Law of Demeter
      14. Principle 14: You Ain’t Gonna Need It
      15. Principle 15: Don’t Use Too Many Levels of Indentation
      16. Principle 16: Use Metrics
      17. Principle 17: Boy Scout Rule and Refactoring
    3. Conclusion
  12. Chapter 5: Premature Optimization Is the Root of All Evil
    1. Six Types of Premature Optimization
      1. Optimizing Code Functions
      2. Optimizing Features
      3. Optimizing Planning
      4. Optimizing Scalability
      5. Optimizing Test Design
      6. Optimizing Object-Oriented World Building
    2. Premature Optimization: A Story
    3. Six Tips for Performance Tuning
      1. Measure First, Improve Second
      2. Pareto Is King
      3. Algorithmic Optimization Wins
      4. All Hail the Cache
      5. Less Is More
      6. Know When to Stop
    4. Conclusion
  13. Chapter 6: Flow
    1. What Is Flow?
    2. How to Achieve Flow
      1. Clear Goals
      2. Feedback Mechanism
      3. Balance Opportunity and Capacity
    3. Flow Tips for Coders
    4. Conclusion
    5. Resources
  14. Chapter 7: Do One Thing Well and Other Unix Principles
    1. The Rise of Unix
    2. Philosophy Overview
    3. 15 Useful Unix Principles
      1. 1. Make Each Function Do One Thing Well
      2. 2. Simple Is Better Than Complex
      3. 3. Small Is Beautiful
      4. 4. Build a Prototype as Soon as Possible
      5. 5. Choose Portability Over Efficiency
      6. 6. Store Data in Flat Text Files
      7. 7. Use Software Leverage to Your Advantage
      8. 8. Avoid Captive User Interfaces
      9. 9. Make Every Program a Filter
      10. 10. Worse Is Better
      11. 11. Clean Code Is Better Than Clever Code
      12. 12. Design Programs to Connect With Other Programs
      13. 13. Make Your Code Robust
      14. 14. Repair What You Can—But Fail Early and Noisily
      15. 15. Avoid Hand-Hacking: Write Programs to Write Programs If You Can
    4. Conclusion
    5. Resources
  15. Chapter 8: Less Is More in Design
    1. Minimalism in the Evolution of Mobile Phones
    2. Minimalism in Search
    3. Material Design
    4. How to Achieve Minimalistic Design
      1. Use Whitespace
      2. Remove Design Elements
      3. Remove Features
      4. Reduce Variations of Fonts and Colors
      5. Be Consistent
    5. Conclusion
    6. Resources
  16. Chapter 9: Focus
    1. The Weapon Against Complexity
    2. Unifying the Principles
    3. Conclusion
  17. Letter from the Author
  18. Index

Product information

  • Title: The Art of Clean Code
  • Author(s): Christian Mayer
  • Release date: August 2022
  • Publisher(s): No Starch Press
  • ISBN: 9781718502185