Code that is easy to read, understand, and maintain by humans, not just machines. Clean code expresses its intent clearly through meaningful naming, small focused functions, and minimal complexity, so that any developer can work with it confidently without needing to decipher what it does.
Clean Code
Code that is readable and understandable by other humans, not merely executable by a machine. The underlying principle is that code is read far more often than it is written, so clarity and expressiveness are first-class concerns.Â
A frequently cited standard comes from Martin Fowler: good programmers write code that humans can understand, not just code that a computer can run. Clean code tends to use meaningful names, small focused functions with a single responsibility, and no unnecessary duplication.
— TWiQ Episode 136
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Clean code is code that is easy to read, easy to understand and easy to maintain. It is written for humans first and computers second.
Here are some characteristics of clean code:
- It expresses its intent clearly, meaning that variables, functions, and classes have descriptive names that tell you exactly what they do. Often following a naming and casing standard so that you cannot identify i ndividual authors.
- Functions perform a single action.
- Code adheres to the DRY principle (Don't Repeat Yourself). If you need to change a business rule, you should only have to change it in one place.
- It isn't longer than it needs to be, including comments. It contains no dead code, unused variables, or speculative features (YAGNI - you ain't gonna need it).Â
- It handles errors gracefully such as network failure, missing files or bad user input, and handles those exceptions explicitly, leaving the system in a predictable state.
- It has minimal dependencies. Internally, code keeps connections between different parts of the software to a minimum and externally multiple packages aren't brought in for the same action (breaking DRY and increasing security surface area).Â
- It is self-documenting. The code itself explains what it is doing and comments add why an approach was taken or the business logic being implemented, rather than explaining the lines of code they cover.Â
- Similarly to self- documenting, clean code is verifiable. It is written in a way that makes it easy to test and it actually passes those automated tests consistently.
Is AI failing, or is it an API? Simulate your API environment in WireMock Cloud to run better tests, earlier
Explore MoT
QALS Summer 2026: a leadership summit to move beyond AI testing pilots and build production-ready, AI-first QA organizations - powered by the BrowserStack AI Test Platform and 25+ connected AI agents
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
Debrief the week in Quality via a community radio show hosted by Simon Tomes and members of the community