Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Since your code performs a data base operation, the cost of this operation is likely dominating the execution time. The cost of both a return or an exception may be negligible compared to that ope...
Answer
#1: Initial revision
Since your code performs a data base operation, the cost of this operation is likely dominating the execution time. The cost of both a return or an exception may be negligible compared to that operation. For example, assume your data base operation takes 6ms, the return takes 1ns, and the exception is 30000 times more expensive than the return. Then the exception still requires only 30µs. With return your total execution time will then be 6.000001 ms and with exception the total execution time will be 6.03ms. Compared with the 6ms you will barely notice a difference.