Yeah it is a common issue that the OOP examples tend to be too simple and the value behind can not be identified. After all, the OOP approach makes things more complicated in the first place, but as soon the program gets a bit of complexity the abstraction shows its true value.
@RalphaelNinja: I have taken several approaches to show "old school" programmers with a background in RPG and now (Visual) Basic to get in touch with OOP. It is amazing how difficult it is to show someone the benefits of it by just a discussion. Common arguments against OOP from the old school people cover "needs more code to achieve the same", "I can not follow the code flow due to abstraction (polymorphism)" and finally "it might just be too complicated".
I understand that the root cause of those wrong arguments comes from the fact that those people try to apply their old and proven structural programming knowledge to the OOP world. Off course, you still program structurally inside classes, but they seem not to be able to get the big picture.
I wonder if you have some easy to understand arguments to explain the matter to "another" old school programmer?
hello Fellows... if I read your post correctly, you are asking if I have more easy to understand arguements to another "old school programmer?"
Actually I'm one of the kinky old school programmers back then; I actually love OOPS and needed no convincing to head for the dark side. Today, OOPS is so easily available that there is no reason why you shouldn't tackle it with vigor as everything is now OOP and that is the way it is. In the old days you have to pay to get OOPS and now like with AHK, it is free. Free!! what more can you ask for
1st Arguement: Free is one of my arguements that it is time to take an old topic and put it to rest. Everything is in OOPS now and If you are a structure programmer then you have to start OOPS by using classes. This is the foundation on which OOPs is based on. Within the Class you begin defining the structure of the object, the local variables and the self contained methods. When you begin working with a Class, you begin to think of self contained Commands that you can tell this object to do; like in my case, "Blink" "off", sit and beg...
Second arguement: OOPS is used wisely can reduce your structure coding by 50% or more. I've finished my program that allows you select which sim Expansion pack that gets activated and by using OOPS the coding has been reduced from 3000 lines of coding down to about 1000 lines. Structures that previously had over a hundred if-then-else coding has been reduced down to:
for k, v in SimButtons
v.save()
v.save() is the method in which each game updates itself in the registry. Now instead of having to deal with each game separately and maintaing information about which game goes with which variable, like game_01 goes with game_01_registry goes with game_01_textstring etc, all this information along with its methods are all "encapsulated" in a single game object.
Granted you could store all this information in a "Structure" or "Record" array, but.... this is what an object is... a structured record
Third Arguement: Once you wrap your head around this paridigm, there are some things that you can do in OOPS that you really cannot do in standard logic flow.
In my game selection, one of the function that I needed was to select one expansion pack to play and the rest would be deactivated and their entries removed from the registry. Now given that I did not have an array of games, I would have to hard code the games in straight deativation list, or I could simply remove all the games and re-insert only the game that I wanted to play.... but I still had to remember what the original settings was so that I could restore the deleted games.... yes yes.... there are hundreds of possible solutions....
but one came to mind.... OOPS...
here is my oop solution...
for k, v in simbuttons
v.push()
the push() method is defined to save the status of itself and set it's new status to off
turn on the game that I selected.... run the launcher...
and on return
for k, v in simbuttons
v.pop()
last arguement:
This was the original reason that I decided to go to OOPS with this game selection program, to reduce the complexity of the logic. Objects themselves are self contained and you don't have to worry where the associated data and functions that can manipulate that object are stored. This is true if you have very complex functions of which you no longer have to pass as parameters that contains hundreds of parameters. Objects can be created with defaults. In the hands of a programmer artist, OOPs is a thing of beauty, but like any programming tool, it can get ugly rather quickly; like most of the novelty examples that I have seen; however this is true of all programmers as they love obfusated code.
when I see code like: for k,v in simbuttons v.off(), I am in love!! it is just so simple!!