Learning

I’m a slow learner.  By that I mean it can take me a while to put all the pieces together so I can see the whole picture.  If I was a detective, I’d be the plodding kind that takes ages to interrogate every witness, look at every piece of evidence, and use one of those huge pin boards to visually represent the case.  I wouldn’t have a Eureka! moment part way through when I could suddenly see whodunnit and spend just a few seconds demonstrating how everything that remained fitted together.

I’ve just spent the best part of three months teaching myself to write code so that I can copy blog posts from over 800 bloggers, together with the date the blog was posted and the title.  Actually, in the end I’ve written code that will do that for most of the blogs in my list, for reasons I’ll explain in the next post.

Writing computer code to do a variety of somethings, and do them in the right order, is hard.  I’ve been using Python, which is pretty straightforward and relatively easy to read if you’ve never seen code before.  While lots of things still happen ‘under the bonnet’ so to speak, the commands that make those things happen are pretty transparent.  It does exactly what you tell it to do, and executes your commands in a precise and logical order.  This is how it works:

(1 + 2) + (3 x 4) = ?

3 + 12 = 15

It will do the calculations in the brackets first before moving on to the second stage, where it adds the totals from the bracketed calculations together.

A similar instruction in Python would be:

if len(blogPostTitle) > len(blogPostDate):
blogPostTitle.pop()

So, if the length of the list ‘blogPostTitle’ is greater than the length of the list ‘blogPostDate’, remove the last item in the blogPostTitleList.  The second line is indented so that Python knows it must execute this line of code before it moves on to the next.  My code goes through a sequence of instructions, not all of which have to be carried out if certain conditions aren’t met, and it must execute this code several times before it can move on to repeat the process – in my case, on every item in a list – before it ends.

Typing it out like that makes it sound extremely simple, but the form of words, and the sequential structure of those words, have kept me occupied for weeks.  I’ve no doubt someone with a better grasp of maths than I have would grasp the logical structure behind it, and learn the language, much faster than I.  In fact, a long piece of code that does a specific thing can be labelled as a ‘function’ and given a name, and called on to do its work using just the name, saving you from copying and pasting all the code again (and having to make numerous corrections if it needs amending).

During the course of this project, I’ve written a bit of code.  Searched on Google for how to write the next bit of code.  Read bits from books on programming.  Searched again.  Written a bit.  Got one little thing working (like putting all the URLs in a list Python can read).  Written the next bit of code.  Or rather, tried, and repeated the process above several times over.  And believe me, reading coding solutions online, when you’re a coding novice, is less than helpful.  Just knowing what key words to put into your search is a major leap forward.  Finally, I ended up drawing diagrams of what I needed my code to do, printing it out and cutting it up with scissors so I could visualise the sequence of events and the result if I changed anything around, and then I went back to that last piece of working code I put together and I could see the final thing I needed to do to make it work.

I strongly suspected that getting to grips with code would improve my maths skills, and I was right.  It really made me think about the sequence of events as much as the language used to describe them, and of course if you want to be any kind of an engineer, you have to understand the rules of logic.  I feel as if I’ve really actually learned something properly, and that was one of my main goals in doing this PhD.  I’ve levelled up.

code

My personal blood, sweat and time, but no tears.

Advertisements

2 thoughts on “Learning

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