How to efficiently write code on paper [closed]
Asked Answered
A

2

10

In my University tests I often have to write programs and algorithms with pen and paper. For example, for my next test I'm going to have to write quite a lot of code in scheme and Java on paper.

I write quite a lot of code, but never on pen and paper. When writing code on paper, I often go at it with the same attitude as if I'd be writing the code on a computer. This often results in a lot of strikethroughs and additions, which often results in a total incomprehensible mess, because I'm used to being able to add and remove blocks as I please.

The problem is the programs or algorithms are complex enough so that it's not possible to think them completely through in your head before writing the code.

Is there any way to effectively and efficiently write code with pen and paper?

Ardatharde answered 2/10, 2012 at 11:59 Comment(6)
How exactly does one answer this question? There isn't a particular method to help writing on pen and paper, it just requires thought and logic. If you can write it in an IDE then you should at least come close (logically) to writing it on paper.Volution
I was thing of something like: "Write your method body first, leave some space in the middel, don't write x before y and so on. I know it is not an question with one exact answer, but as described in the question, I especially am having problems with thins I write and then strike out or want to move around again.Ardatharde
Use a pencil and don't write heavily. Get on of those white erasers that works well and doesn't damage the paper. Also consider working it out in a scratch area and then copying it to the place where you want to write your final answer.Australian
Good Idea! Even though pencil is not allowed in the test, one can easily overwrite it with a pen after one is finished, which still is faster than copying the code from a scratch area. You should add this as an answer!Ardatharde
I think this is a great question. Many interviews require candidates to write code on paper or on the whiteboard. This is not a useless skill! I disagree with the votes to close.Propensity
You could use an intermediate step: draw a diagram. When you see it, chances are you will need fewer strikethroughs when writing code from it.Evapotranspiration
F
5

You are right in writing the code on paper as you write it on the system. But, to write an efficient code, you need to learn few things

  1. Always use indentation at every line of code to make it presentable
  2. Don't forget to add comments at various points so that what you are writing and trying to convey gets clear to the examiner
  3. If anywhere you want to cut through some parts of your code, or encounter a strikethrough, better strike out the whole line and rewrite it. It improves the visibility of the code and makes it appealing.
  4. Remember to leave ample amount of space between two lines of codes, probably a blank line or two. This spacing makes your code presentable.

More suggestions are welcome.

Fresno answered 2/10, 2012 at 12:4 Comment(0)
P
4

Ugh... Programming on paper!! =(

When I am backed into a corner and forced to do this, I like to have a pad of scrap paper handy. I nut out the shape of the program on my scrap paper.. That means I draw a bunch of rectangles, roughly representing how much code I might have to write in a block. When I realise I need something else in between, I sketch more rectangles and draw obvious arrows.

A rectangle might say a few hasty words about what it's achieving, like load stuff from thing. Or x < y ? Or whatever helps me get a feel for what I think I'm going to write, without wasting too much time. I might also note down variable names I intend to use further down, and draw an arrows to where that may be... Or even write a line of code that I mustn't forget!

That means I already have an overview of what I'm doing before I start the code. It gives me time to sit back and make sure I have thought it through. Then I can focus on implementing small chunks at a time and keep my thinking more linear. That's useful because I make more mistakes if I'm thinking ahead at the same time as writing.

Works for me... Might be useful to you, or it might just sound like rubbish.

Pearcy answered 2/10, 2012 at 12:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.