Skip to content
UnderDunn Courses

Reading Unfamiliar Code

Programming FoundationsLesson 8 of 875 minutesLab included

For a small unfamiliar program, first locate:

  1. The entry point: top-level Python code or C main.
  2. External input: arguments, files, or standard input.
  3. Output and effects: printed text, written files, and exit codes.
  4. Functions called from the entry point.
  5. Conditions and loops that decide what happens.
  6. State that changes along those paths.

Then draw a small map. Names such as parse, validate, and save are hints written by the author, not proof of behavior.

Choose one externally controlled value and record each transformation:

Step Location Value/type Evidence
Entry argument or file text input interface
Conversion parser integer or structured value conversion call
Decision condition compared value branch expression
Effect output result print/write/return

Mark assumptions: required length, permitted range, terminator, successful allocation, or expected file format. Each assumption suggests a boundary test.

Run a normal case, empty case, exact boundaries, just outside each boundary, wrong type, and unexpectedly long input. Record predictions first. If behavior contradicts the map, revise the map before modifying code.

Temporary print statements can confirm state, but keep a clean copy and change one observation point at a time. Instrumentation can alter timing and state; it is evidence with limitations, not divine revelation.

Knowledge check

Question 1 of 2

What should an unfamiliar-code map begin with?

You now have a repeatable source-level investigation process. The Code Investigation Lab asks you to apply it without being handed the command sequence.