How to Tackle a Giant, Undocumented Codebase?

0
5
Asked By CuriousCoder99 On

I've recently taken on a massive codebase of over 400,000 lines for a game, written in a language that I'm not very familiar with. Unfortunately, there's no documentation at all, and the debugger tool available is in a language I can't read, which makes it tough to use. The main code is in English, so I can analyze that, but the code structure is messy and uses 'goto' statements extensively, making control flow really hard to follow. This code is quite fragile—any change I make can break other parts of it. Fortunately, I don't have a deadline, so I can take my time to understand the systems involved. If anyone has tips or similar experiences, I'd love to hear them!

4 Answers

Answered By HelpfulHints12 On

First off, see if the debugger or any related tools are open source. That could help a lot, especially if you can check out community resources. Also, reading *Working Effectively with Legacy Code* could give you insights that apply to your situation.

When analyzing the code, I find that starting with a list of keywords related to the functionality you need is beneficial. Focusing on one system at a time while doing a codebase-wide search for those keywords will allow you to zero in on what you need without getting overwhelmed. And don't forget to leverage any comments or commit history in the source control if there’s any insight there!

DebuggingDev -

Are there even any tests available for the code? That can really streamline things. But if there aren’t, you’ll have to start building your own understanding from the ground up.

CuriousCoder99 -

Thanks for the book recommendation! I'll check it out. Unfortunately, there are no tests.

Answered By GameDevGuru88 On

I'd highly recommend adding logs everywhere. Documenting the flow of variables and function calls is key. Use the debugger to your advantage, creating a timeline of what gets called can really clarify the relationships within the code. With a codebase this size, having logs that detail which procedures call others will really help you map everything out.

Honestly, utilizing AI tools sparingly to understand the methods can also offer some insight, though keep in mind it might not catch everything due to the size.

Answered By LegacyWarrior76 On

When I worked with a similarly complex codebase, I relied on UML diagrams to visualize the function calls and relationships. Even creating a simple overview helped me make sense of the overall structure and spot important sections quickly. It can be tedious, but drawing things out really does help.

If your IDE supports it, set it up to highlight these relationships visually as you navigate the code.

Answered By CodeExplorer17 On

Honestly, if you find this codebase too tangled, starting with clean rewrites for the various components may be the simplest path forward. But I get it; you want to understand it first, which is smart! If you can, incorporate performance profiling to understand the more complex parts that are frequently accessed.

CuriousCoder99 -

That's a fair point! I don't want to throw everything out just yet, but rewriting the messier sections could ultimately pay off.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.