Value of Comments in the code!!


During my journey of Software Development, I am always indulged by doing research and coding, and learning new technologies as technology is changing rapidly day by day. Technological advancements are happening at an exponential rate, and the pace of change is only getting faster. New technologies are being developed and improved daily, leading to new opportunities, products, and services.

Hence as a developer, we constantly shift from one project to another but the previous projects are still modified as per requirements so the hectic code that we wrote by doing too much research has to be gone through by someone who has the responsibility of that project. So here the value of commenting into code has to take place.


Commenting is an important aspect of software development that involves adding descriptive notes or explanations to the code. The value of commenting in code during software development includes:

  1. Improved readability: Commenting makes code more readable and understandable for other developers who may need to work on the code. It provides context and clarifies the purpose of the code.

#Python comments start with the # character and extend to the end of the line.

name = “Sanchit Pahwa” # employee name id = 00175 # employee id role = “Software Developer”

2. Easier maintenance: Comments can help make the code easier to maintain. When developers come back to the code to make changes or fix bugs, comments can help them quickly understand the code’s purpose and behavior, which can save time and reduce errors.# Comments for function

#This is a function that returns multiplication of two numbers def mul(a,b): return a*b #Calling function by specifying parameters and printing its value print(mul(10,20))

3. Documentation: Comments can serve as documentation for the codebase. They can provide a record of the code’s design decisions, assumptions, and limitations, which can be useful for future reference.

#Using Python Docstring as Multiline Comment ”’ Used to provide documentation for functions, classes, and modules It is used as multiline Comment ”’ #While making API’s we use it ”’ Description: Used to fetching category name from database Body: category id, should be string Return: category name ”’ def category_name(id): ctg_name=category_database.find({“_id”:id},{“category_name”:1}) return ctg_name ”’ For every function write its description,parameters,return before start writing function and inside it if there is any mapping, looping or high complexity code write it in statements so that it is easier to read instead of debugging it. ”’

4. Collaboration: Comments can help team members collaborate on a codebase by providing context and insights into the thought process behind a particular piece of code.

5. Debugging: Comments can be helpful for debugging purposes. They can help developers identify the source of a problem and narrow down the scope of their investigation.

Some extensions that help you with automatic code commenting in VS-Code Editior specifically for Python:

a. AutoComment

b. AutoDocstring

c. Python Docstring Generator

d. Pylance


Conclusion

Overall, commenting on code is a valuable practice that can improve the quality of software development. It makes code more readable, maintainable, collaborative, documented, and easier to debug.

Happy Learning!!😀😀

Latest

SENTRY integration in your React Native App for Error/Crash tracking

Sentry captures data by using an SDK within your...

Recall the concepts of useCallback.

useCallback hook is one of the best hooks offered...

YOLO:Bullet Paced Algorithm

http://sh017.hostgator.tempwebhost.net/media/33949d0e61af4b50f374c534713f56b3 According to world health organization, more than 1.35 million...

Featured

Developing Enterprise Application in Node.js – CJS Vs ESM

Node.js is a popular runtime environment for building server-side...

Integrating your web react applications with their React Native(android and IOS) apps using QR code

Integrating a web application with Android and iOS apps...

YOLO: Bullet Paced Algorithm – popular choice for object detection in autonomous vehicles 

According to world health organization, more than 1.35 million...

Importance of Test Scalar Tool

TestScalar is quick to access, convenient to execute, easy to track. Our popular web-based test planning software lets you focus on what matters: meeting...

From Requirements to Reporting: How to Use a Test Case Management Tool to Ace Your Software Testing

The Software Testing Life Cycle (STLC) is a process that describes the stages of testing software. It includes planning, design, execution, and reporting of...

YOLO:Bullet Paced Algorithm

http://sh017.hostgator.tempwebhost.net/media/33949d0e61af4b50f374c534713f56b3 According to world health organization, more than 1.35 million people die every year because of vehicle accidents . Vehicle safety features started with passive safety...

LEAVE A REPLY

Please enter your comment!
Please enter your name here