-5

At my new work I am dealing with a quite big C/C++ project (50k lines in multiple files). I usually "draw" what the code is doing to understand its functioning but this time I am struggling a bit because of the code's size. Is there a technique that you use to such a purpose? The common algorithm notation with 2D shapes is a bit confusing with this size.

Thanks to anyone.

(I appreciate the downvotes if they come with an explanation)

  • Some IDEs come with a tool to draw class diagrams - either automatically or using any classes you choose. – Robbie Dee Apr 12 '18 at 12:39
  • Which tools (or at least search terms) did you try out? What are your coworkers using? What's your IDE? Also: Why was my question down voted? – fheub Apr 12 '18 at 13:40
  • 2
    Possibly relevant, probably not a duplicate: I've inherited 200K lines of spaghetti code — what now? – Dan Pichelman Apr 12 '18 at 15:34
  • 1
    There is a whole bunch of tools for C/C++ code base, and they're centered around a data format called "ctags" or "etags". The premise is that, in C/C++, it is necessary for a compiler-grade parser to preprocess the source code, before its content can be indexed (i.e. made searchable, in a meaningful way). Any diagramming or visualization could only come after that. If you don't have access to any tools, then, of course one has to do everything by hand, inside one's brain. – rwong Apr 12 '18 at 15:52
  • 50KLOC is a small project (approximately the amount of documented & debugged code you'll do in two years, working alone and full time). Compare that size to the Linux kernel or to the GCC compiler. Both have one or several dozens of millions of source code line. Google have internal programs of more than half a billion lines of C++ .. So "quite big" is really excessive (but your small 50KLOC project can be messy) – Basile Starynkevitch Apr 12 '18 at 16:43
4

You need a higher level of abstraction to start out with.

Try grouping related classes together into a single box on your diagram.

For example, an eCommerce app might have one box for user management, one box for the shopping cart, one box for products, one box for checkout, etc.

You can then dig into each box individually and note that the products box may include "sub boxes" for inventory, prices, descriptions, images, etc.

The "sub boxes" may eventually break down into individual classes.

Note the links between the high level boxes are not necessarily direct 'control flow', but are more "these boxes are related and there are a bunch of interactions that occur between them".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.