Understand a program logic when it becomes heavy

Hello,

I was reading a large code (apache web server).

With all those inclusions, I would like to understand how one can make his way into this furious mess (same for any large program) without dying before being able to understand the whole package.

Are there any tools ? I just can't image someone having to open all the files and search for references..

Any clue ?

thanks
Any decent IDE will have the ability to show you, for example, where an entity is defined and declared, and where else in the code it is used. That can go a long way towards helping you figure things out.

If you're in a position to modify the code, it might help to add comments as you start to understand the code, and even refactor it to break it down into understandable functions. Also, if the code isn't sensibly formatted (indentation, braces, etc) then changing that might be helpful too.

EDIT: And, of course, finding the original programmer and whacking them upside the head with a clue-by-four until they learn how to write readable, maintainable code, is an option :D
Last edited on
> Are there any tools ?
> I just can't image someone having to open all the files and search for references..


Step 1. Get as far away from your IDE as possible (An IDE may be great when we have fifty thousand lines code spread across 20 directories; it is no good at all when it comes to a million lines of code.)

Step 2. Get an overall understanding of the high level architecture and design philosophy. In particular, get an idea of the flow of control - for instance, when an http request arrives, the sequence of flow through the subsystems. For instance, figure 4 here: http://www.shoshin.uwaterloo.ca/~oadragoi/cw/CS746G/a1/apache_conceptual_arch.html

Step 3: Focus now on the key architectural components; for instance step 2 would have made us realize that the entire apache web server is made up of an apache core which delegates and orchestrates between a large number of modules. Pick up one subsystem and one of its standard modules - say, the authentication subsystem / mod_auth.

Step 4. This is the time an IDE could come in handy. Pull in the files of mod_auth; draw a dependancy chart. We can start investigating the code, now that we know where it fits in the overall picture (architecture), and we know where to start looking (dependancy chart).

Step 5. Try to extend it by writing a module of our own. Code examples and explanations would be extremely helpful if we can lay our hands on them.
http://www.informit.com/store/apache-modules-book-application-development-with-apache-9780132409674

Step 6. Go over to another module (from the same or from another subsystem). Repeat steps 3, 4 and 5 till the process looks straightforward, comfortable.

Step 7. Look at the remaining parts based strictly on need. No one person's head is big enough to keep every detail of every part of a large software base.
Thanks a lot,

Your points of view were very useful to me.

I have got a lot to grab :)

See you !
Topic archived. No new replies allowed.