Matrix

Friday, 30 January 2015

Week 4: Brackets, Recursion and More Brackets

So starting this week, CSC148 mostly covered the topic of recursion. It sounds overly complicated and extremely confusing but it's not that hard to understand once given examples in class and tutorial. In essence, recursion in computer science consists of defining a function where it applies itself to the definition to solve smaller problems.

The whole idea is pretty foriegn to me since we never really talked about it in my high school CS class. So when my professor first began talking about it, I really had no idea what was going on. But she emphasized that using recursion is vital in programming. You never need recursion technically speaking but it cleans up your code and saves a ton of time.


The examples my professor used in class involved nested lists within lists. And of course going along with that meant brackets, brackets, and more brackets (even more than March Madness). She explained that nasty looking and complicated lists can be simplified and rather than taking using a loop to count the elements, simply use recursion. This began to make more sense to me. Who wants to trek through millions of brackets using a loop?

The other thing she emphasized was tracing the recursion within your code. This not only helps you find mistakes but also understand it better since everything becomes simplified when you are using recursion. This was also the focus of the lab in the tutorial this week which involved tracing functions with recursion.

This week's lectures and tutorials were particulary interesting in showing a method of creating functions that make quick work of complicated and nested inputs. Hard to grasp at first, recursion is actually relatively simple once you understand the core concept of what it does and it will make programming a lot easier.

Monday, 19 January 2015

Why Do Geeks Need To Know How To Write?

This is a simple question yet requires provocative discussion. When do geeks ever need to know how to write? Ask any programmer about their abilities to write. Almost every time, the answer is "I only write in code," "Writing is for English class in high school", or simply "ew." Programmers just don't like the idea of writing or simply associate writing with their high school English class. But writing for programmers goes beyond that. It is an important way to document things, help you fix errors, and most importantly, understand the code you wrote.

A lot of programmers really hate writing in English class.


So why do geeks need to know how to write? Or why is it so vital to programming?

Well first off ask yourself this, how many times have you miraculously solved code? Not with some weird voodoo Harry Potter magic mind you but just randomly moved some code around or just did trial and error until you fixed it? Granted, it is great you fixed the issue but that doesn't mean you actually understand what was going on. Documenting your bug fixes by writing it in pseudo code or even plain English will ensure you don't waste 3 days trying to fix it again.




Keeping a "debug journal" or even a random document on Word can be time-saving and crucial for programmers. It allows you to visualize in a different manner than just hard code and also gives you opportunity to ask for help or see your own blind spots.

Debug. Debug. Debug. Do it by keeping a debug journal.

Along the way, this experience in programming will also help you develop communication skills. And communication is vital in any form of Computer Science. At the end of the day, employers don't hire you based on how many programs you write or how many languages you know or how attractive you are (actually maybe that one helps). It's about whether you can communicate your code effectively. Your documentation has to be understood by everyone else you're working with and you need to talk about your ideas well enough to convince them to agree. Regardless of how amazing your code is on GitHub or SourceForge, if people can't understand exactly what is going through your mind, then the code is essentially useless to anyone but you and that's the opposite of what you're going for anyways. Keep a journal or even just write down your errors before you attempt to solve them. As you write more and more, it'll become easier and easier to the point where it is second nature. Don't disregard writing cause it was boring in high school (it really was. seriously why shakespeare?) and teach yourself how to document everything by writing.

Always write and document your code. Have fun!



Matrix