Answer by A Quora admin:
I'm a student programmer, but since I began a year ago I learned a few things:
1. Don't ever try to "code faster" (unless you're in a typing contest). It feels nice to let your fingers dance, but the next day (or most likely in an hour) you will forget what you wrote, where you wrote it and, most importantly, why you wrote it in the first place.
2. So, if you want fewer bugs – and you are a visual person, like me – visualize and map out the logic in your head before you write a single line of code. Pencil and paper might be helpful, or any flowchart app for that matter.
Personally, I find it extremely beneficial to imagine the lines of code right before I write them, as well as picturing the logical structures of programs using metaphors (for e.g. a nested function as a Russian doll) and/or color coding and giving personalities to specific parts of code. This makes it tremendously easier to remember parts of a program, hence resulting in fewer bugs. It also makes coding a lot more entertaining when you give personalities and visual/auditory/etc. stimuli to each for loop.
Try it, you'll discover a new magical "Codeverse".
PS. This works great if you read lots of books and is good at visualizing/sensing/hearing/etc. what you read. This technique also applies to studying any other subject.