Thursday, February 22, 2018

Modeling Good Coding Practice

Facebook showed me this cartoon this morning.

Programming alone

Teaching computer science means you are often programming while someone watches. I confess that I have been known to write something “quick and dirty” but that is not really an option for anything that students might ever see. Or really anyone else might see. “Do as I say not as I do” really doesn’t work for anything.

Generally I’m pretty careful about how I write code while I am doing a demo or creating a scaffold project for students. It requires a few extra minutes but I think it is important to model good practices. I think I have to make a point of explaining why I am taking those extra steps as they are not obvious to beginners.

Sure it seems unnecessary to rename a label box when there is only one label box on the form. Or to change the text property of the form. Or any one of a number of things that appear to be cosmetic and that don’t keep the program from working. But habits are important.

I remember once asking my father why we had to have perfect table manners at home where no one could see us. My father explained that by developing the good habits at home we would be less likely to mess up in public. It’s a lesson that stayed with me. It is why,even in the small simple code, using good coding practice is important. That way you don’t have to think about it when the coding gets public.

1 comment:

Garth said...

It is kind of like wearing clean underwear, you never know when you are going to be in an accident.

My problem is not good coding habits in front of the class, it is good typing in front of the class. The more people watching me type, the more my fingers do not want to hit the right keys. I also wish for better handwriting when I am at the board. The first line is OK. The second line is getting iffy. The third line might as well be Chinese ideograms.