Minimal Advice to Undergrads on Programming
cscs.umich.edu
Minimal Advice to Undergrads on Programming
1–8 of 8 posts
Re: Minimal Advice to Undergrads on Programming
#2My general policy is to follow the "Use meaningful names" policy and use that as the commenting. The meaningful names of the function give you an idea of what they do and what side effects they have. The meaningful names of the parameters tell you what they do.
Maybe it's not a perfect system, but I think it's a happy medium between eating up a lot of time commenting and having totally unreadable code
Re: Minimal Advice to Undergrads on Programming
#3Does anyone comment to that degree? My general policy is to follow the "Use meaningful names" policy and use that as the commenting. The meaningful names of the function give you an idea of what they do and what side effects they have. The meaningful names of the parameters tell you what they do. Maybe it's not a perfect system, but I think it's a happy medium between eating up a lot of time commenting and having tot…
Comments themselves have, especially when you have lots of them, a really high danger of not getting updating and therefor becoming a liability.
When you write code you are supposed to write (1) the tests, (2) the documentation and (3) the actual code. Only one of those can make what you want to happen happen, and one of those is annoying if it doesn't get fixed but one of those wont do anything if completely wrong. At least not right away.
Re: Minimal Advice to Undergrads on Programming
#4Does anyone comment to that degree? My general policy is to follow the "Use meaningful names" policy and use that as the commenting. The meaningful names of the function give you an idea of what they do and what side effects they have. The meaningful names of the parameters tell you what they do. Maybe it's not a perfect system, but I think it's a happy medium between eating up a lot of time commenting and having tot…
If there are assumed states or input ranges, asserts are better than comments. Comments drift out of correctness, asserts don't.
I try to design data and configuration files with comments and then comment them with field descriptions and examples.
Re: Minimal Advice to Undergrads on Programming
#5Does anyone comment to that degree? My general policy is to follow the "Use meaningful names" policy and use that as the commenting. The meaningful names of the function give you an idea of what they do and what side effects they have. The meaningful names of the parameters tell you what they do. Maybe it's not a perfect system, but I think it's a happy medium between eating up a lot of time commenting and having tot…
As an undergrad, it's probably better to err on the side of too many comments. Then trim them down later as you get better at it.
Good comments also probably helps your prof grade your work.
Re: Minimal Advice to Undergrads on Programming
#6Does anyone comment to that degree? My general policy is to follow the "Use meaningful names" policy and use that as the commenting. The meaningful names of the function give you an idea of what they do and what side effects they have. The meaningful names of the parameters tell you what they do. Maybe it's not a perfect system, but I think it's a happy medium between eating up a lot of time commenting and having tot…
These days, though, TDD is winning a lot of converts as a more effective means of specifying the expected behavior or code. Whether you consider that a good thing probably depends on your relative opinion of executable vs. human-readable specifications.
Re: Minimal Advice to Undergrads on Programming
#7Does anyone comment to that degree? My general policy is to follow the "Use meaningful names" policy and use that as the commenting. The meaningful names of the function give you an idea of what they do and what side effects they have. The meaningful names of the parameters tell you what they do. Maybe it's not a perfect system, but I think it's a happy medium between eating up a lot of time commenting and having tot…
And agreed, code with many short, _well-named_ functions is generally more readable than code with a few cumbersome, but heavily documented ones. Also, the places where I'm inclined to put a line comment are usually natural boundaries for extracting code into its own function.
Re: Minimal Advice to Undergrads on Programming
#8Does anyone comment to that degree? My general policy is to follow the "Use meaningful names" policy and use that as the commenting. The meaningful names of the function give you an idea of what they do and what side effects they have. The meaningful names of the parameters tell you what they do. Maybe it's not a perfect system, but I think it's a happy medium between eating up a lot of time commenting and having tot…