技术控

    今日:129| 主题:49225
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] More Comments on Code Comments

[复制链接]
万圣节丶面具 发表于 2016-10-3 17:04:15
54 3

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
In my last blog post,    Comments on Comments, I was perhaps a bit harsh on the practice of comments in code. What I meant was that excessive    what comments, which are comments that explain what the code is doing, are a possible indicator that the developer who wrote them was uncertain that the code could speak for itself.  
  There are other reasons to write comments in code. Sometimes it’s clear what we’re doing but not always clear why we’re doing it.    Why comments, as I call them, say why something is being done in code. This could be because of a federal regulation or it could be expressing how a design comes together at a higher level. These kinds of comments can be breadcrumbs to the people maintaining the code so that they can get a sense of what is actually happening and maybe call out some design features that aren’t entirely obvious. But don’t resort to teaching your reader things they should already know.  
  Well-encapsulated code is often presented outside of the context in which it lives. This can make it difficult to understand, so visualization tools can be very helpful.
  The domain model should be represented in the objects’ relationships to each other in the system. This makes the system understandable to other people. But in a lot of systems I’ve seen, there were huge swaths of missing objects in their domain model. Sure they call out the important ones, the ones that are most visible, but many of them are actually made up of many smaller objects that they haven’t called out. Nor have they called out the main collaborator objects that their main objects interact with. This creates a shallow domain model and it forces developers to read every line of code in order to understand a system.
  I don’t believe developers should have to read all of my code in order to understand what it does. I believe developers should have to read my method signature and understand what my method does. I don’t like surprises so I keep my APIs clear and to the point. If I’m developing a library or a framework, I will spend extra attention on writing good developer documentation and probably provide a range of good examples through unit tests. Developers can get a good sense of how to use my APIs, but I’ll never bore them with lots of superfluous text.
友荐云推荐




上一篇:Kracekumar Ramaraju: RC week 0000
下一篇:Python 邮箱爆破
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

tzsagpze 发表于 2016-10-13 16:47:34
钓鱼岛是中国的,沙发是我的!
回复 支持 反对

使用道具 举报

刘飞飞 发表于 2016-11-16 09:15:20
涨姿势
回复 支持 反对

使用道具 举报

dalong2014 发表于 2016-11-16 09:32:01
医生叫我进行光合作用,不要熬夜了。
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表