This is one of the code piece, where the method has a series of steps to be performed. The successful execution of the first step is a prerequisite for proceeding with the second step. If there is a failure in step 1, the control should reach the end of the method and continue further.The steps continue this way. The reason for the failure of a step is to be noted in 'valueForReport'. With this in mind, I have used 'success' as a marker for proceeding through all the steps. Please tell if this way of coding is right/advisable/ideal. If not, how should this situation be handled. I face this kind of situation in my regular work too and hence your suggestion will be very useful. Thanks in advance, Rajesh
Marcel de Jong
posted 13 years ago
Hi, I would write that piece of code like this:
Where the method findFlightUtil(criteria, modelName) throws a DataNotFoundException, or another user defined exception. In this way you don't need you success variable and in my option its more readable. Regards, Marcel
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads