CA421 Object Oriented Metrics and Design - Patterns Project

For this project I have decided to implement the Façade Pattern. I have applied the pattern to a set of classes which deal with checking IP addresses’ for administrators and allowing Clients to connect to printers on a network. This assignment allowed me to develop some of the structures and classes which I will be using for my fourth year project. The implementation for this assignment is different than for my final year project but the core functionality will be the same. It also allowed me to develop my Java programming skills, especially in the area of servlets.

2. Description of the Facade Pattern - Taken From GOF

Intent

Encapsulate a subsystem using a high-level interface, simplifying subsystem usage and hiding structural details.

 

                 

Solution

  1. Clients communicate with subsystem objects by calling methods in Façade
  2. Clients never (or as seldom as possible) directly accessing objects in subsystem -- any such access weakens the encapsulation.
  3. Subsystem objects usually retain no knowledge of client
  4. Subsystem objects do not normally maintain any reference to Façade

Consequences

  • Eliminates hard to control tangled networks of object associations
  • Reduces number of objects clients need to interface with.
  • Promotes weak coupling, which enhances overall flexibility.

Related Patterns

  • Façades are often implemented as Singletons.
  • Mediator is somewhat similar to Façade
3. Overview of the project

This program is part of a web based network management system which I will be developing for my final year project. I have changed the functionality for the purpose of this project but the principle ideas are the same. This program allows both administrator and client access via the web.

Administrators can check if a server is online by pinging the IP address of the server. The results of the request will be sent via email to the email specified by the administrator.

Clients can connect to any printer by just selecting that printer and hitting connect.  These are the basic functions of the program but complicated classes which deal with pinging servers, verifying the results, email notification and print server allocation are hidden from the client class and are only accesses via the façade class – AdminRequest.java

The program can be broken down into three basic sections:

1. User Details – name, password and email address.

2. Administrator request – IP check

3. Client Request – Printer Connection with automated print server allocation

4. Description of the project

Throughout this program it is the façade class, AdminRequest.java which deals with the classes lying in the subsystem. The client class never access’ or references any of the classes which perform the requested operations.

ServerCheck.java and ServerAllocate.java both inherit common methods from ServerFacility.java. Using inheritence here saves time as both classes share some common methods. AdminNotify.java is accessed by both server classes and performs email notification when a server is down

1. User Details:

This section must be completed by both administrators and clients. For the purpose of this project an administrator can enter any password but clients must be of 8 characters long. (In the correct implementation of this feature a database of valid Ids would be searched and privileges decided from there.) The sample input/output sessions details the response if all details are not entered correctly.

2. Administrator Request:

Administrator requests are contolled by ServerCheck.java and email notification is controlled by AdminNotify.java. If the user has completed all the detail fields and supplied a valid administrator password then they can perform an IP address check. This is done by pinging the IP address entered, verifying the results and sending the results via email to the email address specified.

3. Client Request:

Client requests are contolled by ServerAllocate.java. If the user has completed all the detail fields and supplied a valid administrator password then they can set any of the printers in the drop down list as their default. This also has the feature of print server allocation. If for example a company has two or more print servers then they need a way to efficiently manage new printer connections without the client having any knowledge of print servers. This is done by firstly making sure that both print servers are online by pinging the servers. If one is offline then the client is automatically connected to the printer via the online server. If both are online then a server needs to be allocated by comparing the amout of connections via each server. This will be done by accessing a historical database in the full version. Printer connection is done by updating the registry settings of the users machine, these files are controlled by running batch files which have been created independently of this program.

Diagrams

1. UML diagram - overview diagram + class diagrams

2. Sequence Diagram

Java Code

1. Admin Request.java - Facade Class

2. AdminServlet.java - Client Class

3. AdminNotify.java - email notification class

4. ServerFacility.java - Server super class

5. ServerAllocate.java - Printer connection class

6. ServerCheck.java - IP address check class

7. Pause.java - Interface with delay method

Sample Input/ Output Session

Input - sample input and output

Administrator/Client Servlet Interface

AdminServlet.shtml

David Reade Computer Applications Software Engineering - Last updated November 2002
-
Projects Semester 1

Project Preparation
OO Project
Databases
Multimedia Essay
Graphics Assignment

Project Semester 2

OO Models Z-specification
Multimedia Essay
Distributed Assignment I
Distributed Assignment II --

Final Year Project

1. Proposal
2. Functional Spec.
3. Technical Manual
4. User Manual

Third Year Project

1. Functional Spec.
2. Technical Manual
3. User Manual
4. Battleship Game

Course Description

Computer Applications

Subjects Semester 1

1. Object Oriented Metrics
2. Multimedia Retrieval
3. Computer Graphics
4. Database Theory
5. Project Preparation
6. Digital Signal Processing

Subjects Semester 2

1. Object Oriented Models
2. Distributed Prog.
3. Multimedia Technology
4. Final Year Project

Structure in Years

1. First Year
2. Second Year
3. Third Year
4. Fourth Year