MHN

Ask HN: Studying large code bases

57 points by rvalue·4304 days ago·Show in HN

Hi HN,

Suppose you had to understand a large distributed system. The modules which interact together can be written in different programming languages and all expose a REST endpoint along with a documentation of what each endpoint can do.

For the simplicity of discussion lets consider these languages(Java, C++, Scala, Python and PHP). They could use a distributed database like solr, couchbase

Some of these modules can be 12factored and some with pretty bad code practices. There is no existing mechanism for monitoring but logging.

How would go into analyzing this vast system ? (Not just one at a time, elaborate your techniques)

To what degree would you trust the documentation, infrastructure, existing testing tools, environment setup tools in the process of understanding a module ?

What would you make sure you definately do NOT do?

What language specific strategy would you suggest ? (Entrypoints, configs, static analysis etc.)

Would you think of creating a mechanism for cloud debugging ?

How do you keep track of the knowledge you learn from one module and apply that as you go along ?

How do you keep your life together and still swim in so much complexity ?

Share your stack! http://stackshare.io/

How do you apply these techniques to learn, update and maintain this system?

PS: I am asking this question in general and not for an existing system. But if you would like to give an answer with some open-source project as example, that would be great.

Add a comment on Hacker News →
1 of 24 comments
    1. Start at the simplest subsystem, and work from there.

    This is especially true when working with third-party, legacy, or undocumented code. In the absence of documentation, your only way forward is to read the source code[0]. Find the main() of the simplest/smallest module in the system, and begin tracing through the code. This could be with a debugger, print statements, or the search functionality in your editor/IDE (Find Usages and Go to Declaration in Intellij are lifesavers).

    1. Don't be afraid to break things apart.

    If the simplest module in the system is overwhelmingly complex, start commenting out parts of the code. Go until you have effectively reduced it to "Hello, World", if you have to. From there, you can gradually add features back.

    1. Constantly test your assumptions.

    Don't assume comments do what they say they do.

    Don't assume that config flag produces the behavior the documentation claims it does.

    Do take inventory of you assumptions whenever the behavior of the system contradicts your current understanding of how it works.

    You should be able to back up any claims about the system with empirical evidence e.g. when I change A to B, X happens; if I change A to C, Y happens.

    [0] http://blog.codinghorror.com/learn-to-read-the-source-luke/