Nothing obstructs maintenance, debugging and continuous development more than a hastily written codebase. The fact of the matter is that we are craftsmen who typically work in ateliers that have deadlines written all over the walls, and so temptations to hack things up is commonplace.
The harsh reality is that hacks have a deadly tendency to build up, and as your application grows, those unidentifiable nasties are going to make your life (and the lives of your buddies) very hard when you have a piece of software that barely stays intact.
I’m also guilty of writing a fair share of dirty code, but I’ve been fortunate to have been mentored by perfectionists that pay special attention to detail. Sometimes I’ve also had to collaborate with contributors that didn’t adhere to such practices. And such cases always resulted in incredible amounts of wasted development time, every single time. Everyone writes shitty code when they’re newbies, but experienced developers lose face.
As you start to embrace this ideology you also start to admire your own code if only for its cosmetic elegance. It can even develop into a compulsive behavior that drives you to push tiny little commits when you’ve just renamed variables, removed excess line breaks, replaced an if–else statement with a ternary operator, or reworded comments. Now while these minor changes alone aren’t going to guarantee a bulletproof application, they do contribute to the overall cleanliness of the codebase, and it mentally conditions you to strive for a better and cleaner structure. In fact, I advise you to make a habit of going to GitHub to just admire the code you’ve proudly sculpted.
Cleanliness is a habit that can and must be developed.
Read more about the importance of being a disciplined programmer in my other post on avoiding shitty first drafts.