I often hear....

Started by
2 comments, last by luasitdown 18 years, 8 months ago
the OO programming is object and message pass between them. please give a simple example. where is message. Is it a string?
Advertisement
The "message" is the method call.

e.g.

An instance of ClassA would send a message to objectB
ClassA::DoSomething()
{
objectB->SomeMethod();
}


Direct invocation is most common, but once you have this seperation you can move the objects between processes or computers and use IPC and/or networking to "send the message". See DCOM, CCM3, or .Net Remoting (not sure what it's called in Java).
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I hate to say it, but I would probably either get a book on the subject of OOP (Object Oriented Programming) or take a class.

The basis of Object Oriented Programming is that an Object (or class) contains data and methods to access/modify the data in the class. Objects talk to each other by passing data/messages to each other. The kind of data/message being passed is really dependant on the specific situation.

Lets suppose I have two objects, a Lightbulb and Switch. They are somewhat like the following:

Lightbulb:
----------
State: On or Off
----------
+SetState(State)


Switch
---------
SwitchState: Up or Down
---------
+TurnOnLight(LightBulb)
+TurnOffLight(LightBulb)


Now, when I want to turn on the light, I would do something like:
Switch.TurnOnLight(DeskLamp)

The code behind this would be something like:
Switch::TurnOnLight(LightBulb)
{
LightBulb.SetState(On)
}

The Switch object basically sends a message to the LightBulb object, to tell it to change it's state from Off to On. I really would recommend getting a book on the subject, or even browsing a basic C++/Java/Object Oriented Programming book to get a rough idea of how things work.
Thanks for you two.

There some dependency relation bewteen Modules(class).

So I think the relation are base of message.

i.e. if 2 object (class) have not dependency ,and message cannot be produced.

This topic is closed to new replies.

Advertisement