Women in Technology

Hear us Roar



Article:
  What I Hate About Your Programming Language
Subject:   Java + Exceptions
Date:   2003-05-15 15:40:59
From:   chromatic
Response to: Java + Exceptions

No.


All I'm saying is that sometimes I don't consider certain things exceptional. Java won't let me ignore them. I either have to deal with the exception or let it crash.


I don't like either option. If I know the file's not likely to be there and my program isn't going to crash if it's not there, it's not an exceptional condition. Why do I have to do busywork to make my intent clear?

Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • Java + Exceptions
    2003-05-15 16:42:08  anonymous2 [View]

    Why would you open a file for reading if you don't think it is going to be there?

    If you ask to open a file and it does not exist then, yes, it is an exceptional condition.

    Also if you wrote the code in, say, C and you didn't check the return of fopen you would "need" to put a comment to make the intent clear. Why put a comment that can easily be wrong after modifying the code if the compiler can do it for free?

    Also if you open a file AND it doesn't exist you would need to check that the return value was not null... messy boilerplate code that is easy to get wrong and hides the logic of the program.

    Please give a clear, concise, somewhat complete example of what you are saying you want - to open a file that may/may not exist and have it be fine either way AND detail what you would rather go through than deal with exceptions.