Code That Fits in Your Head: Heuristics for Software Engineering

Book description

How to Reduce Code Complexity and Develop Software More Sustainably

“Mark Seemann is well known for explaining complex concepts clearly and thoroughly. In this book he condenses his wide-ranging software development experience into a set of practical, pragmatic techniques for writing sustainable and human-friendly code. This book will be a must-read for every programmer.”

Scott Wlaschin, author of Domain Modeling Made Functional

Code That Fits in Your Head offers indispensable, practical advice for writing code at a sustainable pace and controlling the complexity that causes projects to spin out of control. Reflecting decades of experience helping software teams succeed, Mark Seemann guides you from zero (no code) to deployed features and shows how to maintain a good cruising speed as you add functionality, address cross-cutting concerns, troubleshoot, and optimize. You’ll find valuable ideas, practices, and processes for key issues ranging from checklists to teamwork, encapsulation to decomposition, API design to unit testing. Seemann illuminates his insights with code examples drawn from a complete sample project. Written in C#, they’re designed to be clear and useful to anyone who uses any object-oriented language including Java , C++, and Python. To facilitate deeper exploration, all code and extensive commit messages are available for download.

  • Choose mindsets and processes that work, and escape bad metaphors that don’t

  • Use checklists to liberate yourself, improving outcomes with the skills you already have

  • Get past analysis paralysis by creating and deploying a vertical slice of your application

  • Counteract forces that lead to code rot and unnecessary complexity

  • Master better techniques for changing code behavior

  • Discover ways to solve code problems more quickly and effectively

  • Think more productively about performance and security

If you’ve ever suffered through bad projects or had to cope with unmaintainable legacy code, this guide will help you make things better next time and every time. Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. About This eBook
  3. Half Title
  4. Title Page
  5. Copyright Page
  6. Dedication Page
  7. Contents
  8. Series Editor Foreword
  9. Preface
  10. About the Author
  11. I: Acceleration
    1. 1. Art or Science?
      1. 1.1 Building a House
      2. 1.2 Growing a Garden
      3. 1.3 Towards Engineering
      4. 1.4 Conclusion
    2. 2. Checklists
      1. 2.1 An Aid to Memory
      2. 2.2 Checklist for a New Code Base
      3. 2.3 Adding Checks to Existing Code Bases
      4. 2.4 Conclusion
    3. 3. Tackling Complexity
      1. 3.1 Purpose
      2. 3.2 Why Programming Is Difficult
      3. 3.3 Towards Software Engineering
      4. 3.4 Conclusion
    4. 4. Vertical Slice
      1. 4.1 Start with Working Software
      2. 4.2 Walking Skeleton
      3. 4.3 Outside-in
      4. 4.4 Complete the Slice
      5. 4.5 Conclusion
    5. 5. Encapsulation
      1. 5.1 Save the Data
      2. 5.2 Validation
      3. 5.3 Protection of Invariants
      4. 5.4 Conclusion
    6. 6. Triangulation
      1. 6.1 Short-Term versus Long-Term Memory
      2. 6.2 Capacity
      3. 6.3 Conclusion
    7. 7. Decomposition
      1. 7.1 Code Rot
      2. 7.2 Code That Fits in Your Brain
      3. 7.3 Conclusion
    8. 8. API Design
      1. 8.1 Principles of API Design
      2. 8.2 API Design Example
      3. 8.3 Conclusion
    9. 9. Teamwork
      1. 9.1 Git
      2. 9.2 Collective Code Ownership
      3. 9.3 Conclusion
  12. II: Sustainability 201
    1. 10. Augmenting Code
      1. 10.1 Feature Flags
      2. 10.2 The Strangler Pattern
      3. 10.3 Versioning
      4. 10.4 Conclusion
    2. 11. Editing Unit Tests
      1. 11.1 Refactoring Unit Tests
      2. 11.2 See Tests Fail
      3. 11.3 Conclusion
    3. 12. Troubleshooting
      1. 12.1 Understanding
      2. 12.2 Defects
      3. 12.3 Bisection
      4. 12.4 Conclusion
    4. 13. Separation of Concerns
      1. 13.1 Composition
      2. 13.2 Cross-Cutting Concerns
      3. 13.3 Conclusion
    5. 14. Rhythm
      1. 14.1 Personal Rhythm
      2. 14.2 Team Rhythm
      3. 14.3 Conclusion
    6. 15. The Usual Suspects
      1. 15.1 Performance
      2. 15.2 Security
      3. 15.3 Other Techniques
      4. 15.4 Conclusion
    7. 16. Tour
      1. 16.1 Navigation
      2. 16.2 Architecture
      3. 16.3 Usage
      4. 16.4 Conclusion
  13. A. List of Practices
    1. A.1 The 50/72 Rule
    2. A.2 The 80/24 Rule
    3. A.3 Arrange Act Assert
    4. A.4 Bisection
    5. A.5 Checklist for A New Code Base
    6. A.6 Command Query Separation331
    7. A.7 Count the Variables
    8. A.8 Cyclomatic Complexity
    9. A.9 Decorators for Cross-Cutting Concerns
    10. A.10 Devil’s Advocate
    11. A.11 Feature Flag
    12. A.12 Functional Core, Imperative Shell
    13. A.13 Hierarchy of Communication
    14. A.14 Justify Exceptions from the Rule
    15. A.15 Parse, Don’t Validate
    16. A.16 Postel’s Law
    17. A.17 Red Green Refactor
    18. A.18 Regularly Update Dependencies
    19. A.19 Reproduce Defects as Tests
    20. A.20 Review Code
    21. A.21 Semantic Versioning
    22. A.22 Separate Refactoring of Test and Production Code
    23. A.23 Slice
    24. A.24 Strangler
    25. A.25 Threat-Model
    26. A.26 Transformation Priority Premise
    27. A.27 X-driven Development
    28. A.28 X Out Names
  14. Bibliography
  15. Index
  16. Code Snippets

Product information

  • Title: Code That Fits in Your Head: Heuristics for Software Engineering
  • Author(s): Mark Seemann
  • Release date: November 2021
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780137464302