My Programming Autobiography, Part 5
Perhaps I should explain why I was so in love with C++. Well, it was just so good to be around it. It made me feel good. The world made sense in its presence.
To be honest, what I was really in love with was something called Object-Oriented Programming (OOP). If you read A Nerd Is Born, you will maybe remember something called Structured Programming.
Structured Programming was a way of writing computer code that tried to keep things encapsulated in subroutines that had a top and a bottom. Unstructured programming is code that bounces around in one big program, something that could be described to be like a plate of spaghetti. You can’t just look at it and know where one strand begins and ends. Debugging an unstructured program was like that.
The early versions of BASIC that I used left you with little choice. You could come close to doing structured programming, but it still looked a lot like spaghetti. The same was true of some of the other languages I learned, like COBOL, RPG II, and especially assembly languages.
With structured programming, you could put some of the processes into subroutines and force each one to have an entrance and an exit, with no other way to do that same process. It made it more efficient and easier to read, and therefore, debug. This was good. The world had a semblance of order.
Unfortunately, it also had its limitations. You see, a subroutine will try to operate on anything the programmer sends to it. Some things cause a glaring error. Some things go wrong and you never know they did. Very mysterious!
Programming languages that are not object-oriented have a fairly basic set of data types: integers, floating point decimal, strings of text, and arrays of each. It helped a programmer keep things straight, because if you tried to mismatch them, the errors were obvious. The problem was, they were limited. Most “things” in the universe are more than numbers and text.
OOP was a way for me to define my own data types in unlimited combinations. Sure, you can add 1+1 in other languages, but can you add a ball to a table? In other languages, you can say that there is one more ball, but it is just a number that grows or shrinks depending on the count you are keeping.
With OOP, I could define a data type of called a ball and then define the various attributes that balls have, such as diameter, hardness, surface type, color(s), the type of sport that uses it, solidity, or how it feels when it hits you in the head.
Not only could I name the various attributes of a ball, but I could also name the various functions it could perform or could be performed on it. These actions could be assigned only to objects of the type “ball” and make it so that I, as a programmer, couldn’t go around bouncing bricks in my programs.
You non-programmer people won’t really understand why I’m bouncing balls and not bouncing bricks in a computer program. Bear with me, though. You still don’t know why was in love. Here it comes.
I was in love because of the romantic language of it all. Terms like instantiation, inheritance, objects, classes, abstraction, encapsulation, and above all, polymorphism, tantalized my imagination and made me seem like one smart dude! Love, for some reason, is supposed to make me look good, right?
To be continued The Pebble, From My Hand Take, Grasshopper.