Thursday, September 26, 2013

Object Model of Objective C

Object Model of objective C is derived from SmallTalk. It has its basis in SmallTalk. Few things to know before understanding the Object Model.

What is Object?

Think of Object as a real world entity. What is a real world entity? It is something which have some data in its possession and perform different kind of functions. e.g. Think of a Tap as an object. It perform different kind of functions like start water flow, stop water flow, control the rate at which water should flow. Objects hold the data and the methods it perform.

It is like an actor in a play. Which communicate to other actors but it has its own identity and its own dialogues and actions to perform. It has to stick to the script. It can perform multiple roles as the script progress. So an Object is something who has some functions to do and it can stand at its own.

Object Model 

Object Model in a programming language describe how different objects communicates with each other, what different actions can be performed using these objects.
In Objective C, Objects communicate with each other via Messages. Objects send messages to each other and sending message can result in a response or no response at all.

How sending a Message to an Object is different from Invoking a method on an Object. If we say Invoking a method on an object than we are certain about the type of data the method is expecting and the kind of response we will get. However if we say sending a Message, we do not talk about the type of data sent and what will be the response.

In Objective C messaging metaphor made it clear that we should think of objects in term of the behavior and should not think about methods unlike procedural language.

No comments:

Post a Comment