American Software Engineer and Author Robert C. Martin have done an incredible job by writing the book “Clean Code ” detailedly and with so many examples. By reading this book, you can dramatically change your coding mind. But who doesn’t have much time to read the entire book and want to know the gist and utilize the concept of “Clean Code” this article can be the appropriate choice for you.
What is Clean Code?
- Understandable
- Readable
- Changeable
- Extensible
- Maintainable
Overall
- Standard conventions
- Simple & Stupid
- Cleaner than previous
Names
- Descriptive and unambiguous
- Meaningful
- Pronounceable
- Searchable
- Contextual
- Memorizable
- Consistent
Functions
- Small
- Single Task
- Descriptive names
- Fewer arguments
- Side effects less
- Segregated
Classes
- Small
- Single Responsibility
- SOLID
- Encapsulated
Comments
- Self-explanatory is better
- DRY(Don’t Repeat Yourself)
- Noiseless
- Clarified
- Avoid if you can
Source code structure
- Separated vertically
- Related Together
- Similar Together
- Shortline
- Indented
Tests
- One assert
- Readable
- Fast
- Independent
- Repeatable
What is Smelly Code?
- Rigid
- Fragile
- Immobile
- Complex
- Redundant
- Opaque
Happy Coding! :)