We use subversion – Should we place comments in my code anyways? [duplicate]

I brought up in a meeting an annoyance that code changes were not commented within the code itself. We use SVN (Subversion) for source control, and it was relayed to me that you can just go into SVN and check the history and see the changes.

My question is is this a best practices? It seems easier to me to place the comment in the code itself with the defect/user story reference (we use Rally/Agile) AND in the svn header when you check in the changes. My bosses seem to think putting it the code is unecessary, and I told them I completely disagreed with that practice. I’ve always been taught that comments in the code are never bad. This is not my first gig.

I was even more floored when he told me his boss has been known to rip out comments in some code. After I stopped having the shakes, I wanted to… vomit.

What do you think about comments in code vs/with comments in source control and what do you do as a best practice?

0

Absolutely! They serve two completely different purposes.

  • Your commit messages are only describing why you’re committing that particular changeset – customer request, fixing a particular bugs, etc. These would be where you log your user story references or bug references:

Revised method XYZ to cover additional use case highlighted by user story ABC.

Fixing bug 1234 which was caused by an off-by-one error in main loop

  • Comments in your code should describe why your code is written the way it is, or descriptive comments about the methods & variables (like headers to be processed by JavaDoc). See the example given at the end of the earlier answer.

The two concepts are independent. If you lose your source control, or migrate the code to a new VCS without retaining history, you’ve now lost all your documentation if you follow what your bosses suggest. And if you’re trying to debug a system in production with no comments in the code, you’re constantly flipping between reading hundreds of commits worth of SVN logs while trying to interpret the code & figure out what goes where.

The prospect of cramming the comments of hundreds of lines of code (which should be inlined with the code) into a single commit message is frightening.

5

I think there is not a general answer. It depends. Extra-commenting the code may bring noise and make it less readable.

Comments in the code like these:

// 2014/01/17 [email protected] changed this path:
$path="/...";

Shouldn’t be there. They should be in the version control comment, along with other changes. Also, you should have a ticketing system in which this change is reported. Say you have an issue in your ticketing system numbered 12345. Then, whenever you want to see what was done and why, and who asked for changing this url, etc. you would go to your ticketing system and look for it. Then you would find related issue numbered 12345. Then you should grep subversion history for issue 12345 (good practice to add related issue number in your commit comment), etc.

But, comments like these:

// path must be retrieved from file_helper broker, as it crashes otherwise because...
$path=file_helper::get_path(...)

Are very useful and they are worth to be there forever.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

We use subversion – Should we place comments in my code anyways? [duplicate]

I brought up in a meeting an annoyance that code changes were not commented within the code itself. We use SVN (Subversion) for source control, and it was relayed to me that you can just go into SVN and check the history and see the changes.

My question is is this a best practices? It seems easier to me to place the comment in the code itself with the defect/user story reference (we use Rally/Agile) AND in the svn header when you check in the changes. My bosses seem to think putting it the code is unecessary, and I told them I completely disagreed with that practice. I’ve always been taught that comments in the code are never bad. This is not my first gig.

I was even more floored when he told me his boss has been known to rip out comments in some code. After I stopped having the shakes, I wanted to… vomit.

What do you think about comments in code vs/with comments in source control and what do you do as a best practice?

0

Absolutely! They serve two completely different purposes.

  • Your commit messages are only describing why you’re committing that particular changeset – customer request, fixing a particular bugs, etc. These would be where you log your user story references or bug references:

Revised method XYZ to cover additional use case highlighted by user story ABC.

Fixing bug 1234 which was caused by an off-by-one error in main loop

  • Comments in your code should describe why your code is written the way it is, or descriptive comments about the methods & variables (like headers to be processed by JavaDoc). See the example given at the end of the earlier answer.

The two concepts are independent. If you lose your source control, or migrate the code to a new VCS without retaining history, you’ve now lost all your documentation if you follow what your bosses suggest. And if you’re trying to debug a system in production with no comments in the code, you’re constantly flipping between reading hundreds of commits worth of SVN logs while trying to interpret the code & figure out what goes where.

The prospect of cramming the comments of hundreds of lines of code (which should be inlined with the code) into a single commit message is frightening.

5

I think there is not a general answer. It depends. Extra-commenting the code may bring noise and make it less readable.

Comments in the code like these:

// 2014/01/17 [email protected] changed this path:
$path="/...";

Shouldn’t be there. They should be in the version control comment, along with other changes. Also, you should have a ticketing system in which this change is reported. Say you have an issue in your ticketing system numbered 12345. Then, whenever you want to see what was done and why, and who asked for changing this url, etc. you would go to your ticketing system and look for it. Then you would find related issue numbered 12345. Then you should grep subversion history for issue 12345 (good practice to add related issue number in your commit comment), etc.

But, comments like these:

// path must be retrieved from file_helper broker, as it crashes otherwise because...
$path=file_helper::get_path(...)

Are very useful and they are worth to be there forever.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật