If you need to learn/teach object orientation, these are my approaches (I hate that classic "car" example):

1) Keep in mind games like Warcraft, Starcraft, Civilization, Age of Empires (yes, I am old school). They are a good example of having classes to use, instantiating objects (creatures) and putting them to work together. As in a real system.

2) Think of your program as an office that has a job to do, or a factory that has something to deliver. Classes are the roles/jobs and objects are the workers/employees. They don't need to be complex, but their purpose must be really (really, really) well defined. Just like in a real office / factory.

3) Even better (or crazier), see your classes and objects as real beings, digital creatures in a abstract world, and yourself as a kind of god, who creates species (define classes) with wisdom. Give life when it is the time for them to come into the world (instantiate object) and kill them when they are done with their mission (dispose an object). Give them behavior, logic, conditions to work with, situations where they take action, and when they don't. Make them kinda "smart". Build them able to make decisions and take actions based on conditions. Give them life. Think on your program as an ecossystem. There must be balance, connection, species must be well defined and creatures must work together to achieve a common objective. Don't just throw code and pray for it to run. Plan it.


When I talk about my classes like they are real beings, and programs as mini-worlds, some people say I am crazy, some others say that's passion.

It is both! @__@

  • 2
    That's a really good explanation! I have only learned OOP by approaching it the same way you did, but instead of rpg my analogy was plataformers (no wonder, my favorites are all time classics Megamans, Castlevanias and Metroids).

    I tried several times but I could never understand OOP when framed in terms of cars, animals, etc. It simply did not make any sense to me, so when I looked it from this different angle, which is by the way the natural angle to see it, as the whole abstract idea of objects and behaviors only live inside computer systems - suddenly I had this leap of knowledge and the day after I was able to code stuff in OOP like a real pro.
  • 1
    I'll try it next semester :)
  • 0
    @kaloczidev Looking forward to hear from you how it worked!
Add Comment