• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

checking for available records for booking

 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

My assignment B&S says that a record can be booked when the owner field is empty.

where do we have to check whether the owner field is empty or not at the
client side or server side

Currently I am checking this in the business method (bookContractor)at the server side:


pseudocode
bookContractor(customer id, recordNumber) throws SecurityException{
1. if( isBooked() )throw SecurityException;
2. lock
3. read record
4. update
5. unlock
}

Or should we just check this at the GUI layer(client side) by getting the owner id from the TableModel and prevent the calling of business method bookContractor.

How did you approach this?
[ May 07, 2008: Message edited by: Mary John ]
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Mary. Long time no talk!
I think the best approach is to check both on the GUI and in the business layer. That's what I did.
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mary John:

where do we have to check whether the owner field is empty or not at the
client side or server side


I just decided to check only at the server side, because that's the only place you can be sure that the record is up to date.

And one check seems enough to me. There is a small risk that the user is so stupid to select a record of which it is clear that it is already booked, and in this case we have some network traffic that could have been avoided. Not a big problem, I think.

Rinke
 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roberto, Rinke.
So I guess its just a choice to go with what you think is right. I think
doing this at the server side is anyway essential, doing this at the GUI can be just an extra check with which we can prevent unnecessary network traffic of calling and reading the datafile.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the best place to check this is in the business layer. This is an operation to be executed in the business layer, not in the persistence layer. Everything must be handled correctly before it achieves the server. If you implement your business method correctly (locking a record, then checking if it is still available for booking), then there's no need to check it in the server side (which I think is wrong).
That's how I did, and I think I reached a very clean design, which junior developers won't have any big work to understand.
That's my opinion. I'm already done with the code, so now I have to work on the documentation. It's thursday 11:59PM here in Brazil now, so I hope you guys have a good night, and I'll stay here "having fun" with the documentation!
 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto

I think I didnt make myself clear, I agree with your point of checking the
availability at the business layer. that is what I have done too. But
I suppose I am not wrong in saying that my business layer is on the server, because my client is a thin client and it is supposed to call the
business methods by RMI.

So thats why I said that the checking of availability should be done on the server side (precisely, at the business layer which is on the server)
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, right! You indeed said that your business layer is on the server side. It's just that I implemented my business layer on the client side.
Well, if your business layer is on the server side, than it is correct to say that this verification should be done on the server side.
[ May 09, 2008: Message edited by: Roberto Perillo ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic