DEV Community

Discussion on: How do you know your code is bad?

Collapse
 
jhartikainen profile image
Jani Hartikainen

These are great points - but I have one question: How do you know you're writing bad code when you're writing it?

Despite having been writing code for like 15 years, I still sometimes find it hard to spot it when writing it. Yeah, I can go and try and change it later and I'll realize "oh this is kind of crap", but how do I prevent myself from writing it in that way in the first place?

My best solution so far has been TDD, but I'd be curious to hear if anyone has any other solutions :)

Collapse
 
bob profile image
Bob

I have read somewhere before that the code for a feature or a module has to be written 3 times to get it right. :P

Collapse
 
eljayadobe profile image
Eljay-Adobe

Robert Martin's Clean Code is a book that instructs a person how to see bad code, and how to fix bad code.

The book points out that these are skills that can be learned. And that they are difficult skills to acquire, so it is set up as examples and exercises to help learn the skills. For a wide variety of bad code (anti)patterns.