Thursday, 5 February 2015

W5: Re-re-re-re-cursion recap

    Clever functions they are, recursive functions. Really, it's inception, I think my first understanding still holds true, "code-ception". As I mentioned in last week's post, our "introduction" to recursion; this week was more of a hands-on experience. Tracing them in last weeks lab, as well as the in class exercises was good practice. I think, once you figure out the "pattern" or "trick", the rest is easy to see.

    Since our first term test was this week, working on my aid sheet also helped prepare me to be capable of writing code on paper. The night before the test, my fellow classmate and friend, Tim, and I were discussing as well as taking turns quizzing each other with content we predicted would be covered on the test. One thing I learned from him, because I didn't exactly trace the recursive question he asked me correctly, is to TEST until the pattern is discovered. Which actually makes pretty good sense, if you don't know what it does, throw something in and see what it spits out. I don't get everything like this *snaps fingers*, like some (most) of my cs friends but I try my best to figure it out and learn.
Still, there are times when this happens:
But practice, practice, and more practice! :)

    As for this week, we had one lecture on Monday, the test was Wednesday (which I thought was okay), and I just had my lab this morning. Today's lab, we focused on the A(bstract) D(ata) T(ypes)'s, stacks and queues. We worked first with Stacks, understanding their attributes and writing code to implement use of them, then we did a similar exercise with queues. The slight difference between Stacks and Queues lays in their LIFO and FIFO difference. Elements of Stacks follow the rule, "last in, first out", while Queues follow the, "first in, first out" rule (much like a lineup at Starbucks- first in line, gets their "java" first). In the lab I was also familiarized with the if __name__ == "__main__": block. Still, I always have my questions about programming :P
    

Sunday, 1 February 2015

W4: If at First You Don't Succeed, You Must be a Programmer.

    Well, that sure went by pretty quickly. On January 9, 2015, I remember thinking, "why. is. this. first. week. taking. so. long.", but I seem to have just skipped through the second and third week. I attended one of the ramp-up sessions  because I felt a refresher would be of benefit, even though I just took csc108 last semester.


This picture accurately describes how I feel about computer science at times.  
The first weeks started with some confusion but I think I'm starting to get right into things. The biggest adjustment, I think, from csc108, is the change in lecture style. 

    Csc108 was run as an inverted class- which I enjoyed and found very helpful. 
(1) we had in class work-sheets, the opportunity to see if we understood the material and was capable of implementing it ourselves; and if not, ask the prof or the TA's!
(2) the amount of questions asked was also significantly higher (in my opinion), I find sometimes in lecture, people are too shy, or don't necessarily get the opportunity to ask question(s). Maybe several which are common among students. 
(3) sometimes, in lecture, I see the example and I think, "yeah, I could've come up with that", when in reality, it probably would've taken much effort but because I saw it, instead of trying it myself, I thought I could.

  As I adjust to the lecture style of csc148, I realize that the weekly labs have definitely been of help to me because I have the chance to apply what we've learned about in lecture, in practice. The labs are also more specific, focusing on one aspect at a time with a TA available to look at your work and answer questions or explain certain things. This also allows for me to figure out what I am uncomfortable with or uncertain about and ask for help with.

Recap: 
_______________________________________________________________________

As for week four, I didn't know why my friends were so excited, but now I see.

def. Recursive loop: See "recursive loop". 

    To be honest, I had never done programming before I decided to study it in university. In the summer, before I came to Toronto, my very talented friend Paul, who self taught and self learned programming taught me some programming- or attempted to, is probably the better phrase. I worked with Java for maybe a period of three weeks with him as my instructor. We'd meet once a week for a lesson and then he'd give me an assignment to complete for the next class. I must say I did learn a great deal of things from him, but I didn't understand everything as a whole at the time; it all started being pieced together and making sense in 108. We didn't really start with the basic foundation, but rather, the basic concepts, and one of the concepts he taught, was recursion. 

    My general understanding of recursion at the time was, "so it's like code-ception..." This understanding, is somewhat correct, but there's definitely more to it. I've taken a look back at the assignment I had to do in Java over in the summer, which was to make a recursive method that will return based on a given index, the corresponding term of the Fibonacci sequence. For those of you that don't know, the Fibonacci sequence is formed by adding two numbers before the current term together (first two numbers of the sequence are 0 and 1); looking back now, I have a better understanding. In lectures, as well as this week's lab we've been practicing tracing recursive functions of different depths as well as writing our own simple little recursive function. Tracing, I think, helps to understand it. 

People often joke, that in order to understand recursion, 
you must first understand recursion.

Friday, 23 January 2015

W3: Why Geeks Write

    Why geeks write? Believe it or not, it can prove to be beneficial.

    Keeping a debugging log helps keep your work organized. A bug could actually take more than just a couple of days to find and solve, it could take weeks or even months. And if it does, how will you remember exactly what you've attempted and the results of those attempts? Maybe you almost solved it and all that was needed was some slight tweaking, but let's say you've already spent a long time getting to where you are now, and you feel tired and just want to sleep on it. Maybe the next morning, with a clear head, you could retrace your steps and it'd be fixed- but what if you didn't keep track of it and it as a few lines here, a few lines there, and now you can't remember exactly where you left off. Or, maybe you attempted something earlier, and it fixed some part of it, and now you've found the solution to fixing the rest of it, but uh oh, now you can't remember what you tried before.
 
    Maybe you think you've tried everything and you decide to ask a someone else for a little input, it will be good to share what you've tried and maybe they can take something you've tried and change it a little to make it work, but it will also give them a general guide as to what has been attempted so they can come up with new solutions. Or, perhaps you've been at this for so long, you're beginning to feel a little numb and you've read lines over and over so many times you're not really reading it anymore, and instead, you're brain is just "reading" it to you, you may read it as something but once someone else reads it, they immediately pick up on an error or even small detail that could be the first step in solving the problem. Or if you encounter a problem similar to something you've already solved, and you documented your method in correcting that problem, then maybe you can refer back to that and use a similar approach. Sometimes it could even be a bug where you don't even know where to begin. You just stare at it and think.... well... uh... so... hm..... Maybe you need to brainstorm HOW to debug this bug.
 
    Personally, I always like to write ideas down, just in plain English, and expand/add detail later on; whether it be starting an assignment (the panic has set in as I count down the days till Assignment #1 is due while I blunder around in my small amount of code and read and re-read through the handout) or fixing a problem. In my experience, even writing code for csc108, when something didn't work and I wanted to change the code a little, I always copy and pasted onto a new page just in case it turned out worse or if I wanted to revert to my original code or compare my original code with what I had at the moment. That is what I did before I decided to ask my friends and fellow peers for insight, before asking on Piazza, before going to office hours, asking TA's, going to the help centre etc.
Whatever the case may be, it's good to keep track of your work for future reference. It could end up saving you lots of time.

    It's one thing to know how to write code, but it's another to know how to explain it. Whether it be working with a group on a project, or working for a client, it is important to be capable of communicating ideas verbally, or in written form, not just in programming languages. I fully agree with Carlos' explanation, http://theimportanceofbeingpython.blogspot.ca/, as how writing improves us in two dimensions. He gives a detailed explanation in both our outer and inner dimensions which I found intriguing to read.

Now, enough writing, time for a Java break :)

Saturday, 17 January 2015

W2: Getting Started

     I enjoyed and learned lots from csc108 last semester! The only thing I feel less confident about is "class". I understand we use class to contain several functions that may be used together in case we have a lot of separate functions which may be difficult to keep track of. Class still somewhat confuses me, and I am slightly unfamiliar with writing a class. I have been attempting to clarify my confusion about classes by asking my prof, asking my peers, googling, and referring to notes from csc108 as well as textbooks available to me. As for the design, I am slowly learning, it helps me to identify the main noun (which is a candidate name), verbs and important attributes, as well as operations that should support the noun. In class we have also used the special methods, __str__, __repr__, and __eq__ which I hope will become more familiar to me with more practice.

     Our first assignment has been assigned, and the first time I read through the handout I felt very overwhelmed. Then, I decided to break it down and read it section by section; even after doing that, I was still perplexed in what to do and how to start. I kept reading it over, not necessarily from the start to the end, but chunks by chunks. I did some highlighting of hints and more specific instructions which I thought would help me get started. I slept on it, and then I did more brainstorming, ideas started forming and connecting and making sense! I don't know if all these ideas will work and I don't have ideas for all of the assignment but at least I have something.

     We also had our first lab this week, which really helped with my familiarization of a class. For the majority, I was on the right track. I think these labs will prove beneficial and worthwhile as it allows me to practice with a TA available for questions or errors I may have. This also allows for discussion or exchanges with fellow students working on the same or similar task and is sometimes less intimidating than asking TA's or profs.

Thursday, 8 January 2015

W1: Fresh Start

    It's again, the start of a new beginning for most of us. I, for one, have definitely been awakened by the chill of the weather. I am determined to make yet again, the best of the upcoming semester. True, this semester's courses do seem heavier and harder, but that just means more opportunities to improve, expand, and experience! To be honest, I'm interested in 148 and at the same time nervous. The first few lectures have not been too intimidating- so that's a relief.

    So far, this week, I have learned: the general definition of "recursion", "clever functions that call themselves", the general structure in designing a new class, and a refresher about object-oriented programming and special methods in python.