This article is about the computer science concept. Message passing differs from conventional programming where a process, subroutine, or function is directly invoked by name. Message passing is key to some unix systems programming communication concurrency and threads pdf of concurrency and object-oriented programming.
Message passing is used ubiquitously in modern computer software. Message passing may be implemented by various mechanisms, including channels. In contrast to the traditional technique of calling a program by name, message passing uses an object model to distinguish the general function from the specific implementations.
The invoking program sends a message and relies on the object to select and execute the appropriate code. The justifications for using an intermediate layer essentially falls into two categories: encapsulation and distribution. Encapsulation is the idea that software objects should be able to invoke services on other objects without knowing or caring about how those services are implemented. Encapsulation can reduce the amount of coding logic and make systems more maintainable.
IF-THEN statements that determine which subroutine or function to call a developer can just send a message to the object and the object will select the appropriate code based on its type. One of the first examples of how this can be used was in the domain of computer graphics.
There are all sorts of complexities involved in manipulating graphic objects. For example, simply using the right formula to compute the area of an enclosed shape will vary depending on if the shape is a triangle, rectangle, elipse, or circle. In traditional computer programming this would result in long IF-THEN statements testing what sort of object the shape was and calling the appropriate code. Shape asking it to compute its area.