Object-Oriented Programming (You either GET IT or YOU DON’T) Part 2
This is the second post in a series of three that I am writing about the basics and understanding of Object Oriented programming and thinking.
Thinking like an Object-Oriented Programmer
Now you are starting to think like a programmer, this is a good thing especially if you ARE a programmer. So the main problem with just “Getting” OO design is that most people overcomplicate everything about it. When I was first learning to program I was terrified of this whole OO thing. It seemed like everyone on the internet was talking about it and it was way over my head. Boy was I wrong! The problem and the source of fear was that nobody ever made sure that I understood all the OO concepts. This resulted in my stumbling across the concepts a little at a time and finally one day I got the last piece of the puzzle and the light bulb came on and I just “Got It”
Hopefully you will not have to put all of these pieces together a little at a time. I am going to try and give you all of the pieces in a simple manner so that the light can come on for you as well. To start with let’s take everything you have ever heard about OO design and programming and throw them away. Objects are not hard, complicated or scary they are GOOD! In an OO language like Java or C# everything is an object. This may seem like a very awkward statement for a beginning programmer because you may think of everything in terms of simple data types such as (int, string, float, etc…) Don’t be confused though, even with OO design we still need these simple data types.
The best way that I can describe thinking like an object-oriented programmer is to think about everything in terms of objects. This is a little contradictory from what I said above, but this is a natural progression. Truly thinking about everything in terms of objects is not hard. Let’s take the items in a classroom as an example. Looking around the classroom there are some tables, chairs, computers, a blackboard, a projector and screen, etc… So think about it this way, if we were going to program a virtual classroom how do we define our objects? This is so simple it’s not even funny: For objects we will need to have a table object, chair object, computer object, blackboard object, etc… These types of objects are often referred to as Business Objects; these object mimic real life objects. What this means is we program the objects to model the real objects. We give the virtual objects the same properties that our real object has, and we program its behavior based on how it behaves in the real world. Realizing that virtual objects in the program just follow the same rules and properties that their real life counterparts do was the golden key to the city of OO Programming for me. This is really powerful stuff!