We all have a goal to create simple, beautiful, elegant code, but many times in a project, when we get to the end and we look at what we wrote — our first guttural response is — “What have I created?”
Do you know the Problem?
Whenever I’ve written confusing/messy code, I can always bring it back to not understanding the problem well enough that I simply started coding, and then kept adding onto it. While I was building, I then started gain a better appreciation for the problem, bolting on little nuggets of wisdom here, there, and everywhere until I was finally complete and realized what I had built.
The thing is — writing confusing code never goes away, no matter your level of experience in the framework of language — if you don’t understand the end goal of what you’re trying to accomplish you’ll never be able to keep it simple.
Know the problem you are trying to solve, know the answer to this question in one or two lines, anything more and you don’t know what your end goal.