{"id":581,"date":"2012-04-23T20:37:18","date_gmt":"2012-04-23T20:37:18","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=581"},"modified":"2012-04-23T20:37:18","modified_gmt":"2012-04-23T20:37:18","slug":"prefer-open-close-syntax-commenting","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/prefer-open-close-syntax-commenting\/","title":{"rendered":"Prefer open\/close syntax when commenting"},"content":{"rendered":"<p>In many languages, there are two ways to comment:<\/p>\n<ul>\n<li>Open\/close (often used for multi-line comments), i.e. \/* my comment *\/<\/li>\n<li>Single open (often used for end-of-line comments), i.e. \/\/ my comment<\/li>\n<\/ul>\n<p>This may be trivial for you, but if your language does not rely on line breaks to mark the end of a code line, then it may actually make more sense to stick with the multi-line comment syntax as a best-practice.<\/p>\n<p>Take JavaScript for example, which is often minified (and not always by a dedicated minifier):<\/p>\n<p>var a = &#39;b&#39;; \/\/ initialize a<br \/>\n\tvar b = &#39;c&#39;;<\/p>\n<p>Now, let&#39;s minify it to one line:<\/p>\n<p>var a = &#39;b&#39;; \/\/ initialize a var b = &#39;c&#39;;<\/p>\n<p>Our second assignment statement is commented out.<\/p>\n<p>While many folks out there make use of online services to minify JavaScript, this may not always be feasible (such as when using a home-brewed script to move your development site files to a live version, hence minifying JS code).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In many languages, there are two ways to comment: Open\/close (often used for multi-line comments), i.e. \/* my comment *\/ Single open (often used for&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/581"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=581"}],"version-history":[{"count":1,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/581\/revisions"}],"predecessor-version":[{"id":582,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/581\/revisions\/582"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}