DEV Community

Cover image for Must read: Clean code
krlz
krlz

Posted on

Must read: Clean code

Image description

So lets start with some jokes

  1. Why was the programmer always cold? Because he left his windows open!
  2. Why did the programmer quit his job? He didn't get arrays!
  3. How do you make a joke about null? You can't! It's a null point.
  4. Why do programmers prefer dark mode? Less illumination, fewer distractions!
  5. Why do developers hate bugs? Because they love squash!
  6. Why did the programmer go broke? He used up all his cache!
  7. Why was the developer always looking for a spoon? Because he needed a Java!
  8. How do you spot a bad code? It never returns your calls!
  9. Why don't developers get lost in the woods? They follow the C-trail!
  10. How do you catch a bug? You use insect debugging!

Image description

Robert Cecil Martin, or "Uncle Bob" as his fans affectionately call him, is a big-name software engineer and author. He's kind of like the Yoda of software development - wise, experienced, and full of useful tips and tricks.

Uncle Bob has written several books on programming, including "Clean Code" and "The Clean Coder". These are must-reads for any serious software developer who wants to improve their skills and write high-quality code. They're not just informative, but also entertaining and accessible - Uncle Bob's writing style is clear and concise, and he has a great sense of humor.

In "Clean Code", Uncle Bob shares his insider secrets for creating code that's easy to read, maintain, and extend. He explains the importance of naming conventions, comments, and testing, and provides practical examples of good and bad code. It's like having a personal mentor who shows you the ropes of programming.

Here are 20 things that we can learn from the book:

  1. Always try to make code that's easy to read and understand for other people.
  2. Give things good, meaningful names (like variables, functions and stuff).
  3. Stick to one way of writing your code (like how many spaces you use for indentation).
  4. Break down your code into small functions that do one thing and do it well.
  5. Don't use variables that everybody can access (like global variables) and keep your code in sections.
  6. Add comments to your code to explain what's happening and why.
  7. Always test your code to check that it's working like it should.
  8. Make sure your code can handle errors and crashes gracefully.
  9. Fix up your code regularly to keep it neat and tidy.
  10. Use design patterns that are popular and proven to work well.
  11. Don't try to look clever - write code that's easy to understand for everybody.
  12. Talk with your team and people who are using your code to understand what they need.
  13. Stay up-to-date with the latest software tools and technologies.
  14. Make sure that your code is well documented and organized in a version control system.
  15. Keep it simple - don't make your code too complicated.
  16. Listen to feedback from your team and others in the programming community.
  17. Avoid copying and pasting code by writing functions and classes that are easy to reuse.
  18. Prioritize writing code that's easy to read, instead of code that's tricky but looks cool.
  19. Try to stay consistent throughout your whole codebase, even if you're using lots of different software parts.
  20. Having clean code is important because it will save you and your team lots of time and headaches in the future.

If we want to apply these lessons to our daily life, we can imagine cooking dinner for our family. To keep things clean and organized, we need to use good ingredients, prepare everything before we start cooking, use different pots and pans for different things, and clean as we go along. We need to follow a recipe and stick to the instructions, set timers and stay clean and hygiene!

Overall, Clean Code is a great book that can teach us developers a lot about how to write neat, tidy and understandable code. We might have heard of it before, but that's because it's really useful! Writing clean code is incredibly important in software development, so it's good to learn how to do it well.

And as Uncle Bob quote said: "Remember, your mind is your best IDE".

Top comments (0)