aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes add, modify and delete in data class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "add, modify and delete in data class" Watch "add, modify and delete in data class" New topic
Author

add, modify and delete in data class

Rudy Yeung
Ranch Hand

Joined: Dec 27, 2000
Posts: 183
According to the specification, we only need to implement the flight booking, meaning that we need to apply a write lock to the modify method provided in the data class. As the specification does not mention that we need to implement the adding and deletion, I think we just leave the add and delete methods as they are. However, I understand that these two methods also require a write lock or else the database may be corrupted. Do we really to take care of the add and delete methods in terms of locking and unlocking?
Sam Wong
Ranch Hand

Joined: Dec 07, 2000
Posts: 133
My opinion is that it wouldn't negatively affect your grade regardless of whether you support add/delete. Perhaps, someone who has completed their SCJD can shed some light on this.
Sam
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Well, it's true that you will probably need lock and unlock for add and delete methods. But they are not needed for the assignment, at least not for my requirement.
Besides, if you need to implement add, delete functionalities, you should add a method similar to booking, and let that emthod call the lock and unlock.
Rudy Yeung
Ranch Hand

Joined: Dec 27, 2000
Posts: 183
Adrian and Sam,
If that is the case, you apply a collection API, say the hash table, only to the modify() method, but not the add() and delete() methods. The hash table is for keeping trach the lock and unlock state of the records. Is that true to you?
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Yes, I use similar technique.
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
I see that the add/delete methods seems more like an administration tool as far as this application is concerened more than a real tool. However, I see that after adding/deleting a record, the record count is not increased or decreased by 1. It seems to be the one that is used at startup. A bit strange.
In a future scenario, User A requests lock on DB, User B request lock on DB, User C requests lock on DB. Lets assume that the locks will be served in the order A, B,C . A and C seek to modify the database while B is going to remove the same very record. How is the database going to handle this scenario???


Never be satisfied with anything less than the best and you will surely pass the test...
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17234
    
    1

I didn't touch add or delete. I think it was there for the older version of the assignment when you had to create a conversion program to put a text file of data into the db.db file.
I did not lose any points for not touching it.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Rudy Yeung
Ranch Hand

Joined: Dec 27, 2000
Posts: 183
Kalichar,
Vow!! You replied my mail that was posted almost a year ago. Referring to the scenario you mention, I think it will never happen if your locking mechanism is in a synchronized block or method. In this way, only one client can be granted the lock and have the only access to the database or record locked at any time.
Good luck,
Rudy
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
I do understand that but what I am referring to is A gets lock does modification and unlocks, B gets lock does modification, releases lock, C gets lock modify??? The record it is searching for is gone, the record count is not updated...whats up....
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: add, modify and delete in data class
 
Similar Threads
add, delete and modify
record lock & lock timeout
record lock&unlock
Help on Threadsafe requirement
Hopefully my final design, comments welcome