Sunday 9 March 2014

Pair Programming

The course requires us to work in groups during lab time and we are encouraged to team up for Assignment work.  The technique of pair programming is used in professional settings and involves the programmers to alternately take on two roles: that of a driver, who inputs the code and that of a navigator, who monitors the code for errors.  The technique is beneficial in terms of efficiently writing code, the navigator spots bugs before that are buried in multiple lines of code and before they require hours of sifting through.
In a professional milieu, the pair is matched in terms of knowledge - they are able to communicate effectively about what their goals are and how they want to achieve them.  I also imagine that they work together for an extended period of time and are bale to develop a relationship and to find ways to complement each other's skills.
Pair programming in a classroom setting presents a few challenges. In a school setting, when people are starting out at different levels of knowledge, and are just starting to get used to working in pairs, group work becomes more complicated.  There are a few things one can do to make the pair programming experience easier:

- Talk to your piers.  Find out what their level of skill is and whether they are good communicators.  It is important to be able to talk to each other while completing assignments.  Find someone who is excited about the work you will be doing together.

- Pay attention to the way your partner works.  There is always something to learn and you should be able to spot their mistakes more easily if you know what to expect.  

- Do not be hesitant to share knowledge.  You will both benefit because teaching a skill to someone else (putting it in words so another will understand)  allows you ta take on a different point of view and thus to improve your own way of doing things.

- Spend time actually doing proper pair programming.  it is all too easy to divide the assignment work and go your own separate ways.  The goal, aside from learning to program, is to learn to work with other people.
  
- Become friends.    Working on assignments will not be a chore if you have fun together.

Saturday 1 March 2014

Recursion

Recursion involves iterating over smaller instances of a complex problem to provide a solution. A recursive function repeatedly calls itself in its definition in order to produce an output. As is the case of a while loop, there needs to be a base case in order to prevent the program from running infinitely.
In class, we were introduced to recursion using the example of this function:

sum_list:

return sum([sum_list(x) if isinstance(x, list) else x for x in L])

The base case in this function is the if isinstance(x, list) stipulation. It tells the program to keep running the sum_list function on itself until it gets to an element of the nested list which is not itself a list, in which case it runs the sum method.

If the sum_list function encounters a list while traversing over the given input, it calls itself until a non-list element is encountered.

While manually tracing recursion, it's good to solve the simplest case of a problem first (a simple list of two elements, for example) and to note the results in further tracing of more complex problems (like a nested list of two levels.)

Thursday 30 January 2014

The second assignment was due today and I think I did okay in the end, although I spent quite sometime figuring it out. I think that I need to approach writing code with more confidence, instead of wondering if what I think I should write is the correct thing to write. Python is quite easy and intuitive. Learning to code really is like learning to speak a foreign language. I do wish the auto-marker ran at set intervals, so that I could know that I could have feedback at a certain time. I'm looking forward to getting started on the Assignment. I have not yet looked at the code but remember from 108 that I really enjoyed reading the starter code and putting together a conceptual map of the programs. Let you know how it goes. :)

Thursday 23 January 2014

Object Oriented Programming

I am new to computer programming, am not a Computer Science student. The only other programming course I've taken is CSC108, so Python is the first and only language I am familiar with. This has its positive aspects - it seems that some of my classmates who are used to coding in other languages sometimes find it difficult to adjust to the ideosyncrasies of Python. The challenge I am facing at the moment, having to do with the switch from writing functions to using classes and methods is the dot notation. I find that for now it helps to remember that I usually get things backward (instead of object.method, I say method.object), so I should write the opposite of what I think I should write, like George Costanza: http://www.youtube.com/watch?v=cKUvKE3bQlY
Sometimes, the multitude of 'self' in writing classes is also confusing, but I think I'm starting to get used to it.