你的“硬规则”是什么?关于评论您的代码? [英] What are your "hard rules" about commenting your code?

查看:137
本文介绍了你的“硬规则”是什么?关于评论您的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过其他问题,但我仍然不满意这个主题的涵盖。

I have seen the other questions but I am still not satisfied with the way this subject is covered.

我相信人们会说的话,只是互相取消的事情。但嘿,也许我们可以为每个营地建立一个名单。对于那些没有评论的人,只会非常短:)

I am sure people will say things that will just cancel each other. But hey, maybe we can build a list for each camp. For the guys who don't comment at all the list will just be very short :)

推荐答案

我有一个简单的规则评论:你的代码应该讲述你在做什么的故事;你的意见应该告诉你为什么这样做的故事。

I have one simple rule about commenting: Your code should tell the story of what you are doing; your comments should tell the story of why you are doing it.

这样,我确保谁继承我的代码将能够理解代码背后的意图。

This way, I make sure that whoever inherits my code will be able to understand the intent behind the code.

这篇关于你的“硬规则”是什么?关于评论您的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆