| Author |
Is this a good coding practice?
|
Rajesh So
Ranch Hand
Joined: Oct 08, 2002
Posts: 111
|
|
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
Ranch Hand
Joined: May 27, 2002
Posts: 54
|
|
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
|
 |
 |
|
|
subject: Is this a good coding practice?
|
|
|