Let's Know Our Code!

Let's Know Our Code!

Hey Folks,

As developers or someone who is immersed in coding day in and day out, we encounter numerous opportunities—I would say, opportunities rather than challenges. Amongst the array of these opportunities, one lies in understanding the code and the codebase. As the saying attributed to Abe Lincoln goes, 'Give me six hours to chop down a tree, and I will spend the first four sharpening the axe.' Similarly, comprehending our code and codebase is akin to 'sharpening the axe.' The more effort we invest in familiarizing ourselves with the codebase, the better equipped we are to remain connected with the code over many days, months, or even years.

Today, I present a small article—a particularly important one. Drawing from the benefits of my personal 7-year industry experience, I am sharing the insights below on acquainting oneself with and embracing the codebase. So, here we go.

READ MEs :

One of my initial mistakes was ignoring the 'Read Me' files. This caused me to lose sight of the project's purpose and aim, subsequently affecting my comprehension of the individual components utilized within the project. Therefore, I urge you not to disregard this file. Upon cloning your project, dedicate a minimum of 5-10 minutes to reading the 'README'.

'README' is a file containing the repository name and basic instructions. The file format is 'md,' which stands for Markdown documentation. By reviewing this file, we can obtain a bird's-eye view of the project's details, use cases, and more. This will help you grasp the essence of the individual components within the project.

Unit Reading :

Units - referring to individual methods and classes - are what constitute the core components of the code. By briefly reviewing these units, we can grasp the concepts that underlie the code, leading to a better understanding of the code snippets. Consequently, whenever we encounter a specific unit, we won't find ourselves grappling with unfamiliar code.

Three things to focus on in this section:

  1. Documentation at the method level.

  2. Method signatures.

  3. Methods being called.

Local Run :

Set up your application to run locally, using the environment as a playground to interact with the code. Attempt to execute the application and call various methods or APIs to understand the behavior of individual components. This process will help us to become more acquainted with the code.

Three things to focus on in this section:

  1. Set up your application locally.[ go through the docs if available or contact your peers]

  2. Run the application and take note of the specific method that needs to be studied.

  3. Call the methods either in logs, print statements or in debug mode.

Unit Testing :

Unit testing: Unit Testing is a type of software testing where individual units or components of the software are tested using some available tools like JUnit, TestNG, Mocha etc.

This is a significant, crucial, and exceedingly helpful step that every developer should be aware of. It serves not only for code testing but also aids in gaining deeper insights into individual units, especially when dealing with granular aspects like CRUD operations. Therefore, we can write the unwritten JUnit tests for the components or units.

You can delve deeper into Unit testing and JUnit in the 'Let's Mock it-o' section that I have covered.

Defect triaging :

Defect triaging is a technique through which defects are addressed with swift assessments and fixes. Once we're familiarized ourselves with a basic understanding of the code, we can start fixing the defects, defect-debug-fix-test, this step propels us to delve deeper into the codebase and its enhancements.

Technical Debt Setoff :

Technical debt occurs when there is a debt related to technical implementations, when there is a gap in the required technology for the project or certain implementations within the code. Therefore, addressing this debt as soon as possible would enhance our comfort level within the codebase and the domain.

In this era of AI, the task of addressing technical debt has become a bit easier compared to ten years ago, thanks in large part to generative and predictive analytics. These tools assist us in understanding the technical intricacies with greater ease.

Refactor :

When we become comfortable with the code, we can refactor it to enhance readability, performance, and efficiency, with this, it clears our thorough understanding and we become versatile in delivering the requirements.

We can utilize SOLID principles, code coverage tools, and design patterns to aid us here.

We can consider the aforementioned fundamentals to gain a better understanding of and deal more comfortably and easily with our code. Personally, this approach has helped me in comprehending my codebase effectively and encountering fewer hiccups when working with the code.

To summarize with simple pointers :

Activities
READ MEs
Unit Reading
Local run
Unit Testing
Defect Triaging
Technical Debt SetOff
Refactor

That concludes this article, dear readers. Thank you for your attention while reading through it. In the upcoming post, I will present another technical document to explore the technology around us.