Home » Tutorials » ColdFusion » Comments

Comments

Commenting in ColdFusion is different most other languages. The comment is very much like the HTML comment, but that extra – is super important. Don’t forget it. The ColdFusion comment doesn’t validate in HTML either, so be sure to not to use the ColdFusion comment on strictly HTML pages. I wish circumstances where different and Adobe choose a different commenting style, but that is the hand we are dealt. Always try to comment your work about every 30 lines or so you can remember what the following code does. It’s often a great idea to comment every function. Also, you make it easier for everyone else to figure out what you are doing and why. Like I said try for at least every 30 lines, but comment more when you are dealing with some complex code. One of the best pieces of information I acquired from digging through a previous developers work is that comments are always accurate. Whenever you update a piece of code in ColdFusion, make sure you update the comment too.

Example
<cfoutput>
    <!---ColdFusion Wrote me--->
    No, it didn't
</cfoutput>
Result No, it didn’t

So, in this example we had <!—ColdFusion Wrote me—> that was a comment, and it is on the server side. This means you will not see the comment at all on the client side. Thank goodness for that because we surely wouldn’t want people to search through our source code and find our deepest commented secrets. Finally, the only text that actually shows up on the client side is the No, it didn’t, which is exactly what we wanted.



Link/cite this page

If you use any of the content on this page in your own work, please use the code below to cite this page as the source of the content.

  • Stewart, Suzy. "Comments". After Hours Programming. Accessed on March 16, 2024. https://www.afterhoursprogramming.com/tutorial/coldfusion/comments-cf/.

  • Stewart, Suzy. "Comments". After Hours Programming, https://www.afterhoursprogramming.com/tutorial/coldfusion/comments-cf/. Accessed 16 March, 2024.

  • Stewart, Suzy. Comments. After Hours Programming. Retrieved from https://www.afterhoursprogramming.com/tutorial/coldfusion/comments-cf/.



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.