Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
From the author of

The Distributed Object system is a good demonstration of the flexibility of Objective-C. Implementing it requires the second-chance dispatch mechanism that Objective-C inherits from Smalltalk, but that languages like C++ lack. In C++, you would not be able to use local and remote instances of an object interchangeably unless the code had been specifically designed using virtual functions or templates to support this possibility. In Objective-C, you can pass a DO proxy to code from a framework that someone else wrote and expect it to just work.

It's not surprising that DO was one of the products that NeXT charged a large premium for back in the '90s. It is a shame that it's not used more widely. It's quite common to see people invent some custom networking protocol for sending simple messages around when using DO would require half a dozen lines of code. Don't be put off by the large number of complex classes in the Distributed Objects reference. The system is incredibly complex and powerful, but using it is simple unless you want to exploit some of the more subtle aspects of it. Most of the time, it's trivial to use.

If you're using GNUstep, rather than Cocoa, then you can still use DO, but you also get a couple of even simpler options if you just want to broadcast messages. GNUstep's NSDistributedNotificationCenter implementation supports two additional types not found in Cocoa: GSNetworkNotificationCenterType and GSPublicNotificationCenterType. These send distributed notifications to the local network and to all users on the local machine, respectively.

  • + Share This
  • 🔖 Save To Your Account