Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Module Name and Code: Object Oriented Development with Java (CT038-3.5-2)
Intake Code: UC2F1303IT {NC}
Hand Out Date: September 27th, 2013
Hand in Date: December 9th, 2013
Words Count: 4578 words
Lecturers Name: IMRAN MEDI
CT038-3.5-2
Individual Assignment
1. Table of contents
1.
2.
Table of figures..................................................................................................................................... iv
3.
4.
Acknowledgment ................................................................................................................................... 6
5.
Abstract .................................................................................................................................................. 6
6.
Introduction ........................................................................................................................................... 6
7.
B.
C.
D.
Class Diagram............................................................................................................................. 31
7.2.
8.
A.
B.
Inheritance .................................................................................................................................. 33
C.
Overriding ................................................................................................................................... 33
D.
Packages ..................................................................................................................................... 34
8.2.
8.3.
8.4.
8.5.
8.6.
A.
Singleton Pattern......................................................................................................................... 37
ii
CT038-3.5-2
Individual Assignment
B.
C.
Facade Pattern............................................................................................................................. 38
D.
Composite Pattern....................................................................................................................... 38
E.
8.7.
8.8.
8.9.
Which Design Pattern Suit the EIIMS Study Case and Why? ....................................................... 40
9.
10.
Conclusion ........................................................................................................................................... 44
Reference List ................................................................................................................................... 45
iii
Asia Pacific University
CT038-3.5-2
Individual Assignment
2. Table of figures
Figure 1: EIIMS Use Case Diagram ............................................................................................................... 8
Figure 2: AD - Add New Customer .............................................................................................................. 19
Figure 3: AD - Add new Job ......................................................................................................................... 20
Figure 4: AD - Add New User ...................................................................................................................... 21
Figure 5: AD - Generate Invoice .................................................................................................................. 22
Figure 6: AD - Job Search ............................................................................................................................ 23
Figure 7: AD - Search For Customer ............................................................................................................ 24
Figure 8: AD - Search For User .................................................................................................................... 25
Figure 9: AD - Update Duties ....................................................................................................................... 26
Figure 10: AD - User Login .......................................................................................................................... 27
Figure 11: AD - View Duties ........................................................................................................................ 28
Figure 12: AD - View Engineers Duties ....................................................................................................... 29
Figure 13: AD - View Statistics .................................................................................................................... 30
Figure 14: EIIMS Class Diagram ................................................................................................................. 31
Figure 15: Users Class .................................................................................................................................. 32
Figure 16: Facade Design Patter Solution Example ..................................................................................... 40
iv
Asia Pacific University
CT038-3.5-2
Individual Assignment
3. Table of Tables
Table 1: Add New User Use Case Description ............................................................................................... 9
Table 2: Search For User Use Case Description ............................................................................................. 9
Table 3: View Duties Use Case Description................................................................................................. 10
Table 4: Update Duties Use Case Description .............................................................................................. 10
Table 5: Generate Reports Use Case Description ......................................................................................... 10
Table 6: View Engineer Duties Use Case Description ................................................................................. 12
Table 7: View Statistics Use Case Description............................................................................................. 12
Table 8: Generate Reports Use Case Description ......................................................................................... 12
Table 9: Adding New Customer Use Case Description................................................................................ 14
Table 10: Customer Search Use Case Description ....................................................................................... 14
Table 11: New Job Use Case Description..................................................................................................... 15
Table 12: Job Search Use Case Description ................................................................................................. 15
Table 13: View Job Records Use Case Description ..................................................................................... 15
Table 14: View Customer Records Use Case Description ........................................................................... 17
Table 15: Generate Report Use Case Description ........................................................................................ 17
Table 16: Email Report Use Case Description ............................................................................................. 17
v
Asia Pacific University
CT038-3.5-2
Individual Assignment
4. Acknowledgment
I would like to express my special thanks and gratitude to my Lab lecturer Mr. Imran Medi, which with his
sincere guidance and help throughout the labs I had the chance to do and finish the Object Oriented
Development with Java assignment.
5. Abstract
This assignment is for Object Oriented Development with Java, requested by Mr. Imran Medi. The
assignment aims to develop an Object Oriented system using Java for INSPECT-RICALS, an Electrical
Contractions Company.
6. Introduction
Inspect-Ricals is an Electrical Constructions Company, which provides electrical wiring and installation
services for condominium developers and owners. The company requires a system that helps them
facilitate and manage the inspection process, as well as produce the necessary reports for the benefit of
management and clients. The system will be used by four types of users which are Administrators,
Engineers, Clerks and Managers.
Clerks are responsible for customers and customers order as well as allocating Engineers to specific jobs.
While Engineers are responsible for carrying out the allocated jobs. Manager will have managerial access
to the system to issue and print reports. Admin will have full administrative access to the system including
users management.
Page 6 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 7 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 8 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Use Case
Summary
Actor
Admin
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Use Case
Summary
Actor
Admin
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Page 9 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Use Case
View Duties
Summary
Actor
Engineer
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Use Case
Update Duties
Summary
Actor
Engineer
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
---Login
Use Case
Generate Reports
Summary
Actor
Pre-condition
Engineer
Assigned duties
Assigned finished duties
Post-condition
Exception
CT038-3.5-2
Sequence
Sub Use Case
Individual Assignment
Page 11 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Use Case
Summary
Actor
Manager
Pre-condition
Login
Post-condition
Exception
Sequence
----
Login
Use Case
View Statistics
Summary
Actor
Manager
Pre-condition
Post-condition
Generate report
Exception
Sequence
Sub Use Case
Use Case
Generate Reports
Summary
Actor
Pre-condition
Manager
Assigned duties to Engineers
Assigned finished duties by Engineers
Post-condition
Exception
Sequence
CT038-3.5-2
Sub Use Case
Individual Assignment
Login
Page 13 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Use Case
Summary
Actor
Clerk
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Use Case
Customer Search
Summary
Actor
Clerk
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Page 14 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Use Case
New Job
Summary
Actor
Clerk
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Use Case
Job Search
Summary
Actor
Clerk
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Use Case
Summary
Actor
Clerk
Pre-condition
Post-condition
Exception
Sequence
----
Login
Page 15 of 46
CT038-3.5-2
Individual Assignment
Page 16 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Use Case
Summary
Actor
Clerk
Pre-condition
Post-condition
Exception
Sequence
----
Login
Use Case
Generate Reports
Summary
Actor
Clerk
Pre-condition
Post-condition
Exception
Sequence
Sub Use Case
Use Case
Email Report
Summary
Actor
Clerk
Pre-condition
Post-condition
Sent Email
Exception
Sequence
CT038-3.5-2
Sub Use Case
Individual Assignment
Login
Page 18 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 19 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 20 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 21 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Generate Invoice
Page 22 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Job Search
Page 23 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 24 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 25 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Update Duties
Page 26 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
User Login
Page 27 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
View Duties
Page 28 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 29 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
View Statistics
Page 30 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
D. Class Diagram
Page 31 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Objects are a representation of a real-world things that have state such as name, color, etc. and behavior
such as eating, walking, etc. Java OOP objects stores the state in fields or and exposes the behavior
through methods or functions (Oracle, n.d.).
In my solution, objects of classes where created to represent different users instance.
public class C_AddNewJob_Form extends javax.swing.JFrame {
ClerkUser CU = new ClerkUser();
Page 32 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
B. Inheritance
Inheritance in OOP refers to the process where a class of objects acquires properties from another class. In
Java inheritance can be done through the use of one of the two keywords extends or implements (Wang,
2002). The Main class in the inheritance is called the super class or the parent class, and the second class is
the child class or the subclass.
In my solution code inheritance where used between the parent class User class and the other child classes
which are AdminUser Class, ClerkUser Class, EngUser Class and ManagementUser Class.
public class ManagementUser extends Users{
...
...
}
public class A_AddUser_Form extends javax.swing.JFrame {
...
...
}
C. Overriding
Overriding or method overriding is an instance method in the subclass with the same signature (name,
number and the type of its parameters) and return type as of the super class (Deitel & Deitel, 2002).
Although the super class has the method, it was overridden in the subclass.
In my solution code, overriding was used to override the Login method in the parent class User with the
Login method in the other child classes.
Page 33 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
D. Packages
In Java, packages are used to group related types (classes, interfaces and annotations) which provide access
protection and name space management thus leads to preventing naming conflict, control access and make
searching and using classes, interfaces and annotations much easier (Tutorials Point, n.d.).
In my solution code, Packages were used to collect Classes in Classes package, and all GUI interfaces in
the gui package.
package classes;
package gui;
Page 34 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 35 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Best Practice: Design Patterns evolved over the past 40 years which led to provide the developers
with the best solutions for any specific problems. (Tutorials Point, n.d.)
Standard Platform for the Developers: Design Patterns provide standard and unified common
template which are specific to a particular scenario (Tutorials Point, n.d.).
Page 36 of 46
CT038-3.5-2
Individual Assignment
CT038-3.5-2
Individual Assignment
Singleton Pattern is one of the simplest design patterns, and it involves only one class that is responsible of
instantiating itself for two reasons. The first reason is to ensure that only one instance or object of the class
is created which is essential when only one object is needed to coordinate actions throughout the system,
while the second reason is providing a global point of access to the instance or the object (OODesign,
n.d.).
B. Factory Method Pattern
Factory Method Pattern or known as Virtual Constructor is another pattern of the creational category
patterns and it is designed to replace the class constructors and abstracting the process of object generating
thus leading to determine the type of instantiated object at run-time (Code Project, n.d.).
In another words, Factory Method Pattern defines an interface to create an object, and leaves the object
type to the subclasses, thus in run-time the creation defers to the type of object according to the subclasses
needs (OODesign, n.d.).
C. Facade Pattern
In general Facade or Faade means an exterior side of a building; the word comes from the French
language in which it means frontage or face. In Design Patterns, Facade or Faade Design Pattern is a
software design pattern under the Structural Patterns category and it is mainly designed to hide the
complexity of a system by adding and providing an interface to the client in which the client access the
system through the interface (Tutorials Point, n.d.).
Faade design pattern is usually used by software developers when an easier, unified and a simpler
interface are required in order to hide the system complexity from the users and make it easier to be used.
D. Composite Pattern
Composite Pattern in Software Design Patterns is another pattern under the Structural Patterns category.
The Composite Pattern used when a need to handle a group of objects as the same way as we handle a
single object. It composes objects into tree structure to represents both the part and the whole hierarchy
(Tutorials Point, n.d.).
E. Observer Pattern
Observer Pattern in Software Design Patterns is one of the behavioral category patterns and it is used
whenever there is one to many relationships between objects in order to notify the dependent objects
automatically whenever any object is modified (Tutorials Point, n.d.).
Page 38 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Software Reusability: Patterns promotes software reusability as the pattern is designed and
created once but used and reused many times. Thus reducing production costs and saves a lot of
time by eliminating redesign (International Business Machines Corp. (IBM), 2004).
Limitless: Patterns can be shared within a project, within a company or across many companies.
There are no limitations on patterns except on how the pattern was designed and the intention of the
pattern creator (International Business Machines Corp. (IBM), 2004).
Expert Knowledge: Patters captures the expert knowledge and design logic and makes it widely
available through different patterns (Gamma et al., 1994).
Ease Object-Oriented Transition: Design Patterns helps developer to ease the transition from
structural programming concept to Object-oriented programming concept (Gamma et al., 1994).
Complexity: Implementing Design Pattern solution within a system is known to be difficult and
add complexity to the system code thus requires the knowledge of an expert software developer
(Gamma et al., 1994).
Memory Consumption: Design Patterns offer generalized format design as a solution, thus
consumes a lot of memory during the runtime (Gamma et al., 1994).
No Pattern Testing Methodology: All Software Design Patterns have no automated testing
methodology but can only be validated and discussed by experienced experts (Gamma et al., 1994).
Increase Source Code Size: implementing a design pattern adds indirect amount of code which
can lead to an increased Source Code Size (Gamma et al., 1994).
Page 39 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
8.9. Which Design Pattern Suit the EIIMS Study Case and Why?
In my opinion, choosing a design pattern that could fit into the Electrical Constructions Company InspectRicals software system solution is a bit tricky. Nonetheless if I were a Software Engineer I would choose
one design pattern and implement it fully within the Inspect-Ricals software system solution.
The obvious pattern I would choose is the Facade or Faade Design Pattern. From the Faade Design
Pattern description that was written above, what Facade Design Pattern used for is hiding the complexity
of a system by adding and providing an interface to the client in which the client access the system through
the interface (Tutorials Point, n.d.). Assuming that the Electrical Constructions Company staffs are nontechnical, an easier, unified and a simpler interface is required in order to operate the software system.
Thus implementing the Facade design pattern will provide that easy, unified and simple interface.
The Faade Design Pattern could be used to create an interface called Users, and then create concrete
classes implementing the Users interface. These classes are AdminUser, ClerkUser, EngUser and
ManagementUser. After that create a faade class to have the users login, below is a class diagram and
sample code illustrating the point:
Page 40 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 41 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 42 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Step 4: Use the UserLogin facade class to allow various user login.
Results
Page 43 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
9. Conclusion
In conclusion, the assignment consists of documentation and an application system. The documentation
consists of two parts; the first part is the Description, Justification and Design of the System, which
contains a detailed description of EIIMS system logical designs that includes Use Case Diagram and
descriptions, Activity Diagram and Class Diagram. The second part consist of an Advance research on
Software Design Pattern and its usage, the advantages and disadvantages of Software Design Pattern,
categories and types of Software Design Pattern and which design pattern will suit the EIIMS case if
implemented.
The application system that was created is a GUI system, built according to the EIIMS case study. The
system comprises from 4 types of users with different access level, these users are Admin, Management,
Clerk and Engineer. The Admin can add and manage users, Management user can view reports and
statistics, Engineer user can view and update their duties as well as generate reports, while the Clerk user
can add and manage new customers, place new order and assign an engineer to the order, edit and delete
orders as well as other authorities such as generate invoice for the customers.
During the coding of the system I faced some problems on how to deal with classes and objects created in
the system, how to pass data and information from one form to another as well as from one method to
another. Faced issues on how to deal with text files, how to read, edit, delete, update and save from and to
text files. Nonetheless, Generating PDF report was the most problematic for me as it is my first time
dealing with PDF reports within the application coding.
However, I learnt some new ways on how to handle files, how to generate PDF reports and most
importantly how to utilize Object-Oriented Programing concepts into creating an application system that is
much more dynamic and maintainable than the normal structural programing concepts. Gained new skills
while doing this assignment such as the ability to implement a singleton pattern in a project and use its
benefits to enhance the project.
Page 44 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
10.Reference List
Page 45 of 46
Asia Pacific University
CT038-3.5-2
Individual Assignment
Page 46 of 46
Asia Pacific University