General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
SmallSpoonBrigade
Thriving Technologist
comments
Comments by "SmallSpoonBrigade" (@SmallSpoonBrigade) on "If Code Is Self-Documenting, Why Do Comments Exist?" video.
@JanPavlikdr It depends what you're thinking of when documenting. The documentation here is just how it's being done. There's no value to those kinds of comments that isn't better dealt with by removing or rewriting the obfuscated code. But, documenting the why and the objective of the code is immensely helpful in most cases.
2
That's it. Self-document code should tell you what is going on, but it won't tell you why it's being that or necessarily much about the goal of the code. That is what comments are for, as well as cluing in future programmers about areas of the code that are likely to need to be changed in the distant future. Things like the Y2k bug in the '80s where memory was limited and there was no certainty that the code would still be in use at that time. Or if there is the expectation that an API might eventually change while the software is still useful.
2
@WarrenPostma No, or they didn't do a good job of explaining it. Code should document what is being done, it does not follow that the code is going to give you any information about why it was done the way that it was, or possible issues with other options. The point of comments is to tell yourself in the future, or future developers, why things are being done the way they are, or what you're trying to accomplish with the code. Not how the code is doing it. That should be obvious from the code itself if it's self-documenting.
1
@pablofernandogonzalezolmos8472 Yes, abbreviations are only find if you can open up the source a year later and remember what it means. In olden days, it made more sense to abbreviate, but with modern development environments providing autocompletion, there's no real reason to. That and storage is a lot larger than it was 30 years ago.
1
@WarrenPostma There's that, but there's also information about what the code needs to accomplish. Just because you've got some sort of a return value doesn't mean that you're not going to want more information coming back to the code later on without remembering why and what you were doing.
1