Home
Comments should not be nested
Description
The rule "Comments should not be nested" means that comments should not be placed within other comments. This is because comments are used to explain code and make it easier to read, and when they are nested they can become confusing and difficult to read. It is best practice to avoid nesting comments and instead use separate comments for each section of code.
Key Benefits
- Easier to read: Comments should not be nested, as this makes code harder to read and understand.
- Easier to maintain: When comments are not nested, it is easier to maintain and update.
- Reduced complexity: Nested comments can increase the complexity of the code, making it more difficult to debug.
- Improved performance: Nested comments can slow down the execution of the code, leading to decreased performance.
Non-compliant Code Example
SELECT
/* --Non compliant code (Nested comments)
Select Name, Address, Credit Limit columns in the customer table
/*Select customer details/*
*/
NAME,
ADDRESS,
CREDIT_LIMIT
FROM
CUSTOMERS
Compliant Code Example
SELECT
/* --Compliant code
Select Name, Address, Credit Limit columns in the customer table
Select customer details
*/
NAME,
ADDRESS,
CREDIT_LIMIT
FROM
CUSTOMERS