dongzou1964 2011-08-04 13:14
浏览 29
已采纳

评论样式库...发布您的评论样式[关闭]

I love looking through other people's codes and see how they style their comments, most people use a mix of * and ////, and of course it all depends on the language, but I have definitely seen some good ways to comment and some bad ways. A coded page can really come together with the right commenting structure and make it really easy to read for someone coming into a project without any knowledge.

I am curious to see what people think are the best way to style comments, section divisions, etc. This could be for html, php, or anything else really.

  • 写回答

3条回答 默认 最新

  • douping6871 2011-08-04 13:27
    关注

    PHP:
    Personally I use // for everything inside of a method/function. It is annoying if someone uses /* */ because it makes it more difficult to comment out blocks of code

    For documentation purposes I use what phpdoc uses which is very similar to javadoc.

    /**
     * Overall description
     * @keyword - description
     */
    

    Usually a good rule is, if you go 15-20 lines without any comments, you need to put in some comments unless the code is truly self explanatory. While at the time you may think you'll remember your 500 line function and everything it does you often time won't. If it is someone else trying to come in and understand your code, it will only be harder for them!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答