The client and server code given so far is very procedural. In fact, the best way to express the server is as a finite-state machine, and this works well for the client too.
A finite-state machine isn't an O/O representation. How does this fit in with O/O design representations such as UML? It doesn't. So if you want to use UML, you have to hide the finite-state machine.
A simple UML diagram for a standalone FTP application could be
To change this to a client/server system, the FTP object needs to be split in two: one half in the client address space, the other half in the server address space. The two half-objects will communicate using a private protocol that is unknown to the rest of the application.
The private protocol will here be "message passing using sockets". Other implementations may use CORBA, RMI, JXTA, etc. This allows the implementation of the HOPP objects to be changed without affecting the rest of the application.
The server from the lecture on protocols nearly fits this design pattern. The changes are
FileTransferServerHOPP
String[] dir()
boolean chdir(String dir)
String getdir()
SocketHandler
in a new thread
for each new socket
SocketHandler
has a FileTransferServerHOPP
to
which it delegates all file calls.
The client in the lecture on protocols does not fit this design pattern and does need to be changed. It mixed up UI and protocol calls, and these should be separated.
A revised client, made up of FileTransferClientHOPP
and FileTransferClientUI
follow. Points to look
out for
String[] dir()
boolean chdir(String dir)
String getdir()
The client HOPP is
The Client UI is
RemoteException