Exchange messages between objects, what does it mean?

Asked

Viewed 1,710 times

13

What is the term message exchange between objects in Object-Oriented Programming?

1 answer

10


For use mainstream is what everyone knows as invocation or method call. That is, you call a method and indicate which object you are referring to.

Smalltalk is that the language that originated the term uses it more correctly and has a more important meaning and has a more sophisticated system of invocation, delegation and solution of non-existent method. That is, the object has an infrastructure to solve what it actually runs. The flexibility is enormous but the performance is usually poor.

Smalltalk is a language where truly (not just marketing) everything is an object, including the message and the classes themselves. This requires great dynamism in language.

Messaging is usually done by a full copy of the data that is great for competition but bad for resource savings, so it is something little adopted.

Correctly, the term is little used in practice in languages such as Java, C# or C++ that have a simpler mechanism and almost all solved in the compilation. But there are people who adopt the term even though it’s not exactly what happens in these languages.

Wikipedia article.

Read more about how the term ended up associated with OOP without being. Also. Add to that. One more comprehensive discussion can be seen in the SE.SE.

To better understand every question. And OOP is not what people learn.

  • 1

    To be a little clearer, you could provide me an example, in java, of message exchange between objects?

  • 1

    Basically not. Because Java doesn’t have this exchange. Unless you think this is a message exchange: objeto1.metodo(objeto2). Actually this cannot be considered a message exchange as defined in OOP. But if you want to use the term anyway, then it’s just a simple call. I know a lot of people use the term for this, but it doesn’t refer to the mechanism as it was defined. You asked about the term and I have to say what it is. There is a lot of confusion about what OOP is and what we use in those languages is not quite OOP.

  • 1

    I understood, this question came to me because I heard this term a lot as being related to OOP, but I couldn’t associate it with implementation, and one language I’m learning now is Java, so I thought Java used this concept

  • 3

    Not exactly, because Java is not a truly object-oriented language in the formal definition of the paradigm. Of course, it uses a form of OOP, but it’s a little different and one of the main differences is this one. Message passing between objects is not a sophisticated and dynamic mechanism but a simple call from a function solved wholly or partially at compile time.

  • 1

    But if Java is not a truly object-oriented language, which or which are?

  • 2

    I wrote in reply.

  • 1

    @bigown And polymorphism, the fact that a polymorphic call has the target set at runtime, doesn’t count as message exchange?

  • 1

    Counting counts, but not as it is formally defined. Not polymorphism itself, but the call is what generates the exchange. The polymorphism gives a small dynamic touch but is a very simple and limited mechanism. Ruby is a language that comes much closer to the original messaging system. But it’s tricky too. And if this mechanism were so good it would be widely used. What is and what does not enter a complicated field. What is formal can be ignored and the term successfully used in another way that serves other interests well.

  • Very cool comment @Maniero, complementing, a model more similar to Smalltalk currently used is the actor model of Elixir. He works with living objectives in memory and passes messages between them, including creating queues of messages at the entrance of these objects.

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.