I don't have a formal computer science education, meaning that I did not study computer science topics in a university. However, I work at a programming job and write a reasonable amount of code. Naturally, programming means that I also have to document and comment my code.
The problem I seem to be having is deciding between two schools of thoughts:
Comment the hell out of your code e.g.
unsigned int subtractor (int subtractee, int subtractor) { /* - This function is a subractor and is used to subtract one integer from another. - In other words the case here is subtractee - subtractor. - Please ensure that the subractee is larger then the subtractor because this function will have undefined behaviour for negative answers. */ (The code here...) }
The code that explains itself let it be (no need to comment) like in this example. Just use good meaningful names.
Perhaps this example code makes one think that option (2) is better, but programmers with experience on large projects know that sometimes only meaningful names are not good enough. I know some commenting at appropriate places is a good practice but is it also a good idea to comment like in (1) to describe almost all major methods/functions?
The reason I ask is that a senior colleague at work told me to do as in (1) but now I am reading Clean Code by Robert C. Martin and it actually pretty simply states that (1) is a bad practice.
There are many other questions about commenting on this website but this question is different from others on this website because I am asking about a specific way of commenting i.e. (1).
UPDATE: What is the downside of writing more comments, this way a complete newbie can also understand it and also an advanced programmer (if he/she wants to read the comments anyway). But I understand that the advanced programmer will probably get a headache because he/she might read what they already know or can figure it out from the code anyway.
Another downside I can foresee is that the more you comment the more the chance that it might contain errors which can lead to confusions, but other good reasons we might have to comment miserly?
subtract (a,b)
looks much more natural thansubtractor (a,b)
.