DEV Community

Sampad Sarker
Sampad Sarker

Posted on

Dry run the code before compile

What is dry run?
Tracing code manually on pen & paper.

Common mistakes in Dry run

❌ Skipping lines or skipping loop completely/half-completely.
❌ Don't track updated values of variables.
❌ Not tracing the real code rather than another imaginary code in your mind because of lack of concentration.
❌ Reading mistakes(silly mistakes like comma, semicolon , typos etc.).
❌ Conceptual lacking(not clear about execution sequence , execution context, data flow , loop execution etc.).

Good practice in Dry run

✔ Always write updated values of variables by drawing box shape . In case of loop, use table like chart to track every updated variables of every iteration.
✔ Read lines letter by letter.
✔ Evaluate arithmetic expression according to precedence rule of operator.
✔ Give enough time for dry run.

Why need dry run?

  • understand the code properly.
  • clear the coding concept.
  • find bugs easily.

Top comments (0)