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