Thursday, 29 January 2015

Week 4

This week we focused on recursion. A function is recursive if it calls itself. Recursion is an essential tool for computer scientists because it is necessary for some problems and is provides a solution that is concise and elegant compared to iterative solutions which may be long, complex and inelegant. We also practiced tracing recursive code. To better understand recursion and how it works, it's useful to trace the function with examples of a call with the smallest possible input, with the next largest possible input and then continuing to problems of any larger size for more confidence.
Also this week, on the 29th of January, our first assignment was due. I worked on it with Tal and Adam. We had some issues figuring out how to use __repr__ and __str__ in our function. I asked in my tutorial and I received a good answer that's cleared up my understanding. __repr__ are similar in many ways which make it quite confusing. They both return strings but __repr__ returns what you chose to return as the representation and __str__ returns a string that normally gives a kind of "english" summary of what's going on.

Friday, 23 January 2015

Why Geeks Should Write

The Three Virtues according to Larry Wall ( who the original author of Perl programming language,) are laziness, impatience and hubris. In order to fulfill these virtues we must be efficient, and what better way to be efficient than to make sure we don't make the same mistakes. One way to do so is to keep a debugging journal. A debugging journal is just a way of recording the process you used to fix a bug you encountered. By doing so, you can be sure that the next time you come across that bug you will know how till deal with it. Also, by documenting the bug and how you fixed it will allow you to have a better understanding.  Another way to be efficient and a great programmer is being good at communicating ideas. Clear comments, technical specs, etc.. allow other programmers to better understand your code. That also means that other programmers can us and work with your code instead of rewriting it. So for a group project, that is very important. Also for yourself, it makes it easier to go back or find what you need within your code. So I definitely think geeks should write.

Saturday, 17 January 2015

Week 2



Last semester I took CSC108 so this week has mainly been a review. Our main topic of discussion was stacks and introduction to programming (such as how to think like a programmer).

A stack is a common ADT (abstract data type). It is a data structure that contains multiple elements, otherwise known as a collection.

An ADT is defined by the operations that can be performed on it, which is called an interface. The interface for a stack consists of these operations:
__init__
Initialize a new empty stack.
push
Add a new item to the stack.
pop
Remove and return an item from the stack. The item that is returned is always the last one that was added.
is_empty
Check whether the stack is empty.
An implementation is a set of methods that satisfy the syntactic and semantic requirements of an interface.
Our first lab was also this week. The work in our lab focused on designing and implementing classes as well as applying the proper recipe for designing functions. Unfortunately markus wasn't working so my partner and I weren't able to submit our work.