• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Application Specific Exceptions

 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm trying to implement the 48hrs criteria in the book method of adapter class itself. As I am doing it, I got a couple of doubts.
In the book method of adapter, I'm checking the following on the about-to-be-booked-room.
1. If the record is not present(In case its just been deleted by another thread) -- Throw RecordNotFoundException
2. If room is already booked -- Throws RoomAlreadyBookedException.
3. Next am checking if the room availabe date is already passed -- If so, am throwing TimeAlreadyPassedException.

Ex: Room Availabe: February 3rd, 2004.
Tried to book: Anytime after February 3rd, 2004 00:00:00AM.

4. Next am checking for the date, if its less than 48hrs or not -- If not, am throwing RoomCannotBeBookedException.

Ex: Room Availabe: March 3rd, 2004.
Tried to book: Anytime before March 1st, 2004 00:00:00AM.

5. And finally there is IOException.
So the book method itself is throwing 5 exceptions. I am and I think the evaluator may be more than I am. Is it ok if a method throws 5 exceptions.
The reason why it is throwing is am checking all the constraints on server side(48hrs, recNo present or not, owner present or not, date passed), to say in adapter class only. Also I want to warn the user according to the exception thrown. I can check the date passed and 48hrs on client side, but we cannot trust on client as he can change date on his machine and make us book for wrong date right.
Please comment on this. Thanks.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,
I think it is a normal case since there are several things to check.
On the other hand, if you think there are too much exception, you may consider to throw InvalidBookingRequirementException for all types of errors and identify them with an input string.
Basically, I have not implemented this requirement, and as Vlad said, I document that as a business requirement, and assume that there is another program (since in our system, no one is expected to call create() and delete()) inserting *suitable* data into the data file everyday.
Keep going on what you have, and I think it will be ok. But be sure that you need to check this function carefully due to its complexity.
Nick.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Nick, thanks man
Originally posted by Nicholas Cheung:
Hi Satish,
I think it is a normal case since there are several things to check.
On the other hand, if you think there are too much exception, you may consider to throw InvalidBookingRequirementException for all types of errors and identify them with an input string.

OK. But in that case, the client does'nt know what exactly went wrong right? I think that's ok.

Basically, I have not implemented this requirement, and as Vlad said, I document that as a business requirement, and assume that there is another program (since in our system, no one is expected to call create() and delete()) inserting *suitable* data into the data file everyday.

Yeah, I remember you answered a couple of ranchers that you did not implement 48hrs as its not required, but documented it. Phil was saying that it is not in "must", but in "should" requirements.

Keep going on what you have, and I think it will be ok. But be sure that you need to check this function carefully due to its complexity.

OK Nick. Thanks for the advice.

Nick.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,

OK. But in that case, the client does'nt know what exactly went wrong right?

The client knows! When the system passed the exception to the Controller (I assume you used MVC in the front end), the controller can grep out the message and display to the client.

Yeah, I remember you answered a couple of ranchers that you did not implement 48hrs as its not required, but documented it. Phil was saying that it is not in "must", but in "should" requirements.

I have also confirmed this part with Vlad that both of us have not implemented this, with only documentation. The result turns out that no or less marks is deducted, as I scored 99/100 in my general consideration, and 70/70 in OO.
Thus, if that 1 mark is for this requirement, I prefer giving up this requirement, as you cannot 100% sure what's going on if you implemeted it with some errors that cannot detected by you but by SUN. (Just like my locking part ).
Nick.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nick. I will try to stick with "Phil" and implement some "should" requirements. If it increases complexity, then am with "you" and "vlad".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic