Slide 3 Chapter 3
Slide 3 Chapter 3
Chapter 3:
Basing Software Development on
Reusable Technology
Building on the Experience of Others
•Software engineers should avoid re-developing software
already developed
•Types of reuse:
– Reuse of expertise
Experience, Article and blog of expert software engineer
– Reuse of standard designs and algorithms
There are thousands of algorithms, designs and documentation
– Reuse of libraries of classes or procedures
Libraries and commands represent implemented algorithms,
data structures and other facilities
Chap. 3: Basing Development on Reusable
2
Technology
Building on the Experience of Others
– Reuse of powerful commands built into languages and
operating systems
– Reuse of frameworks
Frameworks represent more than libraries, they represent
the structure of entire applications or subsystems
– Reuse of complete applications
Use full application and adapting it to the need of a client
by adding a small amount of extra software.
Extra code often called glue code.
Scripting language is used
Frameworks: Reusable Subsystems
•A framework is reusable subsystem that implements a
generic solution to a generalized problem.
– It provides common facilities applicable to different
application programs.
•Example:
– A framework for payroll management
Payment, tax, deduction
– A framework for frequent buyer clubs
frequent flier or frequent buyer for a supershop
– A framework for university registration
– A framework for e-commerce web sites
Chap. 3: Basing Development on Reusable
6
Technology
Frameworks and product lines
– A product line (or product family) is a set of
products built on a common base of
technology.
• The various products in the product line have
different features to satisfy different markets
• The software common to all products is included in a
framework
• Each product is produced by filling the available
hooks and slots
– E.g. software products offering ‘demo’, ‘lite’ or ‘pro’
versions
output = clientSocket.getOutputStream();
input = clientSocket.getInputStream();
•They:
– Create subclasses of the abstract classes in the framework
•Accessing methods:
– isConnected -- to inquire whether client is connected to a server
– getHost -- which host the client is connected to
– setHost -- change the host of a disconnected client
– getPort -- which port the client is connected to
– setPort -- change the port of a disconnected client
– getInetAddress – provides detailed information about the client
•Accessing methods:
– isListening -- determines if server is listening
– getClientConnections -- returns an array of instances of
ConnectionToClient
– getPort -- what port the server is listening on
– setPort -- set a port to listen
– setBacklog -- set the size of the client queue length
Chap. 3: Basing Development on Reusable
32
Technology
The callback methods of AbstractServer
•Methods that may be overridden:
– serverStarted – called when starts accepting connections
– clientConnected – when new client connects
– clientDisconnected – disconnect a client using close Method of
ConnectionToClient
– clientException – client disconnects itself or network failure
– serverStopped – whenever server stops accepting connections
– listeningException -- whenever server stops accepting
connections due to some failure
– serverClosed – when server closes down
•Method that must be implemented:
– handleMessageFromClient
Chap. 3: Basing Development on Reusable
33
Technology
The public interface of ConnectionToClient
•Controlling methods:
– sendToClient – communicate with client
– close – causes the client to be disconnected
•Accessing methods:
– getInetAddress – internet address of the client
connection
– setInfo – arbitrary information to be saved
– getInfo – retreival of information
Chap. 3: Basing Development on Reusable
34
Technology
Using AbstractServer and ConnectionToClient
– Security
• Security is a big problem with no perfect solutions:
consider the use of encryption, firewalls, ...