Reading Code

The Essential Skill Not Taught at University

A picture of the author, Jakob Maier
Jakob Maier
Aug 19, 2022

I'm a student at TU Wien and have just started working as a Java Developer. This puts me in the position of having to see how well the theoretical training I have received stacks up in the real world.

So far, I have noticed one thing: At university we spent most of our time writing code, either from scratch or using a small templates provided by the professor. At my new job however, I have been mostly reading code, exploring a large codebase in order to understand what is going on and eventually make some changes. And while knowing how to write Java helps of course, I would consider reading code a skill quite different from writing. In fact, I think it can sometimes be much harder. I could probably hack something together that makes sense in my head, but making sense of someone elses thoughts and concepts can be much harder.

Also, when writing code myself I generally only use concepts and techniques I'm familiar with. Sometimes a problem might force me to use a new feature of the language, but for the most part I stick with what I know. When reading someone else's code however, especially if they are more experienced in the language than me, I will often come across language features I have never seen before.

My New Best Friend: The Debugger

This might seem obvious to some, but the best way to understand a piece of code really is to break out the debugger. I used to underappreciate the debugger and hardly ever used it, but when going through unfamiliar code there really is no substitute to stepping through the control flow and being able to inspect variables.

My Workflow

  • Find the start point of the code. This is often the main() function.
  • Set breakpoints and start debugging.
  • Once you find something you know, work back from there.

Here is a visual representation of me trying to understand some else's code:

Hamster Programming

This image was generated using DALLĀ·E.

↑ back to top

© 2024 Jakob Maier
kontakt & impressum
edit