So you want to learn to program

Last week my friend asked me how she could learn to program. She’s a lawyer now, but she took one C++ programming class in college years ago.

I started down some long path: “Python is a nice beginner language. But you’ll want the most current Python version. You use a Mac, so you should get homebrew, so you can download the latest Python. Then you’ll need to install pip so you can get new Python packages. And you’ll do better in an IDE, so you should probably get Pycharm from JetBrains.”

What, am I insane? She doesn’t want to do all this. So I backed up: “What are you interested in about learning to program?”

Continue reading “So you want to learn to program”

Writing Solid Code

Writing-Solid-Code

I came across Writing Solid Code by Steve Maguire (Microsoft Press, 1993) at work. My boss had a shelf full of 90’s software texts, and this one caught my eye while I was waiting for a meeting to start.

It’s fantastic, and all programmers should read it.

It’s written by an early Microsoft programmer, with experience writing for Excel. The focus of the book is C, but the ideas are applicable to almost any language. Here are some of them.

Procedures/methods/functions should do one thing well.

They should avoid special cases.

“If you pass in a pointer as the third parameter, the function will fill in the data structure it points to. But if you pass in 0 as the third parameter, the function will allocate memory and then fill in the data structure.” This type of intricate behavior allows subtle bugs or memory leaks to sneak in.

Continue reading “Writing Solid Code”