{"id":10916,"date":"2019-01-06T21:15:45","date_gmt":"2019-01-06T13:15:45","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=10916"},"modified":"2024-08-16T19:34:40","modified_gmt":"2024-08-16T11:34:40","slug":"source-code-comment-styling-tips","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/","title":{"rendered":"Optimizing Source Code Comments for Clarity and Efficiency"},"content":{"rendered":"<p>Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can become complex. With so many elements like functions, variable references, return values, and parameters, how can you keep everything organized?<\/p>\n<p>It\u2019s no surprise that commenting your code is crucial for both solo and team projects. However, many developers are unsure of the best practices for doing so. Below, I\u2019ve shared some personal tips for <strong>crafting neat, well-formatted code comments<\/strong>. Standards and comment templates may vary among developers, but your goal should always be <strong>clear and readable comments<\/strong> to explain any potentially confusing areas in your code.<\/p>\n<p>Let\u2019s begin by discussing some of the differences in comment formatting. This will give you a better understanding of just how detailed you can be with project code. Afterward, I\u2019ll share specific tips and examples that you can start using right away!<\/p>\n<h2>Comment Styles: An Overview<\/h2>\n<p>The ideas presented here are intended as <strong>guidelines<\/strong> for cleaner comments. Individual programming languages don\u2019t typically provide specific guidelines or specifications for how to structure your documentation.<\/p>\n<p>That said, modern developers have developed their own systems of code commenting. I\u2019ll cover a few mainstream styles and detail their purposes.<\/p>\n<h3>Inline Commenting<\/h3>\n<p>Almost every programming language supports <strong>inline comments<\/strong>. These are limited to single-line content and only comment on the text after a certain point. For example, in C\/C++, you begin an inline comment like this:<\/p>\n<pre>\r\n\/\/ Start variable listing\r\nvar myvar = 1;\r\n<\/pre>\n<p>Inline comments are perfect for briefly <strong>explaining potentially confusing functionality<\/strong>. If you\u2019re working with many parameters or function calls, you might place several inline comments nearby. However, the most beneficial use is a <strong>simple explanation for small functionality<\/strong>.<\/p>\n<pre>if(callAjax($params)) { \/\/ Successfully run callAjax with user parameters\r\n  ... code \r\n}<\/pre>\n<p>In the example above, the code must be on a new line after the opening bracket; otherwise, it would all be caught on the same comment line! <strong>Avoid overusing<\/strong> inline comments, as you generally don\u2019t need them on every line. However, they are helpful for particularly confusing junctions in your code and are easy to add at the last minute.<\/p>\n<h3>Descriptive Blocks<\/h3>\n<p>When a single-line comment won\u2019t suffice, <strong>descriptive blocks<\/strong> come into play. These pre-formatted comment templates are widely used in programming, especially around functions and library files. Whenever you create a new function, it\u2019s good practice to <strong>add a descriptive block above the declaration<\/strong>.<\/p>\n<pre>\/**\r\n  @desc Opens a modal window to display a message\r\n  @param string $msg - The message to be displayed\r\n  @return bool - Success or failure\r\n *\/\r\nfunction modalPopup($msg) {\r\n  ...\r\n}\r\n<\/pre>\n<p>In the example above, I\u2019ve created a JavaScript function named <em>modalPopup<\/em>, which takes a single parameter. The comments above use a syntax similar to <a href=\"https:\/\/www.phpdoc.org\/\" rel=\"nofollow noopener\" target=\"_blank\">phpDocumentor<\/a>, where each line begins with an <em>@<\/em> symbol followed by a specific key. These tags, known as <strong><a href=\"https:\/\/manual.phpdoc.org\/HTMLSmartyConverter\/HandS\/phpDocumentor\/tutorial_tags.pkg.html\" rel=\"nofollow noopener\" target=\"_blank\">comment tags<\/a><\/strong>, are documented extensively on their website. Feel free to create your own tags and use them throughout your code as needed. They help keep everything organized so that <strong>you can quickly reference important information<\/strong>. I\u2019ve used the <code>\/* *\/<\/code> block-style commenting format, which keeps the comments <strong>much cleaner<\/strong> than adding a double slash at the beginning of each line.<\/p>\n<h3>Group\/Class Comments<\/h3>\n<p>Aside from commenting on functions and loops, block comments aren\u2019t used as frequently. However, you need strong <strong>block comments<\/strong> at the beginning of your backend documents or library files. This practice is common in many CMSs like <a href=\"https:\/\/www.hongkiat.com\/blog\/category\/wordpress\/\" target=\"_blank\" rel=\"noopener\">WordPress<\/a>.<\/p>\n<p>The top section of your file should contain comments regarding the file itself. This allows you to <strong>quickly identify what you\u2019re editing<\/strong> when working on multiple files simultaneously. Additionally, you can use this area as <strong>a reference point for the most important functions<\/strong> within the class.<\/p>\n<pre>\/** \r\n  @desc This class holds functions for user interaction\r\n  Examples include user_pass(), user_username(), user_age(), user_regdate()\r\n  @author Jake Rocheleau jakerocheleau@gmail.com\r\n  @required settings.php\r\n *\/\r\nabstract class myWebClass { }\r\n<\/pre>\n<p>In the example above, I\u2019ve created a sample class named <code>myWebClass<\/code>. I\u2019ve added meta information, including <strong>my name and email address for contact<\/strong>. When developers write open-source code, this is generally a good practice so that others may contact you for support. This method is also useful when working in larger development teams.<\/p>\n<p>The tag <code>@required<\/code> isn\u2019t widely used, but I\u2019ve maintained it in a few of my projects, particularly on pages where I\u2019ve customized many methods. When including files in a project, they must be loaded before any code is output. Adding these details to the main class comment block is a good way to <strong>remember which files are required<\/strong>.<\/p>\n<h2>Front-end Code Commenting<\/h2>\n<p>Now that we\u2019ve covered three important comment templates, let\u2019s explore some other examples. Many front-end developers have transitioned from static <a href=\"https:\/\/www.hongkiat.com\/blog\/tag\/html\/\" target=\"_blank\" rel=\"noopener\">HTML<\/a> to <a href=\"https:\/\/www.hongkiat.com\/blog\/tag\/jquery\/\" target=\"_blank\" rel=\"noopener\">jQuery<\/a> and <a href=\"https:\/\/www.hongkiat.com\/blog\/tag\/css\/\" target=\"_blank\" rel=\"noopener\">CSS<\/a>. While HTML comments aren\u2019t as critical as in programming, when writing style libraries and page scripts, things can get messy over time.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/css.jpg\" alt=\"CSS comment example\" width=\"500\" height=\"333\"><\/figure>\n<p>JavaScript follows a more traditional commenting method, similar to Java, PHP, and C\/C++. <strong>CSS only uses block-style comments denoted by a slash and asterisk<\/strong>. Remember, since neither CSS nor JS is parsed server-side, comments will be visible to your visitors. However, both methods are effective for leaving helpful notes in your code to review later.<\/p>\n<p>Breaking up CSS files can be tedious. We all know about leaving inline comments to explain fixes for Internet Explorer or Safari. But I believe CSS commenting can be as organized as jQuery and PHP commenting. Let\u2019s dive into creating style groups before discussing some detailed tips for code commenting.<\/p>\n<h2>CSS Style Groups<\/h2>\n<p>For seasoned CSS designers, commenting becomes second nature. You gradually memorize all the properties, syntax, and develop your own system for stylesheets. Through my experience, I\u2019ve developed a method called <strong>grouping<\/strong> to organize similar CSS blocks into specific areas.<\/p>\n<p>When I need to edit CSS, I can quickly find what I need. How you choose to group styles is entirely up to you, which is the beauty of this system. Below are a few preset standards I\u2019ve established:<\/p>\n<ul>\n<li>@resets \u2013 Resets default browser margins, padding, fonts, colors, etc.<\/li>\n<li>@fonts \u2013 Styles for paragraphs, headings, blockquotes, links, code<\/li>\n<li>@navigation \u2013 Main website navigation links<\/li>\n<li>@layout \u2013 Wrapper, container, sidebars<\/li>\n<li>@header & @footer \u2013 May vary based on your design. Possible styles include links, unordered lists, footer columns, headings, sub-navs<\/li>\n<\/ul>\n<p>When grouping stylesheets, I\u2019ve found the <strong>tagging system<\/strong> to be incredibly helpful. Unlike PHP or JavaScript, I use a single <em>@group<\/em> tag followed by a category or keywords. Below are two examples to illustrate:<\/p>\n<pre>\/** @group footer *\/\r\n#footer { styles... }<\/pre>\n<pre>\/** @group footer, small fonts, columns, external links **\/\r\n<\/pre>\n<p>Alternatively, you could add more detail to each comment block. I prefer to <strong>keep things simple and straightforward<\/strong> so the stylesheets are easy to skim. Commenting is all about documentation, so as long as you understand your notes, you\u2019re good to go!<\/p>\n<h2>4 Tips for Better Comment Styling<\/h2>\n<p>We\u2019ve spent the first half of this article exploring various formats for code commenting. Now, let\u2019s discuss some overall tips for keeping your code clean, organized, and easy to understand.<\/p>\n<h3>1. Keep Everything Readable<\/h3>\n<p>As developers, we sometimes forget that <strong>we\u2019re writing comments for humans to read<\/strong>. All programming languages are designed for machines, so it can be tedious to translate code into plain, written text. It\u2019s important to remember that you\u2019re not writing a research paper \u2013 you\u2019re simply <strong>leaving helpful tips<\/strong>!<\/p>\n<pre>function getTheMail() {\r\n  \/\/ Code here will build e-mail\r\n  \/\/ Run code if our custom sendMyMail() function call returns true\r\n  \/\/ Find sendMyMail() in \/libs\/mailer.class.php\r\n  \/\/ Check if the user fills in all fields and the message is sent!\r\n  \r\n  if(sendMyMail()) { \r\n    return true; \/\/ Keep true and display onscreen success\r\n  }\r\n}\r\n<\/pre>\n<p>Even a few words are <strong>better than nothing<\/strong>. When you return to edit and work on projects later, it\u2019s often surprising how much you\u2019ll forget. Since you aren\u2019t working with the same variables and function names every day, it\u2019s easy to forget significant portions of your code. Therefore, <strong>you can never leave too many comments<\/strong> \u2013 but you can leave too many unhelpful comments.<\/p>\n<p>As a general rule, <strong>pause and reflect before writing<\/strong>. Ask yourself <strong>what is most confusing about the program<\/strong> and <strong>how you can best explain it in simple language<\/strong>. Also, consider <strong>why you\u2019re writing the code exactly as you are<\/strong>.<\/p>\n<p>Some of the most confusing errors arise when you forget the purpose of custom-built (or third-party) functions. <strong>Leave a comment trail leading back to other files<\/strong> if this will help you remember the functionality more easily.<\/p>\n<h3>2. Alleviate Some Space!<\/h3>\n<p>I can\u2019t emphasize enough the importance of <strong>whitespace<\/strong>. This is especially true for PHP and Ruby developers working on massive websites with hundreds of files. You\u2019ll be staring at this code all day long! Wouldn\u2019t it be great if you could easily skim through to the important areas?<\/p>\n<pre>$dir1 = \"\/home\/\"; \/\/ Set main home directory\r\n$myCurrentDir = getCurDirr(); \/\/ Set the current user directory\r\n$userVar = $get_username(); \/\/ Current user's username\r\n<\/pre>\n<p>In the example above, you\u2019ll notice the extra padding I\u2019ve added between the comments and the code on each line. As you scroll through files, this style of commenting will <strong>clearly stand out<\/strong>. It <strong>makes finding errors and correcting your code significantly easier<\/strong> when variable blocks are <strong>clean and organized<\/strong>.<\/p>\n<p>You could apply a similar technique to the code inside a function when you\u2019re confused about how it works. However, this method could clutter your code with inline comments, which is the opposite of orderly! In such cases, I recommend <strong>adding a large block comment around the area of logic<\/strong>.<\/p>\n<pre>$(document).ready(function() {\r\n  $('.sub').hide(); \/\/ Hide sub-navigation on page load\r\n  \r\n  \/\/ Check for a click event on an anchor inside .itm div\r\n  \/\/ Prevent the default link action so the page doesn't change on click\r\n  \/\/ Access the parent element of .itm followed by the next .sub list to toggle open\/close\r\n  \r\n  $('.itm a').live('click', function(e){\r\n    e.preventDefault();\r\n    $(this).parent().next('.sub').slideToggle('fast');\r\n  });\r\n});\r\n<\/pre>\n<p>This is a small piece of jQuery code targeting a sub-menu sliding navigation. The first comment is inline to explain why we\u2019re hiding all the <code>.sub<\/code> classes. Above the live click event handler, I\u2019ve used a block comment and <strong>indented all the writing to the same point<\/strong>. This approach makes your comments visually appealing and easier to read \u2013 especially for others who may read your code.<\/p>\n<h3>3. Comment While Coding<\/h3>\n<p>Along with proper spacing, this may be one of the best habits to develop. Nobody wants to go back over their program after it\u2019s working and document every piece. Most of us don\u2019t even want to go back and document the confusing areas! It really does take a lot of effort.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/comment-while-coding.jpg\" alt=\"Developer commenting code while coding\" width=\"500\" height=\"331\"><\/figure>\n<p>However, if you write the comments while you\u2019re coding, <strong>everything will still be fresh in your mind<\/strong>. Developers often get stuck on a problem and search the web for the easiest solution. When you finally solve the problem, there\u2019s usually a moment of clarity when you understand your previous mistakes. This is the <strong>perfect time<\/strong> to leave open and honest comments about your code.<\/p>\n<p>Additionally, this practice will help you get used to commenting on all your files. The time required to figure out how something works is much longer after you\u2019ve already built the function. <strong>Both your future self and your teammates will appreciate that you left comments ahead of time<\/strong>.<\/p>\n<h3>4. Dealing with Buggy Errors<\/h3>\n<p>We can\u2019t all sit in front of the computer for hours writing code. While it\u2019s possible to try, at some point, we all need to rest! You may have to part ways with your code for the day, leaving some features still broken. In such cases, it\u2019s crucial to <strong>leave long, detailed comments about where you left off<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/checking-code.jpg\" alt=\"Developer checking code for errors\" width=\"500\" height=\"331\"><\/figure>\n<p>Even after a good night\u2019s sleep, you may be surprised by how difficult it is to get back into the swing of coding. For example, if you\u2019re building an image upload page and have to leave it incomplete, you <strong>should comment about where in the process you stopped<\/strong>. Are the images uploading and being stored in temporary memory? Or perhaps they aren\u2019t recognized in the upload form, or they aren\u2019t displayed properly on the page after upload.<\/p>\n<p>Commenting on errors is important for two main reasons. First, you can <strong>easily pick up where you left off<\/strong> and <strong>try again with a fresh perspective to fix the problem(s)<\/strong>. Second, you can <strong>differentiate between the live production version of your website and the testing environment<\/strong>. Remember, comments should be used to <strong>explain why you\u2019re doing something<\/strong>, not just what it does.<\/p>\n<h2>Conclusion<\/h2>\n<p>Developing web apps and software is a fulfilling practice, though it can be challenging. If you\u2019re one of the developers who truly understands building software, it\u2019s important to continue maturing your coding skills. <strong>Leaving descriptive comments is a good practice in the long run<\/strong>, and you\u2019ll likely never regret it!<\/p>\n<p>If you have suggestions for clearer code commenting, feel free to share them in the discussion area below!<\/p>","protected":false},"excerpt":{"rendered":"<p>Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can become complex. With so many elements like functions, variable references, return values, and parameters, how can you keep everything organized? It\u2019s no surprise that commenting your code is crucial for both solo&hellip;<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[352],"tags":[507,506,4117,1319,1884],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Optimizing Source Code Comments for Clarity and Efficiency - Hongkiat<\/title>\n<meta name=\"description\" content=\"Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Optimizing Source Code Comments for Clarity and Efficiency\" \/>\n<meta property=\"og:description\" content=\"Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-06T13:15:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-16T11:34:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/css.jpg\" \/>\n<meta name=\"author\" content=\"Jake Rocheleau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jake Rocheleau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/\"},\"author\":{\"name\":\"Jake Rocheleau\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\"},\"headline\":\"Optimizing Source Code Comments for Clarity and Efficiency\",\"datePublished\":\"2019-01-06T13:15:45+00:00\",\"dateModified\":\"2024-08-16T11:34:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/\"},\"wordCount\":1931,\"commentCount\":25,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/code-commenting-tips\\\/css.jpg\",\"keywords\":[\"CSS\",\"HTML\",\"Javascripts\",\"PHP\",\"source code\"],\"articleSection\":[\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/\",\"name\":\"Optimizing Source Code Comments for Clarity and Efficiency - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/code-commenting-tips\\\/css.jpg\",\"datePublished\":\"2019-01-06T13:15:45+00:00\",\"dateModified\":\"2024-08-16T11:34:40+00:00\",\"description\":\"Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/code-commenting-tips\\\/css.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/code-commenting-tips\\\/css.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/source-code-comment-styling-tips\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Optimizing Source Code Comments for Clarity and Efficiency\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\",\"name\":\"Jake Rocheleau\",\"description\":\"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/jake\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Optimizing Source Code Comments for Clarity and Efficiency - Hongkiat","description":"Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/","og_locale":"en_US","og_type":"article","og_title":"Optimizing Source Code Comments for Clarity and Efficiency","og_description":"Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can","og_url":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2019-01-06T13:15:45+00:00","article_modified_time":"2024-08-16T11:34:40+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/css.jpg","type":"","width":"","height":""}],"author":"Jake Rocheleau","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Jake Rocheleau","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/"},"author":{"name":"Jake Rocheleau","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a"},"headline":"Optimizing Source Code Comments for Clarity and Efficiency","datePublished":"2019-01-06T13:15:45+00:00","dateModified":"2024-08-16T11:34:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/"},"wordCount":1931,"commentCount":25,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/css.jpg","keywords":["CSS","HTML","Javascripts","PHP","source code"],"articleSection":["Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/","url":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/","name":"Optimizing Source Code Comments for Clarity and Efficiency - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/css.jpg","datePublished":"2019-01-06T13:15:45+00:00","dateModified":"2024-08-16T11:34:40+00:00","description":"Developers working on large projects quickly learn the importance of code comments. As you build numerous features into the same application, things can","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/css.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/code-commenting-tips\/css.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/source-code-comment-styling-tips\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Optimizing Source Code Comments for Clarity and Efficiency"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a","name":"Jake Rocheleau","description":"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/jake\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-2Q4","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=10916"}],"version-history":[{"count":4,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10916\/revisions"}],"predecessor-version":[{"id":72598,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10916\/revisions\/72598"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=10916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=10916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=10916"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=10916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}