Thursday 20 February 2014

Some Blogging going on

Because Assignment 1 was such a pain to do, and because I submitted the file at 9:59 pm the day it was due, I decided I would start studying for the midterm early and that way I won't be surprised and I will have mastered the class's content by the day of the exam.
So the first thing I'm doing is re-reading the recommended lectures the prof posts weekly, its long but I only read what I don't know by hard. So far, I've learned a lot about the style guide, somethings I knew, some others I didn't (and I think I might have lost marks for those things in the assignment) and I've come to the conclusion that the style guide was developed in a way that actually makes code way easier to read in the long run. Yes, it is annoying at first to read all this paragraphs on variables and underscores, but when you're coding and you know the rules, you save a lot of time since you don't have to check the PEP guide every 5 mins. Also, it looks like you know what you're doing when you are sitting there with Python open. 

On a different note, I also read about unittest, and all that comes with it and it helps soooo much. Now everything I understand everything I've been doing at the labs. I now know why setUp and tearDown are important and I also understand the unitttest universe and its hierarchy. So the way it works is basically unittest is what they call a "testing framework" so its basically where everything is going to come from. All the tests and everything related to this particular way of testing will be part of unittest. Then, it comes the TestCase, a "subclass" of unittest that helps you create the tests that unittest should carry out. To create these tests you create a subclass of unittest.TestCase that will have the tests you want to carry out. Since you are creating a class, the class has the following methods by inheritance:
setUp, which basically sets up the scenery for the desired test to be carried out. It is called before the test is called.
tearDown, which is called right after the test is called, cleans up all the test did to the scenery in order to leave it ready for the next one. 
Then there's the run method, which runs the tests obviously, but doesnt need to be called, it is executed just by calling the desired instance of the class.
SkipTest, skips the test said, and marks it as skipped in the final result rather than as failed.
Debug, runs the test without collecting the result, it is very useful when debugging code.
And finally there is plenty of assert methods, each of them tries to prove something different, they can and should all be used when creating the test cases.

Anyways, I'll keep reading and will keep you guys posted on everything else I find interesting here!

Natalia

Wednesday 29 January 2014

Week 4

I have been reading for a while now, I find it very useful to read about Python and programming, so its been useful. However, Im still trying to get my head around the fact that recursion is acceptable. From the linguistics point of view it is so wrong to define something by using the term you're trying to define! What helps me though, is trying to see it from the mathematical point of view. Its sort of similar to induction.... At least its the same idea that if it worked with the previous case it should work with this one, or I don't know... Thats how I think about it

Now, regarding the lab, this week.....

Loved the Motorized exercise!! It was a lot of fun creating that but HATED the Testing part! I didn't even now what tests to create! I'm not good at that testing stuff.... Anyways if someone has any suggestions on how to get better at testing and more familiar with them I am taking anything that might come in handy! Please comment your suggestions :)

PS: I was worried this class would be less interactive that 108, but it turns out I feel like now we're getting our hands more dirty and actually programming more, as oppose to being told what to do... Its probably because we have way more tools now!


See you guys next time

Monday 20 January 2014

A little on OOP

After reading How to Think Like a Computer Scientist I actually understood a little more about the so-called "Object Oriented Programming" (OOP). 
The things that seemed relevant about what I read are the following:
- OOP is commonly used because of its relation to real life. For us humans it is easier to have methods of classes of objects than just functions that are not part of anything and that are just lying around waiting to be applied on a certain other object where it becomes useful. 
Because of my lack of creativity now, I will copy the example that helped me understand this idea better, (it comes from the link I copied above). 
 "In real life our cook method is part of our microwave oven — we don’t have a cook function sitting in the corner of the kitchen, into which we pass the microwave!"

- The second thing I found useful in this link was the explanation of Methods, Classes and Objects. I feel like the article helps create a mental map of what goes on in Python, and since we already had some familiarity with all of this vocabulary, it is easy to figure out the reason to use the methods suggested over others that might cross our mind. 
    
    The best example of this, is using methods instead of functions. When you create a class you will be able to create objects with very similar characteristics and by creating methods in the class you can implement functions on the objects of the class and avoid creating variables (that you would have to create if you used a simple function that wasn't related to the class.

-The rest of the reading was also interesting but a little repetitive considering what we knew from CSC 108. 

Saturday 18 January 2014

Useful Links

When it comes to writing code, the internet is my favourite side-kick. I've posted the links I use the most when I need help, so far they are a little mainstream and probably all of you guys use them but I will try to add up some more later on!


Help With Python (Table Of Contents)

Python Visualizer

Pics That Make Me Smile



Introduction

Dear TA's, fellow students, and people who ended up here by accident because they typed the worn URL:

Before coming to U of T, I had no idea of what computer science was all about, much less Python or any type of programming. However, coming here I realized I had to take CSC courses, and as a huge surprise for me, I enjoyed them. 
Last semester I took CSC 108, which introduced me into a world of strings, classes, methods and more. Now, 6 months after downloading Python for the first time and starting my CSC 148 class, I have a few things to say:
  • First of all, computer science rocks! The satisfaction of writing your own code and fixing it until it's error-free (and doing what you actually want it to), its tremendous!!! It is like creating your own virtual little piece of world, and I encourage everyone to try it at some point.
  • Second, since most of the readers of this blog have already tried programming, (or at least that's what I would expect from my classmates), is that I have found that writing code can be tricky! Thinking about the best way to organize the steps your code should follow to make your code efficient and simple at the same time, can take a while, and that when it comes to readability, the best test to do is to write it, leave it for some time and then come back and reader as if you were an outsider. If you understand it the first time you read it and you don't think it has more steps than it should, then you're on the right track, if you notice something that could be change, think about a way to do it and experiment with it.
  • Third, getting into more details, class are specially tricky! I have found them one of the most tedious things in programming (probably because it is the newest method and the most broad one so far). Every time I'm creating a class I have to think about what the appropriate way to define the methods is, and even about simple indentation protocols and docstring rules. Hopefully this will get easier as the course moves on and as I do more and more exercises, but so far this is what has been going on.
  • Fourth, talking more about the class structure and less about Python, I am scared. I am scared that the 10 am lecture will get so full that no more people will fit in it and there won't be a seat for me. As a MAT 137 student, I have class Mondays, Wednesdays and Fridays from 9-10 which means that I can't get early to the 10 am CSC 148 lecture and that I depend entirely on God to get a seat everyday in the lecture. Hopefully people will realize that going to the 9 am lecture is also good or they will come to love the Wednesday afternoon prof (which I don't know but have heard, its not the most organized).

Anyways, I tend to drift away from the subject a lot and I fear that if I keep on writing this blog will stop being about CSC 148 and become my personal diary, so I feel this is enough for an introduction. Take care guys, see you next time.