Sunday, 26 January 2014

From OOT to OOP

         First, a bit of history: my very first foray into programming took place in 9th grade tech, a course where we spent half a semester in the computer lab learning how to type and manipulate spreadsheets, and the other half in a workshop building pop bottle rockets and other fun toys. Near the end of the computer-focused portion of the course, my teacher introduced us to OOT. We used it exclusively to draw pictures, by inputting coordinates to serve as the endpoints, verticies or centres of lines, rectangles and circles of various colours. The final assignment was to draw a house with a tree, under the sun. Being a chronic overachiever, I made my picture terrifically complicated. My house had curtains and a chimney with smoke coming out of it; my tree had several branches and many leaves (as opposed to the ball-on-a-stick models of my classmates).
        In order to create thIs great work of art, I had to draw squares on top of squares and circles on top of circles and carefully plan the layering, so as not to create the impression the picture had been drawn by a small child. 
     If someone had wanted to recreate that picture, they would have had to draw the same endless series of circles and squares. However, with my new python knowledge, I could create a class house, with methods to create doors and windows or a class tree, with methods to create branches and leaves. But that's not all! With python you can create a class and methods for just about anything under the sun, because, to quote my instructor, "just about everything is an object in python". 
     Python, and other object oriented languages, allow you to create objects that correspond to real world objects and concepts. The objects can contain both data and functionality-- they are a compound data type. Objects can then interact with themselves or each other by way of  funtions-- in a previous exercise for this class, we created "dog" and "toy" objects, which were able to interact with each other via a "play" function.
     The multifunctionality of the objects (which are an example of abstract data types) allows users to create bigger, more complex software systems with ease. For this reason, object-oriented languages became to dominant programming paradigm in the 1980s.  Later in this class, we will be writing classes and functions for a more sophisticated toy-- a ."cheesy" version of the Towers of Hanoi logic puzzle-- check back soon for updates!

No comments:

Post a Comment