The Dos and Don’ts of Code Commenting

Developing computer code is a challenging task, but writing code without comments can exacerbate the difficulty by adding extra hurdles to overcome.

Consider receiving all the ingredients required to bake bread but without any recipe to follow. While it’s evident what needs to be combined, determining the correct proportions becomes challenging. Code comments work in a similar way, offering an insight into the execution of a function or customization of a solution tailored to solve a specific problem.

The significance of comments in source code is widely acknowledged in the coding community. Joel Spolsky, the co-creator of StackOverflow, highlighted this when he asserted that “understanding code is more difficult than creating it.” This is especially true when considering the value of an efficient commenting system. Without useful comments, comprehending the code can become immensely challenging. Yet, a well-organized commenting system can make the process significantly simpler.

How can engineers produce high-quality code through effective code commenting? Let’s explore some of the best practices by clicking here.

Engage with Others through Code Comments.

Developers must recognize the significance of incorporating comments in their code to clarify their objectives and approaches. Doing so will allow other developers to easily track their progress and address any queries that may arise.

Consider Your Audience when Writing Comments.

When creating comments, engineers should contemplate how others may interpret them. By doing so, they can create comments that not only serve as a reminder for themselves but also aid in conveying messages to others. This practice enhances collaboration within the team, thereby boosting productivity.

Clear and concise comments are an indispensable part of any code as they provide a means of understanding for other programmers. As such, it’s imperative that developers adopt a writing style that gets the message across quickly and unambiguously, enabling any other programmer to comprehend the code at a glance.

Prevent Misunderstandings with Clear Comments.

Code comments should strive to enhance the clarity of the code, rather than serve as a platform for showcasing the programmer’s proficiency. The primary objective of code comments should be to make the programmer’s intentions and actions explicit, thereby promoting effective communication and understanding.

It is vital that your developer’s comments are clear and straightforward, avoiding any further confusion in the codebase.

Include Citations for Any Copied Code.

It’s imperative that our developers acknowledge the source of any externally sourced code. Doing so ensures that whoever is in charge of maintaining the code in the future understands the purpose and context of the specific code fragment.

When Fixing Bugs, Document Your Changes.

Engineers should include comments for both new code and bug fixes. These comments should be brief and convey the steps taken to resolve the issue and the rationale behind them. It’s advisable to avoid including extensive tutorials within the comments section.

Utilize Code Annotations and Tags.

To keep the code organized and readable, it is advisable for developers in your team to use tags and annotations. These should include a description (@desc), a list of arguments (@param), a list of returned values (@returns), and a list of error codes (@throws). While most programmers are familiar with these tags and annotations, if any team member isn’t, providing them with necessary training is crucial.

Remember to Incorporate Comments in Your Code.

Developers should incorporate comments throughout their programming process, rather than waiting until the end of the project. Such practice can help prevent issues from emerging. Firstly, it ensures the task’s objectives are not forgotten, and secondly, it enables another developer to pick up and continue the project with minimal disruption, should the need arise.

Avoid Expressing Opinions on Everything.

Developers must comprehend the significance of not offering feedback on every single aspect of their work. Beginner programmers who feel the need to provide extensive documentation of their progress should understand that they should avoid giving feedback on the most recent technologies.

Suggest to your developers to ensure that their work adheres to standard norms and syntaxes. If that’s the case, typically, no comment is necessary.

Avoid Replacing Proper Documentation with Comments.

Code comments and documentation must be distinguished. Over-reliance on comments as documentation can result in lengthy and convoluted code, which is time-consuming and inefficient. Developers may avoid documenting their work, contributing to this issue.

Code comments should clarify the purpose and logic of methods and statements. Keeping the comments relevant is crucial to avoiding creating unnecessary clutter.

Avoid Making Comments that Refer to or Quote Other Comments.

Referring to other comments or documents can result in developers creating more work for themselves. In some cases, a developer may include a comment in the code that references another remark. This increases the workload for a programmer who follows along and has to go through the code to locate the referred-to comment, which is time-consuming.

Rather than pointing to an external source, developers should promptly supply the required information. It’s better to take on the necessary duties yourself than to delegate them to someone else.


Code commenting is crucial for developers to work effectively. Establishing good commenting practices from the start assures that any programmer can interpret code produced by others, including what’s been done, why it’s been done, and how it’s been done.

Join the Top 1% of Remote Developers and Designers

Works connects the top 1% of remote developers and designers with the leading brands and startups around the world. We focus on sophisticated, challenging tier-one projects which require highly skilled talent and problem solvers.
seasoned project manager reviewing remote software engineer's progress on software development project, hired from Works blog.join_marketplace.your_wayexperienced remote UI / UX designer working remotely at home while working on UI / UX & product design projects on Works blog.join_marketplace.freelance_jobs