2005年7月頃、SJC-Dを受けた人の解答

ドキュメントの部分は満点になったので、ここに残って置いて、参照物になるでしょう。

B&S Book System Design Choice

Contents

Part One : Network Communication : RMI or Sockets.
Part Two : Pattren Design
Part Three: General Architecture Of Solution.
Part Four : GUI Design
Part Five : DataBase Design
Part Six : Locking/Unlocking
Part Seven: Thread Safety
Part Eight: Exception Handling
Part Nine : Other Decisions

===============================================================================
Part One : Network Communication : RMI or Sockets.
-------------------------------------------------------------------------------
1.SOCKETS
-------------------------------------------------------------------------------
Socket is one of the endpoints in a communication link between two programs
and is always bound to a port.
When the server gets the bytes, it’s up to your server code to figure out
what those bytes are supposed to mean.
The client code developer and the server code developer will have to get
together in advance and come to an agreement on what these bytes mean,
in other words, how they’re supposed to be interpreted.

-------------------------------------------------------------------------------
2.RMI
-------------------------------------------------------------------------------
Notes: For the Architecture has restrictions on RMI,
we will focus on RMI over JRMP(not IIOP).
RMI specifically enables Java objects on different machines to communicate
with each other.
One of the motivations behind RMI is for developers to interact with remote
Java objects as if they were local objects.
The protocol is already agreed on by both ends--just objects moving from
one place to another.then the client and server don't even have to do the
serialization/deserialization--RMI takes care of it

-------------------------------------------------------------------------------
3.Compare
-------------------------------------------------------------------------------
Compare RMI and Sockets, i get some ideas as listed:
RMI has following advantages with Sockets:
a.Less code to implement, and is easier to debug
b.Manage Socket communication for programer.
c.Manage threads for programer,we will not worried about thread safe.
d.Good GarbageCollection of lost clients,ie Unreferenced
e.Marshalls objects for programer.
f.Support Dynamic loading of classes.
g.Can change bussiness logic without change anything on the client side
RMI has disadvantages with Sockets:
a.Slower than a well-optimised socket-based protocol.

-------------------------------------------------------------------------------
4.Choice
-------------------------------------------------------------------------------
For The IT director does not anticipate much reuse of the first Java
technology system, but intends to use that system as a learning exercise
before going on to a web based system,I support it's has no mean to do hard
for speed,So the network commnication is RMI.

===============================================================================
Part Two: Pattren Design
-------------------------------------------------------------------------------
1.Factory Pattern
-------------------------------------------------------------------------------
Using DataFactory to contorl the creation of data access object.
The GUI will access database through the same interface in both standalone
and client/server mode.

-------------------------------------------------------------------------------
2.Adaptor Pattern
-------------------------------------------------------------------------------
a.Using DataAdapter adaptes Data (which can access local database file) and
implements the DataInterface.
b.Using DataServer adaptes DataAdapter and implements the
DataServerInterface(which implements the DataInterface).
So,GUI gains access to the database file using DataInterface.

Notes:
There is a choice between wraper Data.java or wrapper remote object,
both are okay to solve problem.
For the interface DBServerInterface is "more detal" than the DataInterface
(DBServerInterface throws java.rmi.remote),if adaptes DBServerInterface,
the RMI error could not be throwed pretty,i decided to wraper Data.

-------------------------------------------------------------------------------
3.SingleTon Pattern
-------------------------------------------------------------------------------
SysProperty which read and write program's configuration file
(suncertify.properties).
It is design by SingleTon Pattern because the configuration is single in
global.

===============================================================================
Part Three: General Architecture Of Solution.
-------------------------------------------------------------------------------
1.Data access
-------------------------------------------------------------------------------
a.Create a DataAccess Object by mode flag.
DataFactory Object
|
|(by mode flag)
V
GUI--->DataAccess Object

b.DataAccess Object
For DataAccess Object must support local or remote mode,it can be well
done by using interface.

DataServer
|
|implement remote interface
V
DataServerInterface <---------------------------------DataAdaptor

In the client/server mode
client part:
DataAccess Object is a remote object that access server database
through RMI.

DataAccess(Remote Object)---------------->DataServerInterface

server part:
Server will access database file through a local DataAccessAdaptor
Object which does wrapper the Data Object.

DataServer --> DataAdaptor --> Data

Notes:Data Object can access local database file.

In the standalone mode
DataAcessor is a DataAccessAdaptor object,which does warpper
Data.java

DataAdaptor --> Data

-------------------------------------------------------------------------------
2.Main Packages:
-------------------------------------------------------------------------------
The whole project compose of the following packages:
suncertify.gui.* define GUI class
suncertify.db.* define data access class
suncertify.system.* define classes ,methods,key,resoures,ie.,
which often used in global

===============================================================================
Part Four : GUI Design
===============================================================================
Notes:
For In the future,Bodgitt and Scarper wants to move into Internet-based
marketing, and hopes to be able to provide their services directly to
customers over the web, i construct the frame without menu just like
the program running in the browser.
-------------------------------------------------------------------------------
1.Server GUI
-------------------------------------------------------------------------------
The Main frame extends JFrame.
In the center of the main frame ,there is a Configuration Panel which
to accepts user's setting and a group of Control button which to change the
stauts of server.
In the left-bottom of the main frame,there is a area which to display
the stauts of server.

-------------------------------------------------------------------------------
2.Client GUI
-------------------------------------------------------------------------------
The Main frame extends JFrame.
In the top of the main frame, there is a Configuration Panel which to
accepts user's setting and a group of Control button which to change the
stauts of client.
In the center of the main frame,there is an Operation Panel which to
search ,book or unbook the required services.
In the left-bottom of the main frame,there is a area which to display
the stauts of client.

-------------------------------------------------------------------------------
3.Standalone GUI
-------------------------------------------------------------------------------
The Main frame extends JFrame.
In the top of the main frame, there is a Configuration Panel which to
accepts user's setting and a group of Control button which to change the
stauts of program.
In the center of the main frame,there is an Operation Panel which to
search ,book or unbook the required services.
In the left-bottom of the main frame,there is a area which to display
the stauts of program.

===============================================================================
Part Five : DataBase Design
===============================================================================
Notes:
The Database Schema does not specify which field is the primary key of
the database ,but the DuplicateKeyException is throws in the data access
interface (DBMain).
-------------------------------------------------------------------------------
1.The Fileds
-------------------------------------------------------------------------------
Field descriptive name Database field name Field type
================================ ==================== ===========
Subcontractor Name name String(32)
City location String(64)
Types of work performed specialties String(64)
Number of staff in organization size String(6)
Hourly charge rate String(8)
Customer holding this record owner Number(8)

-------------------------------------------------------------------------------
2.The Primary Key
-------------------------------------------------------------------------------
For if "owner" filed is all blanks, the record is available for sale
and i design the user can just book or unbook the services in the program,
i define all fileds excepct "owner" filed as union primary key.

===============================================================================
Part Six : Locking/Unlocking
===============================================================================
Notes:
For assuming that at any moment, at most one program is accessing the
database file ,the locking is necessary only in multi-client networked mode.

Locking Scheme:
a.Checks if record is already locked.(Check if it is in the lockedList)
a.1.If record is already locked ,gives up the CPU and consumes no
CPU cycles until the record is unlocked.
a.2.If record is not locked , locks record.(Add it to the lockedList)
b.Operates the record.
c.Unlock the record.(Move it from the lockedList)

===============================================================================
Part Seven: Thread Safety
===============================================================================
Thread safety between the client and server is managed by RMI.
RMI starts new threads for requesting clients as needed.
Database's thread safety is managed by lockmanager,it synchronizes the lock
and unlock method to control the multi-client access the same record at the
same time.

===============================================================================
Part Eight: Exception Handling
===============================================================================
Much of exceptions are kept to be throwed up until the exception arrive GUI,
then ,relative class handles some logical things and GUI will display it if
application needs to do.

===============================================================================
Part Nine: Other Decisions
===============================================================================
1.Using DataServerInterface instead of DBMain
-------------------------------------------------------------------------------
For get more useful methods in client/server mode ,i using
DataServerInterface instead of DBMain.
(Changing the DBMain interface is refused by Sun WorldWide Certification
Team:2005/03/11)


-------------------------------------------------------------------------------
2.The Configable Properties
-------------------------------------------------------------------------------
I wonder Configable Properties by user in two pattern.
Pattern 1:
a.db-file (server/standalone mode)
b.host(client mode)
c.server url(server/client mode)
d.server port(server/client mode)
If Server url or port changed ,system user must notify all users.

Pattern 2:
a.db-file (server/standalone mode)
b.host(client mode)
If port number 1099 is used, start server will meet a error.

Compiling two pattern,I think pattern 1 is easier to change than
pattern 2,but pattern 2 is easier to use than pattern 1.
For i think the usual user is care more about convenience,i decide using
pattern 2.

-------------------------------------------------------------------------------
3.Ignoring Some Button Text In The Common Dialog
-------------------------------------------------------------------------------
I found when i using JOptionPane.OK_CANCEL_OPTION ,i would get BUTTON OK
in english,but cancel in japanese.It seem depend on the OS and Java version,
and i think the program is running on English System,so i iqnore it.
(Confirmed by Sun WorldWide Certification Team:2005/03/11)

-------------------------------------------------------------------------------
4.Encoding
-------------------------------------------------------------------------------
In the instructions.html, the character encoding is 8 bit US ASCII.
However, there is no 8 bit US ASCII and I think it sould be a typo.
Therefore, I used ISO-8859-1 instead of 8 bit US ASCII.

-------------------------------------------------------------------------------
5.Null Termination
-------------------------------------------------------------------------------
All records of data file provided are space-padded but the
instructions.html mentions "all fields...null terminated" and
"without altering the data file format" so there is a conflict.
I think the data file should be valid.
Therefore, in this project, I choose all records are space-padded.
(Confirmed by Sun WorldWide Certification Team:2005/03/10)

コメント

このブログの人気の投稿

Linux(UNIX)、MS-DOS、OpenVMS コマンド対応表

ECスペシャリストに生まれ変われ!