Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I handle this scenario in Data class?

 
lambertlee Li
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now I handle the following scenario in GUI layer:

if client A book record 1
then if client B also want to book record 1, I don't allow client B
to book record 1 by disabling the book button.

My question is should I move this checking(if record has been booked) into Data class? I am just scared that the accessor won't test it
from GUI side, but use external tool to call Data class to see
if thread A could overwrite Thread B's booking.

Why I am asking this question is I knew there is
one guy in this forum got 0/80 on locking mechanism just because he put his
thread safety codes on the layer of RMI instead of Data class!
I just scared the accessor will do the same to me if I put this checking on
GUI layer instead of Data class.

Could anyone give some comments? How you handle this?
 
Petr Hejl
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO database layer should not contain _any_ business level rules. Of course it should be thread safe and provide consistent writes and reads. But db does not know anything about real meaning of each field. I guess you mix two things together (thread safety, business rules).
[ September 01, 2006: Message edited by: Petr Hejl ]
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can understand the disabling of a button in the GUI for records that have already been booked, but how would this stop client a and b trying to book an available record at the same time?

As Petr mentioned you need to implement the lock, unlock, update etc methods in the data class, these methods should ensure that only a client that has a lock can update.

Then depending on your requirements and design you might have a business logic tier which would have a book method which preforms the lock, read to check if available, update, unlock.

I think it helps to think of the DBMain interface as a simple database API.

regards
Jason
[ September 01, 2006: Message edited by: Jason Moors ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic