Clean Code
If you want to write clean code, then learn these 6 rules:
Separation of Concerns (SOC)
- Break down a complex program into smaller units.
- Each unit should focus on a specific task.
Document Your Code (DYC)
- Write code for your future self and others.
- Explain complex code sections with comments and documentation.
Don’t Repeat Yourself (DRY)
- Don’t waste time writing the same code again.
- Instead use functions, modules, and existing libraries.
Keep It Simple, Stupid (KISS)
- Simple is hard, but better.
- Readable code > clever code.
Test Driven Development (TDD)
- Write a failing test first.
- Write code to make the test pass.
- Then clean up the code without changing behaviour.
You Ain’t Gonna Need It (YAGNI)
- Build only essential features.
- Don’t build features you think you might need later.
The bottom line: Leave the codebase cleaner than you found it.