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

(B&S)When Can SecurityException could be thrown in update(),delete(),unlock()?

 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
In my instructions SecurityException should be thrown when the lockcookie is different from the one used to lock the assciated record when trying either to update() delete() or unlock()! I intend to have a business logic and in my book(), i intend to have it call lock(), update() and unlock(). So it is generally accepted that (maybe) no SecurityException should be thrown when the book() is called! Or am i wrong? If i am wrong i would please like a scenario where SecurityException might be thrown in my approach above! Thanks!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saheed,

It might not be possible for SecurityException to be thrown in your implementation of the business logic, but who is to say what will hapen in the future? Some other programmer might modify your code, changing the business logic in such a way that you might need to throw SecurityException. Or some programmer might write a totally different front end that just happens to use your Data class - so you would need to check cookies and possibly throw SecurityException.

It is important to realize that a lot of this certification is not about just writing a simple solution to a given problem. It is about proving to Sun that you are a developer. Which means that you have to write maintainable code, and you have to write full API documentation for it, and you have to write proper user documentation, even though this is never intended to be a real application.

You have to work as though it is something that you have been contracted to develop for a company, knowing that once it has been completed it will be maintained and modified by unknown people. But your reputation is on the line - if you don't do a great job you wont get another contract with them.

So you have to write the Data class such that it meets the stated requirements, even if those requirements do not make sense in your implementation.

Regards, Andrew
 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Ok cool! So it seems like i can decided not to use the SecurityException and document why i didnt and also i can find a way of justifying why i used it and also document it! Am i correct in assuming the above?Thanks
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saheed,

That would depend on your instructions. My instructions only talk about the SecurityException in the required interface (not in the general text), and state that the various methods throw SecurityException if the record is locked with a cookie other than lockCookie.

So from that I take it that in order for me to properly implement the required interface, I must have my Data class throw that SecurityException if the lockCookie doesn't match. That is: the methods of Data class will check the lock cookie, and throw the exception if the cookie doesnt match.

Even though I know that this exception will not be thrown from within Data class with my implementation of the client, I still must write the Data class to meet the provided interface.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic