4 ms·
In most systems, try to call a method that doesn't exist on something. It will bark at you. In the types of OO systems Kay discusses, it's up to the receiver t
by scroot 8y ago
In most systems, try to call a method that doesn't exist on something. It will bark at you.
In the types of OO systems Kay discusses, it's up to the receiver to determine whether or not to respond to a message and how to behave if it doesn't "understand" the message. That's how you get maximum polymorphism as well -- for example, all kinds of objects are "cancelable" if they respond to / understand the message #cancel, etc, etc
- mamon 8y agook, so truly oriented OO system needs some equivalent of Ruby's method_missing() ? Is that's what you mean?
- chrisseaton 8y agoI'm not sure method_missing is powerful enough to do message passing. It's method_missing, not method_received. You can't intercept message that already have a method defined for them. The sender chooses which method to call, and may call method_missing. It's not entirely up to the object how to respond to a message.
- galaxyLogic 8y agoYou can create a class which has no other methods than 'method_missing'. The explicitly declared methods are just useful syntactic sugar for how to respond to specific messages.
- dodobirdlord 8y agoThe structure I'm envisioning here is that every object has a public pass(m) method that takes an input message and has no other public methods. Every message is a legitimate input to pass(m), and every object can call the pass method of any other object. It's up to each object to decide for itself what it will do with any given message that it receives. If an object wants a response to its message it can identify itself in the message and then hopefully the object being passed the message will choose to pass a message back. This seems exactly analogous to how a collection of webservers interact. They can only communicate with each other by tossing a chunk of bytes around hoping that the target knows what it's supposed to be doing with those bytes.
- hota_mazi 8y ago> and every object can call the pass method of any other object. It's up to each object to decide for itself what it will do with any given message that it receives. It's a horrible programming model, though. We should be glad this is not how most languages work.
- dnautics 8y ago>It's a horrible programming model, though. Have you ever actually programmed in this model? I wrote a correct RAFT library in ~300 lines of code that are extremely legible using this model.
- scroot 8y ago> It's a horrible programming model, though. We should be glad this is not how most languages work. This is not only about languages, but also environments. The argument Kay makes is that in order to make very large complex systems that are resilient, you need something like this kind of message passing. And indeed, this is how the Internet works too
- hota_mazi 8y agoThe Internet works in hundreds of different ways, message passing, RPC, REST, store and forward, propagation, etc...
- scroot 8y agoIt's all made possible because of the protocol which is a kind of message passing. If a node somewhere on the Internet doesn't receive a packet for whatever reason, the whole network doesn't come crashing down.
- edwinyzh 8y agoThis sounds like the Event Bus (which can be implemented in an OOP language) to me.
- arethuza 8y agoDo people use that publish-subsribe model within a process rather than between processes? Any time I've encountered the 'event bus' model it's been for 'enterprise' (for lack of a better term) scale integration (i.e. gluing together applications across an organisation).
- edwinyzh 8y agoSure, no matter what kind of programs. To get an idea, take a look at the example code at the end of the page: https://github.com/spinettaro/delphi-event-bus https://github.com/spinettaro/delphi-event-bus