Believe it or not, the first person to teach me how to write a program was my mother. Our first computer was a Commodore 64 – and she was a pro at that thing. She has a bachelor’s in English and a Master’s in Reading; not who you’d expect to master BASIC in the early 80’s. In the days before the internet, she did some old-fashioned research, tracked down some books, and experimented a lot with programming until she was ready to teach it in a classroom a few years later. She wrote math programs for me, and she even taught me how to program by giving me the same rules she shared with her classroom, which I’ll share with you.
GIGO: Garbage In, Garbage Out
This is the most basic principle of programming, and it will never change. There’s plenty of ways to rephrase this, but it boils down to the fact that your program is only as good as the programmer. If a program kicks out something bad, it’s because of how it was coded. In web programming of course, we’re tempted to blame the web browser, sending hatred mainly to Internet Explore for our problems. And while web browsers have their differences, it’s the web developer who does or doesn’t figure out those compatibility issues. A computer can only do what you tell it.
Plan Your Program
Today this is called requirements gathering. Even on a freelance job where there’s no one but you writing code, this is still a necessary exercise. You need to figure out what your program will look like before you start writing it.
Logic is More Logical Than You
When it was time to start planning the program, my mother had a very ‘simple’ exercise: Write a workflow for how to walk. Doesn’t get easier than that, right?
Here’s what most of her students would produce: Bend knee. Lift right foot. Move right leg forward. Place heel on ground. Place toes on ground. Bend left knee. lift left foot. Move left leg forward. Place heel on ground. Place toes on ground.
With those steps, you’re going to fall, not walk. It’s because one tiny step is missing: shift weight. No robot is walking anywhere without that step. It’s a very logical step that we wouldn’t think of- because we’re used to walking. This happens to me: I plug in the Eric Meyer CSS reset and can’t figure out why my lists have no style. D’uh, the reset cleared my list style. I can’t figure out why my variables aren’t working, and it’s because I forgot to declare them. Computers don’t think, they depend on us to do that for them. Program for the computer, not for you.
Computers Can Be Buggy
One day one of my mother’s students had a very simple program that was failing. It was supposed to calculate addition, but according to the student, 3+4= 8. She referred him to GIGO, but the student was insistent that he did it right. When she looked at his code, it was clear he had done everything right . 5+2 was 7, as well as 6+1. But 3+4 was 8. So was 4+3. The computer simply was wrong. My mother, another teacher, and the principle all confirmed that the computer couldn’t do math.
Never forget that a program can just be buggy. Sometimes, the computer might even have a bug, literally.