I'm Just Sayin'
Apr. 30th, 2007 02:08 pmHave you ever noticed that some programmers comment their code like their job security depended on it? As in, if there are no comments in the code, then their job is secure, because no one will ever be able to decipher the code?
I'd think this was learned behavior, except that my formative programming experience was as a junior systems programmer on the PLATO system at the University of Illinois and none of the junior sysprogs there (except for me) commented their code either. And you know that they weren't planning on being around for a long time. (We had a shortage of Zonker Harris clones.)
I'm just sayin'...
I'd think this was learned behavior, except that my formative programming experience was as a junior systems programmer on the PLATO system at the University of Illinois and none of the junior sysprogs there (except for me) commented their code either. And you know that they weren't planning on being around for a long time. (We had a shortage of Zonker Harris clones.)
I'm just sayin'...
no subject
Date: 2007-04-30 07:19 pm (UTC)no subject
Date: 2007-04-30 07:25 pm (UTC)If code without comments is rejected, or if people have a performance component of their compensation that requires comments, or if the coder gets fired for not doing the job, people will learn. It is also the responsibility of project owners (i.e. executives) to include time/money for comments in the project plan; if the manager is given the directive "give me something that works by date X" then comments will be deprioritized.
With logical (and consistent) indentation and variable and function names, the amount of comments required should be minimal. Unsupportable code does not necessarily lead to job security, it can lead to hiring new programmers to reverse engineer the output. (Of course, that requires hiring managers who know how to manage programmers.)
no subject
Date: 2007-04-30 07:30 pm (UTC)I have this bad habit of thinking "right now it is 100% obvious what this block does, I don't need to put a comment here." You'd think after having to figure out what the code I wrote ten years -- or a week -- ago did more than once I'd learn. But the program I'm working on right now probably doesn't have all the comments it should.
no subject
Date: 2007-04-30 07:31 pm (UTC)* I write comments like I'm going to get hit by a beer truck the next day.
*
* Plus, it keeps me from having to remember what I was doing when I get back
* to that code 6 months later.
*
*/
no subject
Date: 2007-04-30 07:34 pm (UTC)I've been maintaining some of this code -- in one incarnation or another -- for nearly 25 years. I know I'm going to forget what I was doing when I wrote some of it.
no subject
Date: 2007-04-30 07:35 pm (UTC)no subject
Date: 2007-04-30 07:37 pm (UTC)I've had other people who were learning how to code tell me they loved reading my code because they could follow what I was doing and actually learn coding from real live code.
no subject
Date: 2007-04-30 07:42 pm (UTC)no subject
Date: 2007-04-30 07:48 pm (UTC)no subject
Date: 2007-04-30 07:55 pm (UTC)Bad programming is certainly a learned behavior pattern, but I doubt that it's learned intentionally, except in cases where people learn to do what their boss tells them to do even when they know it's stupid. As I see it, the problem is that good programming practices are seldom taught and almost never reinforced. I've been in several workplaces that made noises about having coding standards and real code reviews, but never one where the managers were actually willing to take the time to have code reviewed (and fixed by the coder and rereviewed until actually acceptable). It takes longer to get to nominal feature complete that way, and the fact that it will take less time to get from feature complete to genuinely releasable and less time to do future releases doesn't matter, because corporations are all about immediate results and managers are trained to think that way. (How many managers have you seen who would rather let the schedule slip than ship a shoddy product that they could claim met the specs? How many managers' managers would reward letting the schedule slip with a bonus rather than a severance package?)
no subject
Date: 2007-04-30 08:02 pm (UTC)no subject
Date: 2007-04-30 10:21 pm (UTC)The biggest problem I have with non-commenters is they tend to write the worst spaghetti code and then never have the time and/or patience to explain it to me when I have to fix/change something.
no subject
Date: 2007-04-30 11:22 pm (UTC)It's more likely that commenting is learned behavior innit?
no subject
Date: 2007-04-30 11:33 pm (UTC)no subject
Date: 2007-04-30 11:48 pm (UTC)I work in a university. It's no better there.
no subject
Date: 2007-05-01 02:37 am (UTC)I usually write the declaration for a function and a brief comment simultaneously, when I first discover that I need it, and write the body sometime later. Which might be much later, if I've been called away to work on something more important for a while. Or just get distracted while I'm having lunch.
no subject
Date: 2007-05-01 03:12 am (UTC)When I worked as a remote batch terminal operator at college, I noticed that some of the engineers wrote very dense and cryptic FORTRAN code. When I asked one about comments, their response was something like "The compiler ignores them, so putting in comments is not efficient."
no subject
Date: 2007-05-01 04:14 am (UTC)no subject
Date: 2007-05-01 04:15 am (UTC)no subject
Date: 2007-05-01 04:16 am (UTC)I will sometimes skip the comment for simple event handlers, because they're generally easy to trace from the message map. But that's an exceptional case.
no subject
Date: 2007-05-01 05:44 am (UTC)no subject
Date: 2007-05-01 05:51 am (UTC)no subject
Date: 2007-05-01 08:30 am (UTC)no subject
Date: 2007-05-01 02:48 pm (UTC)no subject
Date: 2007-05-01 03:41 pm (UTC)There's no way I know of to generate Word documents in Perl; LaTeX and HTML are easy. I can run a Makefile over my code tree and get typeset documentation in LaTeX, online documentation in HTML, and an installable application all in one command. And text is easy to manage in a version-control system, which gives me a changelog and a report of differences for both my code and my documentation.
... and there are a couple of WYSIWYG editors for LaTeX if you're foolish enough to think they'll make you more productive.
no subject
Date: 2007-05-01 05:52 pm (UTC)Not an issue in my case. I wasn't even documenting a software product at the time; I was producing user manuals for the Hubble Space Telescope. LaTeX was used because it was the only tool then available (1987-1993) that could properly typeset heavy-duty higher mathematics.
I can run a Makefile over my code tree and get typeset documentation in LaTeX, online documentation in HTML, and an installable application all in one command.
OK, under those circumstances LaTeX would be useful. I'll grant you that it has a reason to exist after all. However, if you were using LaTeX *only* as a glorified word processor (as I was forced to -- not my call) even Word would start looking awfully good by comparison.
Looking back, I think a lot of my ire at LaTeX comes from how difficult it was to tweak the template defaults for spacing and font size. (They didn't match the local style guide, and were ugly to boot.) Certain values would crash the Makefile run every time, while the next increment up or down would not.
there are a couple of WYSIWYG editors for LaTeX if you're foolish enough to think they'll make you more productive
Not if I were a programmer. But great Ghu, yeah, that would have made *me* more productive back in the day. Trying to produce camera-ready copy without WYSIWYG is like typing on an old manual typewriter in pitch blackness with sledgehammers for fingers. If you're good and persistent, you'll do it eventually, but you'll waste an awful lot of paper and the end result won't be nearly as pretty. Been there, done that, see no need to repeat the experience.