When talking about programming, terms and definitions can get quickly overwhelming, especially if you're a first year student studying at UofT. I've always heard people discussing these topics that even today, still scramble my head. Just hearing the words subclass, module, or encapsulation, are enough to make me nod my head, and pretend everything is fine as the lecture continues.
After much fiddling with simple loops, functions, and if-statements the previous semester, I wonder, what's the ultimate objective of programming? For money? For problem-solving leisure?
|
[Let this creepy stock image represent my
dismay during the CSC 108 assignments] |
Well it turns out there's a greater truth that lies beneath all of the books and online slides. It's called Object-Oriented Programming. In the simplest terms, its a way to manipulate organized information. A slightly more rigorous definition would be a type of programming that allows organized information to be perceived as an object. An object can contain attributes (descriptions of the object), it can carry out procedures (instructions for a task), and it can also establish connections with other objects (sharing attributes and procedures).
A bare example of an object in Python looks like:
|
[A simple class in Python] |
And I thought, wow neat! Actually I didn't, I lied and I don't think anyone else would have said the former. If they did, kudos to them for having the motivation. When I'd first seen a class in Python, it sort of just brushed by and I never gave it much thought. But as the lectures started to reveal more and more of what they were capable of, it got me thinking--we call it an object, although it's something we can't hold in our hand. It is purely conceptual, intangible. It's similar to when we say, a hydrogen atom, yet you'd never think of holding a hydrogen atom in the palm of your hand. But it too, is an object, much like anything else in the world.
Actually, the idea of object-oriented programming is applicable to the the entire universe.
If we view the universe as a very-very large program, the idea of object-oriented programming applies. A quark, an elementary particle, can be an object and inherit from a hadron, another object that inherits from say, a proton, also an object which inherits from an atom, then to a molecule, and so on until it eventually reaches you, a person an object, then to a planet, and to a galaxy and it goes on, all inheriting from the few fundamental superclasses, chemistry, physics, and biology.
However, the universe is much more complex than the internet browsers we run on our computers.
While it's cool to think about, the question still stands, what is the point of object-oriented programming? Sure it can be about the money if that's what you're aiming for, or would it be more convenient and efficient to use when trying to solve a problem, but I like to think of it simply as another dimension in programming. Whereas procedural programming is sort of like a 2D plane, object-oriented programming is 3D, it opens our minds to completely new directions. It can be utilized whether you want to make business apps for clients, or design a gaming engine, or a mine a few bitcoins, the ultimate goal of OOP is to allow of these things, and help technology advance to a future with endless possibilities.