• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

My design choices

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I already passed for this exam and I want to give some hints for you.

Locking: I had 80/80 points for.

I have a LockManager class I implemented record locking and I call that class instance inside my Data class. I call lock/unlock methods only in update and delete methods by the server side.

I have a array of WeakHashMap objects with size as recordcounts.

WeakHashMap[i] i = maxRecNo

In my lock method I do so:


in my unlock method I do so:



GUI DESIGN: lost 20 points
I have not imlemented JMenu and JComboBox. I think (maybe) because of that I have lost 20 points for GUI part.

GENERAL:
I have implemented a new Interface named MyDataInterface and I redefined all methods of my Data class inside and other extra methods like bookRoom ...

I have implemented 2 classes that implements MyDataInterface. 1 class for client side and 1 class for my server side.

I have used Factory pattern to check which interface it must use.

MyDataInterface getInterface(Command arguments)
{
if (clientargument)
return new ClientClass
if (serverargument)
return new ServerClass
}

I hope its clear.

success

Regards

Baris Dere
[ June 23, 2004: Message edited by: Baris Dere ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to know what network connection do you user,RMI or Socket?
When you user local data file ,how do you do that?I mean RMi ,Socket or other idea?


Non-Networked Mode
The program must be able to work in a non-networked mode. In this mode, the database and GUI must run in the same VM and must perform no networking, must not use loopback networking, and must not involve the serialization of any objects when communicating between the GUI and database elements.
The operating mode is selected using the single command line argument that is permitted. Architecturally, this mode must use the database and GUI from the networked form, but must not use the network server code at all.


In network mode,I used RMI.But I do not know how to change the networked mode to non-networked mode

[Andrew: Changed code tags to quote tags]
[ June 23, 2004: Message edited by: Andrew Monkhouse ]
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In design choice document,should I describe all Design Pattern applied in my assignment? could I post some code or UML view to specify my design assistantly?

regards
 
Baris Dere
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kevin:

I used for my assignment RMI.

I have next classes/interfaces: (class names are not exactly so)

- DataMain (interface)
- Data (class) implements DataMain
- MyDataInterface (interface) (exact all methods of DataMain interface with RMIExceptions.
- ServerDataClass implements MyDataInterface.
- LocalDataClass implements MyDataInterface.
- ClassChooser (class with factory method)
- ServerClass (class that returns MyDataInterface object "ServerDataClass implementation")

factory method returns MyDataInterface
if (start argument == SERVER) {
// make connection with the server
// server returns MyDataInterface object
} else {
return a new instance of LocalDataClass.
}


Along:

I didn't send any UML diagrams or something else. But you must describe all designpatterns you used in your code. If you think it is more clearlier to send some UML diagrams, then I say DO IT!

Regards

Baris Dere
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First thank andrew correcting my reply.
Thank baris reply so detailedly.
One question to ask is that in the instructions require to implement DBMain interface.I did so.But I used some methods were not provided in DBMain interface.So I design "Data" not only implement DBMain, also implement a my interface.I used my interface in my project, not used DBMain.Anyone can tell me is there any problem in my design.
Second question is :

Non-Networked Mode
The program must be able to work in a non-networked mode. In this mode, the database and GUI must run in the same VM and must perform no networking, must not use loopback networking, and must not involve the serialization of any objects when communicating between the GUI and database elements.


I used JMenu to receive user's input(db file or host ip).In both non-networked mode and networked mode, i used one set of RMI model and view objects.In the networked mode,i am sure about that serialized objects be transmitted by network.IN the non-networked mode,I get a new db file's instance in my controller, and set the model object to GUI.In this mode,I am not sure about that serialized objects is or not transmitted by network.
My design is right?
 
Baris Dere
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wills,

answer 1
There are many ways to implement your assignment. So if you think your desicion is correct, then you must do that. In my code I also used only my own interface and not DBMain interface to retrieve data from the database(local or server).

answer 2
I implemented 3 classes which implements Serializable interface. I used them everywhere I need. It doesn't mean if you use a serializable object without calling any RMI code it is serialized. Serializing is only done by RMI protocol when that object must be send or received by using by RMI server.

I hope my answer is clear. My english is not so good

success

regards

Baris Dere
 
Wills Ni
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulation!
Thank you !
 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,Baris
I want to know about your design more.
What method is set as synchronized in your system? except for lock() and unlock(). Why don't you set delete() and update() as synchronized?
How do you implement Update operation? could you post the steps?

Furthermore, the method:
public int create(String [] data) throws DuplicateKeyException
it throws exception "DuplicateKeyException", but I think over and over, can't find anywhere should throw the exception.
please give me a idea!

thanks!
 
Baris Dere
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Along,

I used only synchronized blocks in my code and not as method modifier.

I call lock/unlock methods only from the server side and inside update and delete methods. Example:

public void update() {
lock(1);
try {
update();
} finally {
unlock(1);
}
}


I didn't set my update (none) method as synchronized because you must lock that record what must be updated and not whole implementation or whole records. If I use locking calls inside my update method and I set also the method modifier as synchronized then I use locking TWICE. And so it can be happening that you get DEADLOCK because of that.

Update method implementation:

I seek that record (recNo) with dbFile.seek(headerLength + recordLength * (recNo - 1));

then I check this recNo is marked as deleted, if so then throw RecordNotFoundException else continue processing.

With a for statement I make a new String with new values, like so:

String newValue;

for (i=0;i<fieldsCount;i++) {
//copy the value of data[i] to your newValue
// but watch out, each field has own size.
// example:

// the size of the field name in database is 30 characters
// and I give a new value 'Michael'. Then you must fill your new value
// 'Michael' and 23 times white space. I did so.
}

at last dbFile.write(newValue);


In your create method you must do like this:

create(newRecordData) {
// if (newRecordData.name AND newRecordData.location) exists in database.
// then throw DuplicateKeyException.
}

I hope it is clear for you.

Regards

Baris Dere
 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much!

It is important and helpful to me!
 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And you never use cookie,don't you?

but I read some article about locking,most of those concern cookie.

It seem that I don't need to use cookie in my design.

regards
 
Author
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My locking mechanism was similar to Baris'. Call lock/method/unlock on the server only, and the client knows nothing about the cookie. I do use the cookie, however, to conform to the DBAccess interface.

I made a separate client-facing method that doesn't have the cookie business in its signature.

Then I log all such activity so that at the very least it is easy to know if something weird happens.
 
reply
    Bookmark Topic Watch Topic
  • New Topic