
Ask HN: Reading another developers code - bjw181
How do you go about becoming intimately familiar with someone else&#x27;s previously written code in order to work with it or build upon it?
======
zouhir37
Here's how I tackle it:

\- if there's good unit tests, I immediately feel more comfortable and
confident as nothing can explain the code and behaviour more than the test
suit.

\- if there's no Tests, but can allocate sometime to think and write tests.
that's the best documentation you'll ever provide and benefit from.

\- With better languages debuggers things are easier, logging to the console
keeps to make me win quicker in some cases!

\- Really long comments are confusing sometimes. and might make things more
complicated than simple.

\- Time will help you get everything. The more time you allocate to focus on
the codebase you'll find yourself more familiar. If you have time, make sure
you don't stress yourself and stare at it too long. take breaks do other
things and come back to it once you brain is cleared.

\- before you build on top: Once you understand most the ins and outs, try to
burn down bugs before building on top.

finally - it is OK if you don't know 100% of the code. no one can easily know
a whole code base they didn't write!

------
xja
I guess it really depends.

On projects where the level of commenting is low and theirs little to no
documentation it can be tough.

For C projects as there's usually a single point of entry I just start with
main() and read through the code to get a conceptual overview of what's
happening. Often I find it useful to comment the code/write basic
documentation as I go.

Then I often attempt small changes/refactoring to attempt to validate my
understanding. Often I'll add code to dump intermediate data to better
understand what's happening.

It can be quite a slow process in a large project to be honest, and it's a lot
easier if you have the original developer available to ask questions.

------
greenyoda
You might be interested in this discussion from a few days ago:
[https://news.ycombinator.com/item?id=13282756](https://news.ycombinator.com/item?id=13282756)

~~~
zouhir37
good find

