Principles Of Code Structure

This collection of essays form the chapters of a short book of advice that I give to fellow software engineers to help them write better code.

Why should you trust my advice? I began teaching myself Python in 2008, and have worked as a data scientist or software engineer since 2016. Perhaps more importantly, I have some expertise in technical writing: I used my PhD as an opportunity to learn to write. This matters, because I have come to realise that the principles of good technical writing are closely analagous to the principles of writing good software. Thus, insights from prose writing are applicable to code writing. However, there are vast areas of software engineering that I know nothing about. These are the opinions of one engineer; user discretion is advised. As I gain more experience and insight, I will improve and extend this book.

  1. Readability
  2. Elementary Code Structures
  3. The Art Of Abstraction
  4. The Platinum Rule Of Thumb
  5. Separation Of Concerns
  6. Single Source Of Truth
  7. Separate Inherent And Collateral Complexity
  8. Separation Of Functions And State
  9. Distinguish Algorithm-like From Data-like Code
  10. Separate Input/Output From Computation
  11. Separate Business Logic From Mechanical Work
  12. Collate The Concern Of Logical Branching
  13. Coupling
  14. Taxonomy Of Connections
  15. Coupling By Direct Connection
  16. Coupling By Dependency Injection
  17. Coupling By Inheritance
  18. Coupling Summary
  19. Coupling Modules Into A Structure
  20. Make Execution Flow Obvious
  21. Data Flow Should Follow Execution Flow
  22. Interfaces - The Glue That Connects
  23. Miscellaneous Advice
  24. Thinking Like An Engineer