Wednesday, 22 January 2014

Week 3 of CSC148: My Experience with Object-Oriented Programming

Welcome to my courSe bLOG, appropriately referred to as a SLOG. Here, I will focus on both general and perhaps not-so-general subjects I happen to feel like writing about throughout the course of the 12 weeks that make up CSC148. As a hopeful computer science major, CSC148 is the keystone of my first year of studies for both personal and academic reasons. I'm excited to finally apply some of that Python programming I was taught in CSC108 to new areas. In many ways, the first 3 weeks of CSC148 have been quite refreshing. It seems like rather than learn complex new ideas that make our lives more difficult, the concepts we are learning are meant to make our lives easier. I only realize now how much of what we learnt in CSC108 was the long way, or in some cases, the incorrect way of doing many things. I'm looking forward to applying many of these concepts, familiarizing myself with them, and applying them in my Python programming! One thing that has helped with this so far is the lab time, where we are forced to discuss and implement these ideas. On the subject of labs, if you are looking for another perspective on CSC148 check out my lab partner Brian's blog here.

For this first post on my SLOG, the focus will be on object-oriented programming (OOP). Talking about OOP is interesting for a variety of reasons. When I've been asked to explain the positives and negatives of something, or just describe it in general, I'm used to understanding how that thing fits into the overall scheme of things. With the case of OOP, this is not the situation. OOP is the only style of programming I am familiar with, since Python, an OOP language is the only real programming language I have learnt. Based on this fact alone though, it seems like OOP is quite dominant in the field of programming languages, with Python, Java, C++, Ruby, PHP and many more very popular and widely-adopted languages falling into this category of "object-oriented". The easiest way to approach a description of OOP is to describe the concept of an "object"--the central focus of OOP. Well, an object in programming is much like an object in real life. A real-life object has attributes (known in the programming speak as data fields) and they have sometimes have a function (known as a method). Take a fork for example, it has attributes like its weight, its shape (probably the most important attribute), etc. It also has a purpose, its method, which is to aid the user eat their food. These objects, sometimes referred to as types, form the basis of an OOP language like Python, where classes are used to define an object.

Object-oriented programming seeks to lessen the semantic gap between the programmer and the user. This means it aims to reduce the number of differences between the structure of a typical users natural language and the programming language itself. This is done to serve the three main goals of OOP (from Wikipedia):

  • Increased understanding.
  • Ease of maintenance.
  • Ease of evolution.

Increased understanding of code is always important because it will serve to reduce the number of errors, and increase the efficiency and speed of the coding itself. Especially when the same code is being worked on by a large number of people. Easier maintenance follows the same logic. Ease of evolution is also a very important goal of OOP. Since code often exists out in the world for a long period of time, it has to withstand changes in technology, changes in the people that work on it, and even changes in the way the programming language itself is used. Using objects, things that are fundamentally easier to understood is the best way of maximizing all of these goals.

1 comment:

  1. oh yeah, here's my SLOG too! feel free to discuss with me :P especially after we hit that wall today on the if name == main issue
    http://my148slog.blogspot.ca/

    ReplyDelete