4 ms·
Yes! This is something it took me a long time to internalize but is something I absolutely love about Objective-C. Regardless of any technical differences betwe
by macrael 16y ago
Yes! This is something it took me a long time to internalize but is something I absolutely love about Objective-C. Regardless of any technical differences between message passing and method calling, there was a real shift in how I thought about the process. When I started thinking about object interaction as message passing, it made me write better encapsulated code. I'm not sure exactly what it is, I think that part of it is that to me a “message” sounds more lightweight than a method call, or that it more strongly stresses the concept that objects are communicating, but it a different way of seeing the problem.
- barrkel 16y agoIt's funny you should say that. I have the exact opposite intuition: message passing is substantially slower than method calls, especially statically bound method calls in a statically typed, compiled language. You're right that message passing is a different way of looking at things; but obviously it's something different to method calls. Delegation, for one thing, is much easier with message passing, as are other strategies, like default implementations, remoting (never mind how poorly RPC scales), etc. On the other hand, getting two objects to communicate over a private channel can be more awkward, as they need to share pre-arranged references, rather than simply being friends / package / internal visibility, or similar visibility override.
- arethuza 16y agoYeah, to me "message" makes me think of very heavy duty systems like MQ.