This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes which functions are actually used by the client? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "which functions are actually used by the client?" Watch "which functions are actually used by the client?" New topic
Author

which functions are actually used by the client?

Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170


as i understand from the specifications, the client can only book a room.
the functions to add, delete and create rooms are never used.
(there's really only 2 buttons in the GUI? "search" and "book"?)

moreover, there's not any requirement to have an "unbook" option.
(that lead to something funny: when a thread is locked waiting for a record
to be free it's wasting its time. the only time locking occur is for booking a
record and no matter what happens, the record will be already booked when
the thread resume...)

N.B.
there are no difference between standalone and client mode according to
the specifications...


SCJP 5, SCWCD 5, SCBCD 5
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5451
    
  13

You are correct


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Jonathan Elkharrat wrote:
moreover, there's not any requirement to have an "unbook" option.
(that lead to something funny: when a thread is locked waiting for a record
to be free it's wasting its time.


Hi Jonathan, just wondering what you mean by the thread is wasting its time when waiting on a record to become free?


SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

i meant you could* already return with a "recordNotAvailable" or something like that,
because the only operation that lock the DAO is booking and since your thread is
locked because another thread is using that record, you already know it'll book it.

*of course you wouldn't do that because the specifications explicitly said to use the
waiting mechanism. if it was in real life that would be a waste of time...


another way to remove the need of lock/unlock (but NOT approved by the spec, of course) would
be to synchronize all writing method in the DAO class.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2266
    
    3

Jonathan Elkharrat wrote:i meant you could* already return with a "recordNotAvailable" or something like that,
because the only operation that lock the DAO is booking and since your thread is
locked because another thread is using that record, you already know it'll book it.


Interesting thought. On one hand, yes, you are correct. On the other hand, despite of instructions or anything else, the lock method would be doing more then it should. Also, let's say that, for some reason, after 2 months the project was delivered, the read method also required the lock method to be used. This would mean that the record would be still available even after it was locked. This would mean that you would have to change the find method (this would be a normal change) and also the lock method to not throw a RecordNotFoundException if the record to be read is locked (this wouldn't be necessary if the method had been correctly coded). So, despite of instructions or anything else, this wouldn't be a good thing simply because the lock method would be doing more than it should.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which functions are actually used by the client?