Professional Documents
Culture Documents
Chapter 3:
Basing Software Development on
Reusable Technology
3.1 Building on the Experience of Others
Types of reuse:
• Reuse of expertise
• Reuse of standard designs and algorithms
• Reuse of libraries of classes or procedures
• Reuse of powerful commands built into languages and
operating systems
• Reuse of frameworks
• Reuse of complete applications
Horizontal framework
Vertical
framework
H o riz o n ta l fra m e w o rk
V e rtic a l
fra m e w o rk
C o d e to b e p ro v id e d to a d a p t th e fra m e w o rk to th e
n e e d s o f th e a p p lic a tio n
• Have no communication
— Each computer performs the work separately
terminate
interact wait for server wait for wait for wait for interact with
with user events connections messages: messages: server user
client A client B
create
connect create
send message
reply to message
display reply
send message
reply to message
display reply
kill client
display disconnect
disconnect
output = new
OutputStream(clientSocket.getOutputStream());
input = new
InputStream(clientSocket.getInputStream());
They:
• Create subclasses of the abstract classes in the
framework
Controlling methods:
• openConnection
• closeConnection
• sendToServer
Accessing methods:
• isConnected
• getHost
• setHost
• getPort
• setPort
• getInetAddress
Instance variables:
• A Socket which keeps all the information about the
connection to the server
• Two streams, an ObjectOutputStream and an
ObjectInputStream
• A Thread that runs using AbstractClient’s run
method
• Two variables storing the host and port of the server
Two classes:
• One for the thread which listens for new connections
(AbstractServer)
Controlling methods:
• listen
• stopListening
• close
• sendToAllClients
Accessing methods:
• isListening
• getClientConnections
• getPort
• setPort
• setBacklog
<<interface>>
AbstractClient AbstractServer
ChatIF
display
ChatClient EchoServer
handleMessageFromServer handleMessageFromClient
ClientConsole
handleMessageFromClientUI serverStarted
accept quit serverStopped
display main
main