|
|
|
|
|
by astrodust
5000 days ago
|
|
I find it's best to describe what the argument are, as short names are rarely enough, and the return values or values supplied to callbacks under various conditions. An example would be: "Verify account takes an account ID, an optional enabled flag which, if specified, will only search for accounts that have a matching enabled status. The default is to search against all accounts. The return value is true if the account is valid, false otherwise." These are extremely important in loosely typed languages where there is little indication as to what constitutes an acceptable argument. In a more rigid language like C++ there are usually a lot more hints in the language about what the input and output is. Still, in programming "by contract" it is important to manage expectations and comments can communicate a lot of this. |
|
I will agree that some of that information is worth writing down, but I'm not yet convinced a comment within the code is the right place for it.
> These are extremely important in loosely typed languages where there is little indication as to what constitutes an acceptable argument.
Isn't that just pushing language "flaws" into the comments, not unlike annotations are being used here? I'll grant you that it is pragmatic when faced with lack of tools, but the grandparent suggested annotation comments were a bad idea but comments were a great idea, which seems contradictory to me in light of this.