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.
- Readability
- Elementary Code Structures
- The Art Of Abstraction
- The Platinum Rule Of Thumb
- Separation Of Concerns
- Single Source Of Truth
- Separate Inherent And Collateral Complexity
- Separation Of Functions And State
- Distinguish Algorithm-like From Data-like Code
- Separate Input/Output From Computation
- Separate Business Logic From Mechanical Work
- Collate The Concern Of Logical Branching
- Coupling
- Taxonomy Of Connections
- Coupling By Direct Connection
- Coupling By Dependency Injection
- Coupling By Inheritance
- Coupling Summary
- Coupling Modules Into A Structure
- Make Execution Flow Obvious
- Data Flow Should Follow Execution Flow
- Interfaces - The Glue That Connects
- Miscellaneous Advice
- Thinking Like An Engineer