Do you use special comments on bug fixes in your c

2020-07-02 06:04发布

Some of my colleagues use special comments on their bug fixes, for example:

// 2008-09-23 John Doe - bug 12345
// <short description>

Does this make sense?
Do you comment bug fixes in a special way?

Please let me know.

标签: comments
2楼-- · 2020-07-02 06:25

Only if the solution was particularly clever or hard to understand.

3楼-- · 2020-07-02 06:25

I don't work on multi-person projects, but I sometimes add comments about a certain bug to a unit test.

Remember, there's no such thing as bugs, just insufficient testing.

4楼-- · 2020-07-02 06:26

If you add comments like that after a few years of maintaining the code you will have so many bug fix comments you wouldn't be able to read the code.

But if you change something that look right (but have a subtle bug) into something that is more complicated it's nice to add a short comment explaining what you did, so that the next programmer to maintain this code doesn't change it back because he (or she) thinks you over-complicated things for no good reason.

5楼-- · 2020-07-02 06:27

When I make bugfixes/enhancements in third party libraries/component I often make some comments. This makes it easier find and move the changes if I need to use a newer version of the library/component.

In my own code I seldom comments bugfixes.

Emotional °昔
6楼-- · 2020-07-02 06:30

Comments like this are why Subversion lets you type a log entry on every commit. That's where you should put this stuff, not in the code.

7楼-- · 2020-07-02 06:30

Don't duplicate meta data that your VCS is going to keep for you. Dates and names should be in the automatically added by the VCS. Ticket numbers, manager/user names that requested the change, etc should be in VCS comments, not the code.

Rather than this:

//$DATE $NAME $TICKET //useful comment to the next poor soul

I would do this:

//useful comment to the next poor soul

登录 后发表回答