Style


I was going to title this “What would Kernighan and Plauger say?” but thought that the reference might be a little obtuse.

There’s an old saying that goes back to my early days “If a computer program was hard to write, it should be hard to read” or something like that. I still remember a professor leading into the topic of documentation with that and then convinced us that programming should be anything but that. You should be able to pick up anyone else’s work, look at the documentation and the code, and understand or modify to your own needs.

The book “The Elements of Programming Style” by Kernighan and Plauger was a required book for the course. I’ve read and discarded more textbooks than I should but I still have that one on my bookshelf. It was required reading for the course.

Throughout, there is a really deep discussion about how the appropriate style makes a program more desirable and readable. They inject bits of advice into the Fortran and PL/1 code. (yeah, I know…)

  • 10.0 times 0.1 is hardly ever 1.0.
  • 7/8 is zero while 7.0/8.0 is not zero.

And, of course, there’s lots more.

On Saturdays, I have a “Zoom Beer” with my friend Philip who teaches Computer Science at the university level. We had a chat about the style or lack of it that so many new students have when they’re writing code. His concern was the use of drag and drop programming languages which, while they can do amazing things, don’t necessarily force you to develop a style.

Some students take time to organize and kind of document their work.

Others come from the mindset that as long as it works, it’s good. Or, close enough is good enough.

I think that it’s worth consideration for all those who are going to incorporate coding into their classroom. It’s easy to sit in a presentation or a workshop and make something do some cool things. But, should students and teachers be satisfied with that? Does this develop enough skill to move on to bigger and better things?

We talk about design and style in all subject areas. There are expectations about what it should look like and how to assess things.

How do you assess “close enough is good enough”?

Advertisement

OTR Links 08/25/2022


Posted from Diigo. The rest of my favorite links are here.