So you are sitting at your desk wondering how come your beautifully and carefully-thought out abstractions have turned into an ugly monster, and why your precious codebase smells like a giant mess? You may be not the smartest guy around but you are not that stupid or unqualified after all.
Well, just accept that your code sucks and stop worrying about it. Even the most brilliant programmers I know come up with the messy code or leaky abstractions sometimes. To fail is human. The business requirements come and go, the product evolves, you are growing as a professional. Don’t be OK with it, just stop torturing yourself trying to find the 100% perfect solution. If it works for now and it looks easy enough to be changed later, then it’s probably fine. On a side note, I would rather wonder why you are OK with any code at all. If you can’t spot an issue here or there then you are probably just not skilled enough to see the defects.
I’m not talking about some ‘forget the code, WE ARE SHIPPING THE PRODUCT HERE, B**TCH!’ management bull**t. The beautiful code and design is what makes your product easy to maintain and improve in the long run. The more skilled and experienced you become, the more likely you are to fall into the “disappointed in everything” mental trap. Try to think about it rationally – you’ve been around for quite some time, you’ve built some great stuff, your projects haven’t fallen apart as a consequence of awful technical decisions. And though your code sucks from your point of view, perhaps it’s not that bad on the absolute scale of code awesomeness.
What can we do make it less painful? Code review really helps a lot. Some developers complain about code review not being effective enough, i.e. it only helps you find the most basic formatting and code issues. I was a bit skeptical myself not so long time ago, but even if it helps to fix the formatting and minor code issues, then it’s a great improvement! I would say it’s a matter of trying and figuring it out for yourself. From my experience, early code reviews help to avoid possible design pitfalls, for example, if a developer hasn't considered a specific use case of a module he is working on. What’s even more important is knowledge sharing. Two heads holding the feature implementation details are definitely better than one (you never know, this lonely developer working on some sophisticated data processing logic may get hit by an asteroid the next day).
Try and fail, learn from your experience. Reading books on code quality doesn’t help. Unless you’ve suffered from the f**ed up design or messed up code, you won’t understand why it’s important to think about future self supporting the codebase.
The code sucks. Repeating this statement makes no sense. What does matter is understanding why it sucks, accepting the trade-offs and constantly thinking about the ways to improve it.