![]() | Ned Batchelder : Blog | Code | Text | Site Comments prevent execution » Home : Blog : October 2005 |
Comments prevent executionWednesday 19 October 2005 Looking for basic information about ASP.NET syntax, I found this description of Server-Side Comment Syntax. It explains:
There you have it: the point of a comment is to prevent a chunk of code from executing. There's no mention of using comments to communicate with other developers. This helps explain a number of Daily WTF's!
tagged:
coding» 3 reactions | |
Comments
Another developer recently told me the following code commenting philosophy one of his old colleagues swore by:
"If it's hard to write, it should be hard to read and even harder to change."
Comments are to prevent server code from executing? The author deserves a dope slap.
Note: the text does make an important, if muddled, point that everything between <%-- and --%> is filtered out. In other words, unlike HTML comments, these comments aren't sent to the client. An important distinction if the comments contain proprietary information -- or snide remarks. ;-)
As well as what Bob said, they really do mean what they say about it stopping code from executing.
If you have a server control in an ASPX page, and you comment it out with <!-- -->, the control will still be rendered on the server into the resulting HTML (which will be hidden on the client because of the comment tags), and any side-effects it might have (database updates, web-service calls, etc) will still take place. With the <%-- --%> comments, the server-side execution won't happen.
Add a comment: