Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

which functions are actually used by the client?

 
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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...
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct
 
Ranch Hand
Posts: 590
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic