Does overuse of Checked exceptions really annoy you?

Im a big advocate for using Runtime exceptions for programming errors (e.g, violations of pre-conditions etc).
I find it really annoying when checked exceptions are overused to 'enforce you to do something about your programming error'.
Ive been on projects where an underyling 'untrust' of some developers ability to read an API to obtain pre conditions has led to a prolification of checked exceptions in central APIs.
e.g, Im a strong beliver (as I expect most are), that this is correct:
if(myContainer.contains(someKey)) {
  // Throws 'NoSuchObject' which is a RuntimeException if not contained
  myObject = myContainer.getSomeObject();
}and that this is not:
  if(myContainer.contains(someKey)) {
    try {
      myObject = myContainer.getSomeObject();
    catch(NoSuchObjectException) {
      // Typical 'This Cant Happen' comment (uurrgghhh...)
  }This basically comes from tech-leads having a lack of trust in the ability of some developers to unit test their classes properly.
However, it leads to absolutely horrendous code!
Has any one encountered this anti-pattern on their projects?
And what Im alluding to.... Has anyone managed to come up with a completely convincing argument to remove it?

There's a place for checked exceptions, but not usually for programming errors. That's why NullPointerException is unchecked. But checked exceptions for catching things beyond the programmer's control can also run amuck. Here's an example of code I have in production:try {
  dq.write(translator.toBytes(s));
} catch(IllegalObjectTypeException _ex) {
  throw new ScannerException(_ex.getMessage());
} catch(InterruptedException _ex) {
  throw new ScannerException(_ex.getMessage());
} catch(IOException _ex) {
  throw new ScannerException(_ex.getMessage());
} catch(AS400SecurityException _ex) {
  throw new ScannerException(_ex.getMessage());
} catch(ErrorCompletingRequestException _ex) {
  throw new ScannerException(_ex.getMessage());
} catch(ObjectDoesNotExistException _ex) {
  throw new ScannerException(_ex.getMessage());
}The "dq" variable refers to a DataQueue object from IBM's JTOpen product for AS/400 connectivity. Okay, there's a lot of things that could go wrong in this case, but in practice everybody is just going to log the fact that something went wrong and shut down. Six different exceptions is just overkill -- I suppose I could just catch Exception but that isn't a good practice either.

Similar Messages

  • HT3678 everytime I open qt pro i have to enter the registration code. This is really annoying. Does anyone know how to rectify this problem?

    everytime I open qt pro i have to enter the registration code. This is really annoying. Does anyone know how to rectify this problem?

    This procedure will check for files in your home folder that are locked or have a wrong owner. It makes no changes and will not, in itself, solve your problem.
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ If you’re running Mac OS X 10.7 or later, open LaunchPad. Click Utilities, then Terminal in the page that opens.
    Drag or copy — do not type — the following line into the Terminal window, then press return:
    find . -flags +uchg,uappnd -o ! -user $UID
    The command may take a noticeable amount of time to run. Wait for a new line ending in a dollar sign (“$”) to appear.
    Post any lines of output that appear below what you entered — the text, please, not a screenshot.
    If any personal information appears in the output, edit before posting, but don’t remove the context.

  • HT1632 I can view a workout on my ipod touch history, but not in itunes or on nike+ website.  I can't seem to upload this run and it's really annoying as I'm loosing about 12k of runs.  It seems to happen when I program in a custom run.  Can you help?

    Hi there,
    I have just done a custom run on my Ipod touch 2nd Gen of 12k.  When I finished the run is appearing in my run history on my iPod touch, however it is not appearing in my itunes 'Nike+' tab, or on the Nike + website.  I can't seem to get this run to sync and it is really annoying because I'll be loosing 12k.  Can anyone help or has experienced this before?  I know there are solutions to add runs to iPod nano's and older iPods using the 'Enable disk' and iPod_control function however from what I'm aware you cannot do this on an iPod touch.  Can anyone please help?
    Many thanks
    Phil

    You should really read the manual.
    "How do you restore from backup? "
    Restore.  When given the choice, choose to use backup.
    "And how can I check to see if the pics and videos are on my computer somewhere first??"
    They would only be where you put them.  What program did you use to import them?  Pics/vids taken with ipod are not part of the sync process at all.  You should be importing them just as you would with any digital camera.
    If you did not import them, then they are not on your computer.

  • The system doesn't recognize or capitalize the word (I) or the first word of every sentence. Another really annoying thing about the integrated mail on your Mac computers is the fact that the system learns the word as you type it more and more instead of

    The system doesn’t recognize or capitalize the word (I) or the first word of every sentence. Another really annoying thing about the integrated mail on your Mac computers is the fact that the system learns the word as you type it more and more instead of highlighting it as incorrectly is this is a word that’s being misspelled. Can Apple fix this bug to make it user friendly as if you were using Office or a Word Document?

    You hit the target CT.
    It’s only fair that if Apple is going to integrate Mail into Mac PCs, it would be nice if the system does it for you like Office or perhaps Outlook. I just don’t to use Outlook although I have it installed and ready to use, but instead use Mail which comes with Mac OS already.
    I hope to make some sense here.

  • All my episodes on my ipod touch are out of order, they are in alphabetical instead of episode number. Its really annoying. How do you fix it?

    After i upgraded to iOS 6 my ipod touch has been putting all my tv shows episodes in alphabetical order instead of episode number order. I have tried a few things to put it back to normal but they just wont go back into the right order. Its really annoying if i am starting to watch something and then want to go onto the next ep on my ipod and its really annoying having to go through around 20 eps to find the next one.. Its the same on my brothers ipad. Except they dont have the episode numbers on them at all. If anyone has a solution on how to fix this it would be great. I might end up going to apple and asking myself when i get my ipad to show them excatly. If its a bug in the iOS it really needs to be fixed.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?

  • Why does my HP G62-A25EO lags on starcraft 2 its really annoying?:(

    why does my HP G62-A25EO lags on starcraft 2 its really annoying?

    Monkemackan, welcome to the forum.
    The normal reason for games lagging is one of three components:
    1) CPU
    2) Memory
    3) Video device
    In your case, the memory should be fine.  It is no doubt either the CPU or video device.  My suspicion is that it is the video card.  I suggest looking at the Windows Experience Index in the Control Panel / Performance information and tools.  I suspect that the video card will have the lowest rating.
    Have you tried running the game on lower settings; low-medium or lower?  This may help the lagging.
    Please let us know if this solves your problem or not. 
    Signature:
    HP TouchPad - 1.2 GHz; 1 GB memory; 32 GB storage; WebOS/CyanogenMod 11(Kit Kat)
    HP 10 Plus; Android-Kit Kat; 1.0 GHz Allwinner A31 ARM Cortex A7 Quad Core Processor ; 2GB RAM Memory Long: 2 GB DDR3L SDRAM (1600MHz); 16GB disable eMMC 16GB v4.51
    HP Omen; i7-4710QH; 8 GB memory; 256 GB San Disk SSD; Win 8.1
    HP Photosmart 7520 AIO
    ++++++++++++++++++
    **Click the Thumbs Up+ to say 'Thanks' and the 'Accept as Solution' if I have solved your problem.**
    Intelligence is God given; Wisdom is the sum of our mistakes!
    I am not an HP employee.

  • HT1918 I have opened my account on my credit card and there has been 3 payments go from my account. 17.49 and then day before 5.49 and 4 days before 4.99. Really annoyed that apple can let this happen and letting app makers con people by doing this. Anapp

    I have opened my account on my credit card and there has been 3 payments go from my account. 17.49 and then day before 5.49 and 4 days before 4.99. Really annoyed that apple can let this happen and letting app makers con people by doing this.
    Don't know how this has happened, would like a refund what is the procedure.

    You haven't bought any items, including in-app purchases within apps and/or auto-renewing subscriptions ? You can view the purchase history on your computer's iTunes : http://support.apple.com/kb/HT2727
    If you haven't made any purchases, and nobody else has access to your account or devices and may have made them, then you can contact iTunes Support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Does any one know a good package with checked exceptions?

    Hey,
    Today in a place that i work there is a lot of use in checked exception and there is no good reuse in exception. For each case a new check exception is created.
    i want to eliminate the checked exception types in the system, so i want to recognize the common cases of checked exceptions like :
    Required
    Validation and etc
    The best will be to find a package (like jackarta) that has those common cases or any other good reference in order to get ideas.
    Thank you

    AvihaiMar wrote:
    they are not sufficient
    i excpect from exception like validation exception to have the following fields (some of them optional):
    class name
    field name
    given data
    expected value
    additional information
    i am looking for any framework that already did this job.
    That really looks like a system that doesn't understand the difference between exceptional states and normal error conditions to me.
    If a user enters 13 for the month in a date field that is NOT an exception. Users are expected to enter invalid data. Thus it is not exceptional.
    Conversely if your GUI client is sending data to the server then the server should not, normally, expect to see a 13 for the month. It might happen but it should be so rare that it should not require anything different than if a order request came in which didn't actually have any items in it (substantially different type of exceptional situation but still something the server would not expect.)
    Now there are situations where you might, as a matter of convenience choose to use exceptions (as a class) to handle normal conditions. However such exceptions should be specific to a layer if common and very uncommon if they cross layer boundaries. And those specific to a layer are unlikely to have the same properties of those in another layer.
    This of course is applicable to an application of which most software is in the world and thus most programmers would be working on that.
    If you should find yourself in the unique position of being a library developer then a modified position would be required. A library developer is NOT someone who creates a 'library' for an application. Instead it is someone who delivers as a final product code that is ONLY intended to be used in other applications and only when there is more than one application.

  • My Mac book pro keeps saying "connection time out occurred" I have a 2011 pro with all the latest updates. It keeps doing it and it really annoys me! Please help!

    My Mac book pro keeps saying "connection time out occurred" I have a 2011 pro with all the latest updates. It keeps doing it and it really annoys me! Please help!

    Take each of the following steps that you haven't already tried, until the problem is resolved.
    Step 1
    Restart the router. Many problems are solved that way.
    Step 2
    Change the name of the wireless network, if applicable, to eliminate any characters other than letters and digits. You do that on your router via its web page, if it's not an Apple device, or via AirPort Utility, if it is an Apple device.
    Step 3
    From the menu bar, select
     ▹ System Preferences... ▹ Network
    Click the Assist me button and select Assistant. Follow the prompts.
    Step 4
    Back up all data.
    Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
    Enter the name of your wireless network in the search box. You should have one or more "AirPort network password" items with that name. Make a note of the name and password, then delete all the items. Quit Keychain Access. Turn Wi-Fi off and then back on. Reconnect to the network.
    Step 5
    You may need to change other settings on the router. See the guidelines linked below:
    Recommended settings for Wi-Fi routers and access points
    Potential sources of interference
    Step 6
    Make a note of all your settings for Wi-Fi in the Network preference pane, then delete the connection from the connection list and recreate it with the same settings. You do this by clicking the plus-sign icon below the connection list, and selecting Wi-Fi as the interface in the sheet that opens. Select Join other network from the Network Name menu, then select your network. Enter the password when prompted and save it in the keychain.

  • The "Pin as app tab" produces tabs that do not persist across sessions. I have this problem on two installations, and it's really annoying (since the Permatab Mod no longer works in Ff4). Can you offer any assistance?

    The "Pin as app tab" produces tabs that do not persist across sessions. I have this problem on two installations (PC and laptop, both running Win7), and it's really annoying (since the Permatab Mod no longer works in Ff4). Can you offer any assistance?

    App tabs and Tab Groups (Panorama) are stored as part of the session data in the file sessionstore.js in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder]
    * http://kb.mozillazine.org/Session_Restore
    Make sure that you do not use [[Clear Recent History]] to clear the "Browsing History"

  • Small problem really annoying! Reinstall does not fix issue!!

    Hi there Small problem really annoying! Reinstall does not fix issue!!
    The Next button when on Taskbar is showing back!
    Weird but really annoying!!
    Windows 8.1 64 AMD Quad Core Black

    Nothing no help?

  • Im just really annoyed.  I turned off my data when I barely went over at 4.004 before I went to bed. I just recently checked it to make sure it wasnt using data, But it had gone up to 4.037, after my data had been turned off.  So I want to know what the d

    Im just really annoyed.  I turned off my data when I barely went over at 4.004 before I went to bed. I just recently checked it to make sure it wasnt using data, But it had gone up to 4.037, after my data had been turned off.  So I want to know what the deal is because thats bogus.

    No need to worry jsanders9! We would be delighted to clarify. Please keep in mind that data usage can be delayed for up to 48 hours. To get the most up to date usage we recommend dialing #DATA send from your VZW device, thanks!
    MatthewS_VZW
    Follow us on Twitter @VZWSUPPORT

  • Why does the IPhone 4 get really hot, when you are making a phone call??

    I can't seem to find the answer to this riddle . why does the iPhone 4 get really hot when you are making phone calls or when using face Time ??

    It doesn't.
    There must be an issue with your iphone.
    Have you tried reset?  Restore?
    Have you made an appointment at the genius bar to have them look at it?

  • Why with the new iOS 7 update does my music rewind a second once I unlock my phone? This is really annoying and they should fix it

    Why with the new iOS 7 update does my music rewind a second once I unlock my phone? This is really annoying and they should fix it

    Start with your finger at the bottom of the screen (about even with the home button) and swipe in an upward motion.  There should be a row of icons at the top of a grey field.  if the quarter-moon icon is bright white, tap it.  If it was (and still is) dark, take the iPhone in to be evaluated by a qualified technician.

  • Why with the last update does the stupid GAMES CENTER always pop up when I want to open a locally stored game?  It is really annoying. I click on 'disable' and it just 'disables' it for that session only.

    Why is the stupid GAME CENTER a popup every single time I try to access a locally stored (and paid for) game application?  It is really annoying! I click on 'disable' and it only disables it for that session. When I come back a while later, the stupid GAME CENTER pops up again....
    this just started with the upgrade to iOS6...

    I share your frustration. Maybe there are more people that really hate what game center has become. Here's my problem: Ok, so when I open the Game Center app it asks me for my password to log in. But when (while "signed out" of Game Center) I open an app (game app) it automatically signs me in without me even putting in a password. So, if I go directly to the Game Center app, I have to use my password to sign in. If I open a game app, I don't need to use my password...I'm signed in without any verification. I now can close the game app, open the Game Center app and BAM!!! I'm signed in, password free. I have searched for a solution to this nonsense of two days. I have tried changing my Game Center ID four times and every time it says, "Welcome back '&&@&!'!" Apple has every freaking app of theirs listed in the support communities but the Game Center app. Why? I am an adult that likes to relax and spend 30 minutes or so playing a game. I could give two flying $&@&s what I the other guy or a 4 year old did yesterday. I want a solution to delete completely or disable this tracking crapware. And the whole signing me in without me giving a password smells really fishy. I bet we will see a lawsuit really soon even if this is fixed. Definitely a security issue at the minimum. 

Maybe you are looking for

  • Unable to get the selected from table when AM Pooling is disabled

    Hi, I have created a EO and VO for EMPLOYEE table and dragged on to pagefragment as ADF table. RowSelection property is set as Single. It is displaying the data in the table. I have written below method which should be invoked on selection of a row.

  • Sending email Notifications from BPM 11.1.1.5+FP

    Hi all, We're trying to send an email notifications from our process but we need to send HTML mails, not just plain text... Any help would be appreciated. Thanks in advance

  • Select lists, Static Assignment Computations

    Hi, I'm using ApEx 4.0.1 on Windows XP Pro SP3. I need to set items default values when the page loads. So I created "Before Header" computations for each item (static assignment). When I run the page, the default values are set, but for select lists

  • Ipod won't update or restore!

    I bought a new iPod 30gb video recently, and I can't do anything on it! I didn't have trouble in the beginning, but now, when I plug my iPod in to my USB port, it is recognized in windows, but not in iTunes. I have followed the steps outlined in the

  • HT201263 Itunes stops working when trying to restore and IPOD touch.

    I have tried the directions on "If you can't update or restore your iOS device" page, but every time I try to restore the IPOD it crashes the program. Any suggestions on how to restore this to factory settings?