Search code examples
oopmodelschannel

What is message passing in OOP?


I am interested in message passing, generally.

I read few definitions but it's still completely unclear and abstract to me what it really means.

Now, here is where it's struck me that MP is crucial...

Class-based Object-oriented programming languages support objects defined by their class. Class definitions include member data. Message passing is a key concept (if not the key concept) in Object-oriented languages.

So, could someone explain me what is message passing in (as much as possible) clear English with some analogy or some examples.

I do have about a year experience in programming, but mostly on CodeAcademy, plus various books, youtube videos and Wikipedia articles.


Solution

  • In an object oriented approach, objects do things themselves. A "message" is the terminology used when telling an object to do something.

    The opposite is a procedural approach, where code gets some information elsewhere, and then acts based on the information provided.

    Consider the diagram at http://aryehoffman.com/reference/action-object-principle/