Hacker News new | ask | show | jobs
by Facens 5550 days ago
Another best practice I have is to place a comment on each closing element, referring to the opening one. So,I have: <div class="CLASS"> CONTENTCONTENTCONTENT </div> <!-- .CLASS -->

When you have complex pages, with several nesting levels, this can save much, much time.

1 comments

Isnt there a danger that someone else working on your code might not respect that rule (or dare I say it, but maybe you're in a rush one day) and you don't update the comment when you update the class.

Now you've got comments saying in correct things, and you risk all sorts of confusion.

The same rule applies to commenting methods in code really, you don't comment what the code does exactly - just what the intention of the code is.

The time spent on keeping the code readable is never wasted :) Obviously, every developer must adopt this habit.