In general, good programming style says you put in comments that are going to be valuable in helping you as a reader understand what's going on inside of the code.
通常来说,优秀的编码风格意味着,你要放进去的注释,在帮助代码阅读者,理解代码内部,是怎么工作的。
It's words to you, or to the reader of the code, that are telling you what's going on inside of this code. OK?
注释是一些对你,或者对代码阅读者说的一些话,告诉你这段代码,是干什么的,对不对?
Because as you'll soon find, when you're writing programs 0 that aren't just four lines long but are 40 or 400 which very quickly becomes easy, you'll find that even you the next morning have no idea what this code does for whatever reason, and just having some English comments is a huge boon to comprehension for yourself and others.
你们自己写程序时就会发现,用40行甚至400行代码来代替繁杂拥挤的4行代码0,将会让事情简化许多,你会发现,即使由于某些原因,你不知道如何写代码,先写些注释,于人于己,都是好事,易于理解嘛。
If you can read the code a year later, even code you wrote yourself, it's a good sign that you put good comments in, right?
如果你还能读懂1年前的代码,就算是你自己写的代码,这也说明了你放进去的注释,已经非常好了,对不对?
Give you some examples. What have we talked about? We've talked about things like using comments to highlight what you're doing in the code, to make it easier to debug.
给大家举些例子,我们一直在强调什么来着?,我们讲过要用注释来说明,你在代码中进行的操作,以便于调试。
So let's take a look then at somewhere where this is actually a useful thing to know so this is compare1.c. So, in compare1.c I've stripped out the comments in my version but in your version you do have comments for reference and it's actually pretty self-explanatory if you just read through the code.
那么再然我们看一看,一些有用的东西,这是compare1。c,所以在compare1。c中,在我的版本中,我吧注释去掉了,但是在你们的版本中是有注释的,这是相当容易理解的,如果你通读这段代码。
应用推荐