Lots of time I see people say they hack and hack at code until it “works”
But those accumulated hacks and patches can be troublesome down the road as you may not remember why you did something that way
And comments are, for the most part, obsolete the moment you write them.
And, unless you have some kind of enforced policy, either personally or corporately, they probably do not get maintained as code gets updated.
So how to avoid this situation where comments are useful and you cant read the code you wrote 6 months ago because you wrote it in a hurry and didnt bother with good names for anything ?
Quite honestly I find I like to be lazy.
By that I mean – slow down ! Take the time to do it once. And do it right. Or as right as you can make it at the time. Use long descriptive variable names. Give your methods good names. And then at least your code will maybe read more like english and actually self document the intent of the code.
Code you quickly hack together today and have to go back and decipher in a month or more does you no favours. In the long run having to revisit that code more than once will cost you both time & effort. And if it isnt carefully thought out you may introduce subtle side effects by making changes to your code.
Repeated studies have shown that the sooner to find and fix bugs and errors in code the less they cost to fix. Quickly written hacked together code is still early enough in the overall process that it can cost a ton to fix later (if you can fix it at all) Design flaws that arent caught can be horribly expensive to fix once a product rolls out – or worse cant be fixed without such a huge change that for all intents & purposes it will never happen.
My advice. Be lazy. Do it once. Do it right.