Code Conveyor
coding with pencil and paper

Writing code with pencil and paper made me a better programmer

Posted on: 2020-27-23 | thought

After stubbornly avoiding it for years, I've recently made it a point to start writing code down on lined paper before doing any actual coding.

Whether it be for debugging or solving an algorithm, here's some of the benefits I've found with this approach:

  • It frees up space in your brain: when you're dealing with a difficult problem, it does you no good to try to put everything together just using your mind. Having the problem infront of you on a piece of paper, even if whatever you're writing seems like subtle details, frees up your thinking capacity and allows you to hone on the real nitty gritty of whatever problem you're facing.
  • You don't have to worry about proper syntax as much, which also allows you to instead focus on solving the problem instead
  • You can come up with multiple solutions very quickly, and compare their runtimes side by side
  • You can sketch out each step of the process and see exactly how your code should work
  • When you've come up with a solution, you'll be able to focus on writing good, clean structured code since the problem has already been solved. This potentially saves you time having to refactor later.
  • Finally, if nothing else, you'll get really good at writing whiteboard problems for those tricky technical interviews

The process I use looks like this:

  1. Write out the input and the expected output
  2. Consider all the variables, data structures, and calculations needed
  3. Walk through the different steps needed to achieve said output
  4. Once a rough solution is available, go over the BUD optimization principles to optimize the code (this stands for Bottlenecks, Unecessary work, Duplicate work)
  5. Write your code as clean as possible, breaking it out into separate modules wherever possible
  6. Test your code
  7. If it doesn't work, rinse and repeat from step 2, perhaps breaking the problem down more than you did previously

Anyways, give it a try. LeetCode, HackerRank, and similar platforms are a good way to practice this. And of course, feel free to drop a comment below about your favorite method to work through a coding problem.

Image by UzbekIL


About Code Conveyor

Hi, I'm Jordan. This is my blog where I share all my secrets (well, not all of them). I'm a developer who makes stuff mostly in the JavaScript ecosystem. Hopefully I can teach you a thing or two.

Categories

Links