Wednesday 31 December 2008

Introduction to Objects - part II

First of all a happy 2009 for all of you !

In a previous blogmessage I explained a bit the concepts of objects.
Now another important concept is the way how objects communicate with each other.

The communication between objects happens by sending messages. If for example an object A wants to retrieve something from object B then A will have to send a message to B that B understands.

It looks a bit abstract but later on I'll show how that works in Objective-C.

Now their is a difference in a message and a method invocation. As already explaned an instance of class can be part of a whole class tree structure and as such a message can be implemented in different ways (=methods).
For example take a number of objects which are instances of the classes Point, Circle, Rectangle. To those objects you can send the message 'draw' , the actual method that will be invoked will be different for each object.

Note that in Objective-C you don't have to care about that, its the compiler/system that ensures that the right method is invoked.

Oke, this is enough theory, in a next message we'll start with some programming

No comments:

Post a Comment