Joesph
Posts: 1
Nickname: orions2001
Registered: Apr, 2003
|
|
Re: How much testing is too much testing?
|
Posted: May 23, 2003 12:38 AM
|
|
Boss, what you are attempting to do is fantastic. But the way you are trying to achieve your purpose can be made more effecient. I am assuming that you are using JAVA. Put the entire 3 lines of the code in a try...catch block, and then handle the error. JAVA gives this unique facility so that the developer can catch errors, without having to resort to if and while conditions. Another benefit will be, your code will not catch runtime errors. but a proper try...catch block will, provided you catch the error
Try using try...catch
Bye > Hi, > > I am slowly but surely evolving my programming technique. > Lately I have been "bulletproofing" my code for mission > critical projects. Now, does everyone turn 4 line's code > into a 40 line's code by adding error checking? > > Every open source project I see (I read a lot of source) > has very little error checking... > > let me give an example: > > ************************************ > String string = getStringOffUser(); > > File file = new File(string); > > doSomethingWith(file); > ************************************ > > 3 lines of simple code. > > this could turn into: > > String string = getStringoffUser(); > > if( string == null ){ > erorr : { > logger.log... > show error to user > do something to resolve error > return something; > } > } > > if( string.trim().length() == 0 ){ > error; > } > > File file = new File(file); > > if( file.exists() ){ > error; > } > > if( file.canRead() ){ > error; > } > > etc etc... > > does anyone else do this or am I by myself? > > Joe Cole
|
|