Any smart person can code: How to go from a manual task, to an automated program

My goal in this post is to give to any programmer who has a friend that wants to learn to code, or any person who wants to teach themselves to code, the proper tools/perspective to take the first step.

In my opinion, every smart person has the ability to code. It's just a matter of doing 2 things: learning what kind of things are possible with code and then learn the syntax to execute those things. That being said, that can still be a tremendous hurdle. Though overcoming the syntactical barrier is probably easiest, because it has become a simple matter of Googling something like:

How to split a string in python

Or basically how do I do x task in y language.

The bigger challenge is figuring out what x task needs to be if you're unfamiliar with programming and don't know what it can do. Now my proposition is that the challenge is not as big as it seems, and there is a simple way to over come it. All you have to do is tell the person to be so overly consious of the actions they take when completing a task, that they would be able to write down each step, give it to 1000 idiots, and have said idiots complete the task with a 100% success rate.

Tell them to dig deep and remember what every good science teacher they hard harked on: create a flawless and fool-proof procedure for your experiment (or task rather). Being able to do this, helps you overcome that first barrier of figuring out what procedures code can do and that you can Google the syntax for.

Let me show you an example. Let's figure out how we would do this for a task that's trivial for experienced programmers, but not-so-trivial for a beginner. 

Task: given a text file with student scores, figure out the final letter grade each student deserves.

Here's the text file:

Now let's just think out loud, not as programmers, but as humans. How would we do this? We know already that we need to first open the file, figure out which scores belong to which kid, add those scores up, find the average, then based off that average assign the kid a letter grade.

Now we can break this down even further.

  1. Open a text file called student_scores.txt

  2. Read the first line of text for the first kid

  3. Figure out the name of the first kid is Joe

  4. Add every test score of Joe's up, and divide it by the total number of test scores

  5. Take that number and assign it a letter grade

  6. Repeat steps 3 - 5 for Kim, Alex, and Sam.

And to break it down further so that it comes closer and closer to pseudo-code and something Google-able, you have to keep asking "How do you do step x" until you can't be any more specific. For instance I'd ask for step 3: how do you know the kid in the line is Joe? For step 4: How do you know what in that line is a test score? For step 5: How do you know what letter grade to assign it? For step 6: How do you repeat it for the three other kids?

The answers will get you a more broken down procedure like this:

  1. Open a text file called student_scores.txt

  2. Read the first line of text for the first kid

  3. Take the word that comes before the ":" (colon) character and that is the name of the first kid.

  4 a. Take the sum of all the numbers separated by commas

  4 b. Divide that sum by the total numbers separated by commas

  5 a. If that average score is greater than or equal to 90, assign the person an "A"

  5 b. Otherwise, if the score is greater than or equal to 80, assign the person a "B"

  5 c. Otherwise ...etc...

  6 a. Skip the next line in the text file.

  6 b. Starting with the line after that, repeat steps 3 through 5.

  7. Repeat step 6 until there are no more lines in the text file.

Now it just takes a little more guidance and a little more asking "how" to turn all that into perfectly good pseudo-code that a noob can go Google and find that syntax for the language they want to use.

And since every smart person is going to be able to write a good scientific procedure, every smart person is going to be able to get the hang of thinking through tasks like a coder, which means every smart person is going to be able to write pseudo-code. And since they are smart, they will also be able to figure out how to Google that to figure out exactly how to do it in their language :). There, problem solved. Now go help all your friends become programmers!