jump to navigation

Doesn’t anyone ever comment any more? June 26, 2013

Posted by mareserinitatis in computers, research.
Tags: , , ,

While the title above may seem like a complaint about the blog, I am fairly certain that the lack of commentary is probably due to the lack of posting.

Instead, however, I feel like complaining about another issue (one I’ve likely addressed before): lack of comments in code.  One thing that frustrates me about teaching students to program is that they are generally unaware of how important it is to comment your code, particularly when that code is for a research project and may need to be picked up by someone else.

I guess I’m getting old enough that I’ve had several instances of attempting to pick up an old piece of my own code and realizing what a horrible job I did in commenting.  I’m now incredibly thorough when commenting my code so that I’ll be able to go back to it later and understand.

The real issue is, however, that no one ever taught me how to comment code.  It’s something I had to figure out for myself.  The only thing I ever saw was one brief section in Darnell and Margolis’ book.  While I agree with the Do’s they listed, I strongly disagree with a couple of the Don’ts:

  • Do not describe how a piece of code achieves its purpose.  This should be obvious from the code itself.
  • Do not repeat the code.  Comments should contain additional information that cannot be construed from the code itself.
  • Try not to use comments to explain the purpose of variables.  Instead, use meaningful variable names.

While I agree with the second bullet, I’ve learned over time that the first and third are bunk.  Specifically, there is this notion that well-written code should make it obvious as to what is being done.  Maybe if you’re the only person looking at your code, but that’s usually not the case.  As much as we would like to think that meaningful variable names will substitute for explanation in the comments, I’ve found that one person’s meaningful variables may not be that to another person and will probably require significant elaboration.  Further, truly meaningful variable names often need to be rather long, and few people want to take the time to type out names that would be exceptionally clear.  (And then there’s the programmer I knew who used exotic dancer’s names for his variables.  His code was a nightmare to debug.)

The first bullet is the one that really irritates me, however.  I have pulled up code I wrote from a class to use in another class and been completely confused because it had been years since I looked at it.  During the second go-around, I realized there was a chance I may end up using it again, so I started adding things in.  Specifically, I put in the comments that it was algorithm to do linear interpolation.  I even put a reference to the book I got the algorithm from, including page numbers, and what the inputs would need to be (including format requirements) as well as the outputs.  I mentioned what needed to be changed to use the code for other programs.  Finally, I went through and explained what was happening in each step or loop and what the variables meant (e.g., k is a counter, c is the coefficient array).  Without *all* this information, it was impossible to take the code I’d written and modify it for another use without putting in some significant effort.

The reason I went into such elaborate detail (and continue to do so) is that a lot of code, particularly when dealing with algorithms, is almost never intuitive.  If that were intuitive, references like the numerical recipes books would be useless.  (Well, they kind of are, but you know what I mean.)  Therefore, contrary to the advice given above, comment everything, how it works, what your variables mean, etc.  You and anyone else who uses your code later will be very appreciative.

Computers will make our lives better! September 3, 2012

Posted by mareserinitatis in computers, engineering, teaching.
Tags: , , ,
1 comment so far

Some days I really wonder.  I mean, my research would be almost impossible without computers.  However, I sometimes wonder about using them so much for teaching.

On the one hand, computers are very helpful if you’re attempting to implement universal design in a classroom.  Computers make things far more accessible.

And then there’s the other hand…

After last year, I decided that I would make one major change to the class.  I decided that, as much as possible, I would not accept in-class submission of homework assignments.  There are a few assignments my students must do on paper, such as their course schedule.  However, they have several assignments that are, more or less, short essays.  There are also assignments where they need to submit a file, like a powerpoint.  In order to avoid all the hassle of collecting assignments and handing them back (especially given one of those hassles is that it’s easy to lose submissions that are not handed in with everyone else’s), I figured that electronic submission would be a great way to keep track of these assignments.

Except…it seems like we’ve been plagued with technical difficulties so far this year.  Last week, a couple of the students couldn’t get in to submit their assignments.  (One brought his laptop to class to show me the problem.)  Yesterday, I was trying to post class notes, which students need to do their next assignment, but it wouldn’t allow me to upload any files.  Today, we can’t access the online classroom at all.

Obviously I’m going to give the students extra time because of these issues, but I hope they’re resolved soon.  I’m not sure I can deal with issues like this all semester.

Another one bites the dust April 30, 2012

Posted by mareserinitatis in computers.
Tags: ,

I’m typing my first post from my new laptop.  Ordinarily, getting a new computer as an occasion for great happiness…except when it’s not.  While I got a nice new computer, I have to admit that I’m disappointed.  Some of you may remember that a few months ago, my macbook hard drive bit the dust.  I replaced it with another and things have been cruising along rather nicely.  That is, until Saturday morning when I left the computer unplugged and it went through a hard shut down.  When I booted it back up…well, it didn’t boot.  And it looks like I lost the hard drive completely.

On the up side, I have a backup that’s only a month old, so I certainly didn’t lose as much as I could’ve.

And the whole time, this song has been running through my head:

Stupid computer tricks March 29, 2012

Posted by mareserinitatis in computers, research.
Tags: , , ,

I swear I’d be a help-desk person’s worst nightmare.

I’ve been struggling to get an application up and running, and when I requested some help, I was sent a bashrc file that was supposed to fix some path problems.  I installed this on Tuesday night, but things still didn’t seem to be working right.  I asked my husband for help (given he’s a lot more Unix literate than I am), and he couldn’t figure out what was going on, either.  Even after logging out and back in and then running the initialization again, it still couldn’t find the application I was trying to use.  It was like I’d never installed the file.  After spending well over an hour on this, we gave up.

Then next day, I was trying to show the problems to the person who sent me the file.  Except that when I showed hir, everything worked just as it was supposed to.

I’m glad it works now, but I sure wish the timing wasn’t perfect to make me look like an idiot.

A kick in the pants March 25, 2012

Posted by mareserinitatis in computers.
Tags: , ,
add a comment

Why is it whenever I need to do something of any significance that involves my computer, I have to upgrade about 10 things, one of which is always the OS?  I know I’m a slow adapter, but this is getting ridiculous.  I think the developers are out to get me…or at least, my paycheck.

What doctors and computer techs have in common September 28, 2011

Posted by mareserinitatis in computers.
Tags: ,

I don’t particularly care to deal with either doctors or computer techs.  Occasionally, you’ll find an awesome one…but a lot of them can be a pain.

When I was an undergrad, I was trying to get a poster printed at the computer center on campus.  Tried most of the day, and nothing seemed to be working.  Finally, I asked them if they had any NT computers that could print to the plotter.  Yeah…but they claimed it would make no difference.  I didn’t care.  I went to the computer running NT (which is what I’d been using on the lab computer), and was able to print it off without a hitch.  On the way out the door, the guy was still insisting that it shouldn’t have made a difference.

The problem seems to be that some computer techs think that they are always dealing with computer illiterates.  Maybe relative to them, I am, but that doesn’t mean I’m stupid, either.  When my computer started giving me problems, the first thing I did was to back it up and then start running the disk repair utilities.  When they crashed, I ran a hardware check.  Sure enough, there’s an error, so I wrote down the code and looked it up.

I tried to get things fixed through the warranty program I purchased (non-apple), and they said it could be 3-4 weeks before I get my computer back…and I would have to mail it out of state.  Sorry, but there’s no way I can go without it for a month.

Instead, I opted to call the two companies in town that do apple repairs.  The first person was not terribly helpful.  I told him it was a hard-drive error, and he said he would still have to run the diagnostic to see if it was.  Hello?!  If I can give you the number, it’s pretty obvious you’re just trying to gouge me.

The other person, however, took the number, talked to me on the phone about what I wanted for a replacement and said he could order and have it in by Thursday.  He asked if I was okay with restoring my data to the new hard drive, and since I was, he said it would probably take 1/2 hour to swap hard drives, so he could do it while I waited.

Guess which person I’m going to take my business to?

On a slightly related note, I feel naked not having my computer bag with me all the time.

Blue screen of (MacBook) death September 26, 2011

Posted by mareserinitatis in computers, meta.
Tags: , , ,
1 comment so far

I didn’t know that macs had a blue screen of death, but I encountered it.  On Saturday, I was working, when suddenly my desktop disappeared and was replaced with deep blue nothing and a moving cursor.

Not good.

I hooked up an external drive, backed everything up (once I rebooted), and then ran some diagnostics.  Looks like my hard drive bit the dust.

I’m in the midst of waiting for things to go through the red tape for the warranty (non-apple) that came with the computer when I bought it.  (The U bookstore was selling specially priced bundles.)  So far, they said I needed to provide a copy of the original receipt.

Yeah, right.

Fortunately, UMN bookstore actually had a copy and sent it to me, and I’ve passed it along.  No clue how long this will take.

So, anyway, now you know I might not be around too much until it’s fixed except maybe on twitter (because that’s the only thing easy enough to read on my iPhone).

Fresh (programming) blood December 4, 2010

Posted by mareserinitatis in education, poll.
Tags: ,

For those of you who spend any amount of time programming, I have three questions. Please leave a response with your answer in the comments.

1 – What age were you when you first started programming?

2 – What caused you to learn to program?

3 – What was the first language you learned to program in? (I am fine if this language is visual, such as LabView. I’m looking for an ability to give a computer a sequential set of commands.)

I’ll probably write a follow up to this, but I am extremely curious.


Get every new post delivered to your Inbox.

Join 1,260 other followers