Code Organization is the key

Ever been tied up in a situation where you see thousands of files containing code, with each file containing several hundreds of lines ? And on top of that you manager has asked you to understand the same code and create a small documentation explaining the underlying logic. What are you going to do? Run through each and every file and try to join the dots? But, believe me thats going to take forever and for sure your manager wouldn't give you that much liberty.

Here's how to deal with such situations. Due to stringent coding guidelines and proper review processes followed by any professional software organization, you will rarely find an un-organized layout of the source code. And if you try to understand the layout of the code first and then delve deeper into it, half of your problem is solved. For example, if you are looking at an application that works on server-client model - then for sure the code will be having two distinct logical portions - one each for server related and client related functionality. Also, the code is supposed to be logically partitioned into different directories based on functionality e.g. directory named "encrypt_serv" will have server side encryption algorithms, "memory_mgmt" directory will have memory management related stuff. On top of that file names are usually related to the functionality they provide e.g. "common/utils/strings_util.c" will have all the common string utility functions such as 'strequals()'.

It would really help if you get hold of specialized code browsing tools that can help you find information quickly. For example, a tool which can easily list down the definition and all the references of a particular function and let you jump to the source code directly. In summary here are few important key points to consider when it comes to understanding the organization of a code base -

  • Logical layout of the project based on functionality.
  • Physical layout of the project in terms of its directory structure.
  • Naming conventions for the files and directory.
  • Use code browsing tools to their maximum potential.
To know more about code organization and other such programming practices do grab a copy of my book - "Hello World: Student to Software Professional” published by Partridge (A Penguin Random House Company). Now available worldwide on all the MAJOR ONLINE Stores - Amazon, Google Play, Flipkart, Barnes & Noble and many others.
comments powered by Disqus