Page 1 of 1

What is commenting out?

Posted: Mon Mar 17, 2025 5:07 am
by ashammi228
Comments out are strings written in the source code of a ig database program that are not executed as part of the program. In other words, they are explanatory text or annotations that are completely ignored by computers and exist only for humans. Cosmo Kikaku is a website production company with over 25 years of experience producing more than 10 websites per year and a total of over 300 companies , and we have seen many cases where the appropriate use of comment outs was the key to the success of a project.

I will explain based on my experience of more than a quarter century since the company was founded and my track record with more than 300 companies. There are many different opinions on the topic, but I hope this will be helpful.


Time required: 7 minutes

table of contents
OPEN
1. Basic way to write comments
1.1. 1. Single-line comments
JavaScript example
1.2. 2. Multi-line comments
CSS Example
1.3. 3. Documentation Comments
1.3.1. JavaScript Example (JSDoc)
2. Strategic use of commenting out
2.1. 1. Temporary Disabling of Code
2.2. 2. Version control and saving alternatives
2.3. 3. Create a TODO list or reminder
. TODO: Optimize the performance of this function
. FIXME: Need to add error handling
.Commenting out examples and best practices
2.4. 1. Write comments at the right level of granularity
2.5. 2. Keep comments up to date
2.6. 3. Make the purpose of the code block clear
3. Pitfalls and points to note when commenting out
3.1.1. Discrepancy between comments and code
3.2. 2. Excessive comments
3.3.3. Accumulation of commented out code
4. Summary: Effective commenting improves development efficiency
Basic commenting syntax
In Cosmo Kikaku's opinion, the way to write comments varies depending on the programming language, but we will introduce some of the most common examples. Please refer to the specific source code below.

1. Single-line comments
This is a way to comment out a single line. In many languages, this is done using "//".

JavaScript Example
// This is a single-line comment.
let greeting = "Hello World"; // You can also write a variable description like this.

2. Multi-line comments
Used to write comments that span multiple lines. In many languages, "/* */" is used.

CSS Example
/*
This is a multi-line comment.
Header style specification
Last updated: 2025.3.10
*/
header {
background-color: #333;
color: white;
}

3. Documentation Comments
These are special comments used for automatic documentation generation, especially for function and class descriptions.

JavaScript example (JSDoc)
/**

A function that adds two numbers
@param {number} a - the first number
@param {number} b - the second number
@returns {number} Addition result
*/
function add(a, b) {
return a + b;