Friday, August 03, 2012

Introduction to OOP (cont.)

Hello again! Let's continue with our short introduction to OOP. We already know what is a program, what is a programming language and more importantly for this entry, what is a paradigm.


We're here to learn Object Oriented Programming, which follows the Object Oriented paradigm. So the question now is, what do we think about when we make a program based on this paradigm?


This paradigm has two main ideas: objects and messages. A object is an entity that exhibits a specific behavior, and that behavior gets triggered when a message is sent to the object. A program that follows this paradigm is nothing but a bunch of objects that send messages to each other in their little object world (aka environment) to reach a common goal.




Harmony: Suppose I want to make a program about music. The instruments could be objects in that program and the way to play music would be by sending messages to the instruments so they produce the sounds I want. But if I don't interact with the objects, nothing will happen.



Grouchy: I hate Harmony's "music".
Let's hope the music he models sound better than reality.



That's interesting Grouchy, thanks for bringing it up :) It's important to differentiate reality from the model of it we make based on what we want the program to do. In reality, Harmony has physical instruments he uses to produce sounds, but in his program the objects he uses to represent the instruments are not actual instruments. This may sound rather trivial, but sometimes we might find that the objects we program do not behave exactly like the ones in reality. The good thing about that is that we can take that licence to make our programs simpler, after all we only need to program what will help us reach our goal in the way we think it's more convenient.

I know for now it all seems very vague, so the next step is to find an example of a very small program for us to start using and adding more ideas to the basic ones.

See you soon!!