Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Object-Oriented Thought Process Chapter 14

Similar presentations


Presentation on theme: "The Object-Oriented Thought Process Chapter 14"— Presentation transcript:

1 The Object-Oriented Thought Process Chapter 14
Objects and Client/Server Applications

2 Client/Server Approaches
As we have seen in several of the previous chapters, XML has had a major impact on the development technologies used today. A distributed object model can either be build on a proprietary system or use a nonproprietary approach based on technologies like SOAP/ XML. The same can be said of a client/server model. An application can be built solely on a proprietary system or on a design using an XML.

3 Proprietary Approach (Java)
In this design, the client creates an object and then sends it to the server. The server creates a reference to the object to access it. The server then may update the object’s attributes and send it back to the client. The client can then process and use the object.

4 Serialized Object Code
The object is sent between the client and server. Objects are serialized so they can be marshalled between the client and server. It is important to note that the object is serialized in a proprietary (in this case Java) binary format.

5 Client Code The client code uses the TextMessage class to create an object and start it on a journey to the server and back. The client must perform the following tasks: Get the user information. Create an object. Set the attributes. Create a socket connection. Create the output streams. Write the object. Close the streams.

6 Server Code On the other side of the wire, the server code performs the following tasks: Create an object reference. Listen to the virtual port Wait for a client to connect. Create the Input/Output streams. Read the TextMessage object. Print the message.

7 Nonproprietary Approach
The previous example was handled in a proprietary manner. To create a nonproprietary approach, we can utilize XML technology just like we did with data persistence and distributed object. Using the XML approach allows us to send the objects back and forth between applications written in various languages and, theoretically, between various platforms.

8 Object Definition Code
When creating an XML version of the CheckingAccount class, we can immediately see, by inspecting the code, that the XML definition of the object is embedded directly in the class itself.

9 Object Definition Code
In .NET examples (C# and VB), the class is created around the XML definitions. This approach can be accomplished with Java as well. In fact, by using the XML approach, we can use whatever language or platform we want interchangeably. That is the beauty of the nonproprietary approach.

10 Client Code For this example, the client performs the following tasks:
Create the checkingAccount object. Create the socket. Serialize the object to XML. Create the stream. Serialize the object to the stream. Close the resources. Close the streams.

11 Server Code In this case we use a loop (in fact, a couple of loops) to implement this version of the server. Again, we can let the code comments provide the flow; however, the server provides the following functions: Create the checkingAccount object references. Connect to the socket and listen. Setup the input stream. Create the stream. Read the bytes off the stream. Serialize the object to the stream. Close everything down.


Download ppt "The Object-Oriented Thought Process Chapter 14"

Similar presentations


Ads by Google