Wednesday, 18 February 2004

Throws Throwable

Looking at badly written code usually pisses me off. That's simple, and true for most people who probably have to read it. There's this one class that I am going through so that I can try and figure out how they used JavaMail and every method they have looks like this:
public void methodName() throws Throwable
Ahhhggg!!! And they just catch Throwable at different points. I have no idea what exceptions they are using and it's very hard to figure out how things are supposed to go. Exceptions and errors are definally something that I will have to work at. I think that when I was working on audioman I used exceptions all the time after checking pramaters etc. I don't think that was a smart idea for methods in a class. From what I was reading in Effective Java, you should use asserts on non-public methods. That's smart, but I just don't know how to test that sort of thing. I always thought of asserts to test the state of an object, but they also have things like IllegalStateException (since 1.1). I don't know when asserts came in, but I think that they are newer than Junit. In a way, it's starting to be a bit of a mess, but I can see why they are going to have a hard time in getting rid of things like that. We'll see how well they are going to be at making the language nice and lean. ;-)
Listening to: Foo Fighters - Low


No comments:

Post a Comment