Chapter 8. Distributed Object-Oriented Programming in C++
In this Chapter
Distributed objects are objects that are part of the same application but reside in different address spaces. The address spaces may be on the same computer or on different computers connected by a network or another form of communication. The objects involved in the application could have been designed originally to work together or they may have been designed by different departments, divisions, companies, or organizations at different times and for different purposes. A distributed object-oriented application can be anything from a one-time collaborative effort by a collection of unrelated objects to a multigenerational application whose objects are spread over the entire Internet. The location of the objects can be intermixed between intranets , extranets, and the Internet. In the most general description of distributed objects, the object may be implemented in different languages such as C++, Java, Eiffel, and Smalltalk. Distributed objects play a number of roles. In some situations an object or collection of objects is used as a server that can provide database, application, or communication services. In other situations objects play the part of clients . Distributed objects can be used in collaborative problem-solving models such as blackboards and multiagent systems. Besides collaborative problem-solving models, distributed objects can be used to implement parallel programming paradigms such as SPMD and MPMD. Objects within the same application don't need any special protocol to communicate. The communication is achieved through normal method invocation, parameter passing, and global variables . Since distributed objects reside in different address spaces, inter-process communication techniques are required and in many cases network programming is necessary. Applications that require distribution can be necessary for several reasons:
In an object-oriented application, the work that a program does is divided between a number of objects. These objects are models of some real-world person, place, thing, or idea. The execution of an object-oriented program causes its objects to interact with each other according to the models they represent. In a distributed object-oriented application, some interacting objects will have been created by different programs possibly running on different computers. Recall from Chapter 3 that each executing program has one or more processes associated with it. Each process has its own resources. For instance, each process has its own memory, file handles, stack space, process id, and so on. Tasks executing in one process do not have direct access to the resources owned by another process. If the tasks executing in one process need information stored in the memory of another process, then the two processes must explicitly exchange the information either through files, pipes, shared memory, environment variables, or sockets. Objects that reside in different processes that need to interact must also explicitly exchange information in one of these ways. The challenges for the C++ developer that wants to do distributed object-oriented programming include:
|