Correct handling of return data
Posted
by
Serhiy
on Stack Overflow
See other posts from Stack Overflow
or by Serhiy
Published on 2011-02-07T14:54:16Z
Indexed on
2011/02/07
15:25 UTC
Read the original article
Hit count: 212
Hello,
I have a question related to correct handling of returns of the DAO library I'm writing for one project. This library probably is going to be used by another people and I want to do it correctly. So I would like to know, how I should deal with return statements of the functions of my DAO.
Example 1 I have function to getCustomer which should return String. In case query doesn't return any result should I return null, empty string or throw some kind of Exception?
Example 2 I have function getCutomerList which return ArrayList. In case query doesn't return any result should I return null, empty ArrayList or throw some Exception?
Example 3 Some sql exception was detected, what should I do: throw exception or do try..catch of the block where it can occur?
What is the "good" practice or "best" practice to apply in my case?
Thanks on advance, Serhiy.
© Stack Overflow or respective owner