IF you can read…you will read this.

Once upon a time, I got scared of real life and tempted by the promise of a high-paying job in the programming field.  I slogged through the rest of the year at my teaching position that was essentially a living hell (if hell had great coworkers), and I shipped out to California for an “apprenticeship.”  I’m basically at a free coding boot-camp for one.  My “master” is teaching me out of the goodness of her heart, and the promise that One Day I will be good enough pay her back by conributing to her work. We’ll see.

I had intended to start my documentation of my coding journey from the very first day I arrived in sunny—errr—extremely snowy California.  I would end up in the part of Cali where it blizzards.  Anyway, I got very distracted by the scenery and all the other things that we’ll just put under the umbrella term of  “procrastination.”  So now I’m about two months in, but don’t worry, I’m still coding like I’m on day one.  Pretty much.

Today, I’m trying to program a game of chess. I’ve written about 350 lines of code, but I suspect at least 150 of them are unnecessary.Essentially, how I code is I use “if, elif, else” until the cows come home.  For those of you who don’t know, “if” statements are essential to programming…but they are not essential to use on everything.  Eventually, you’re supposed to get better at figuring out more efficient ways to say what I say in hundreds of lines.  Since this is not a site for programmers (exclusively), let’s give a real world example so you know what the heck I’m talking about:

Suppose you’re trying to get to your friend’s house across town.  You need to be there in an hour.  It will take you exactly that amount of time to walk there.  The bus that goes there unfortunately runs every 1.5 hours, so unless it’s already at the bus stop once you get there, you need to walk.

Your program would look like this:

IF you get to the bus stop and the bus is there:

take it!!

ELSE (there is no bus):

walk!!

that’s not so bad.  But suppose you don’t know how to walk there.  You would have to give directions in a very tedious way.

Note: to follow this, note the colors I’ve used.  Try the first RED statement.  If it does not apply, skip what’s not red and go to the next red statement.  If that doesn’t apply to you either, go to the next red statement.  At any time if the red statement, DOES apply, follow the non-red stuff underneath.  Do the same thing for the blue statements.

IF you are not at an intersection and not at a dead end:

keep walking on the same street!

ELIF (else if) you are at an intersection:

check the street sign!

IF the street sign says “Oak St”

turn right!

ELSE (if it is not Oak St).

keep walking!

ELSE (you are at a dead end):

turn around!!

 

And so on and so forth until you eventually get there.   This is how I code.  How good programmers code:

bring a GPS and follow what it says.

I feel like I’ll never get to that point. My teacher says I’m learning quickly, and that I’m totally better than average. I suspect that’s just to keep my ego happy,  given that she just basically told me to restructure my entire chunk of code.

 

Advertisements

4 thoughts on “IF you can read…you will read this.

  1. 2mostrareaffections says:

    I’m interested to hear your perspectives on learning computer programming! It’s something that has interested me in the past (right now I’m trying to teach myself HTML, for starters). I like how you de-mystified the basics with the bus stop metaphor.

    1. seasaltandvinegar says:

      The great thing about programming is that it is very possible to teach yourself the basics (have you tried Coursera.org? It’s the best)! I’m still using Python, so my “graphics” are going to be a little wonky for a while, but I’ve heard that HTML is great. Even if you can’t dedicate full time to learning (let’s face it, who can?), you’ll still master quite a bit…says one newbie to another!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s