Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XP] Eliminate Exceptions (was: Writing simple software - A Challenge!)

Expand Messages
  • Kyle Cordes
    From: Kevin Smith ... code. ... I d experience significant misery from codes that takes this too far. For example, code that read a
    Message 1 of 139 , Dec 1, 2002
      From: "Kevin Smith" <kevinxp@...>

      > > Well, would you explain more about not throwing them?
      >
      > If exceptions are thrown, then they must be caught. That requires
      code.
      > So, given a chance, write methods that don't throw exceptions. If you
      > can catch an exception and "do something reasonable", that's often
      > better than propagating the exception up the chain.


      I'd experience significant misery from codes that takes this too far.
      For example, code that read a list of widgets from the database
      according to parameters X. The way I code it, if X is invalid, throw an
      exception. If the database doesnt work, throw an exception.

      I've worked with code where these conditions are hidden by code that
      attempts to do something reasonable when the parameter is wrong (or
      null, whatever), when the database fails, etc. This usually results in
      silent failures and great debugging difficulty.

      Thus, I code this way:

      If valid parameters are passed, and underlying infrastructure works, do
      the right thing. If a parameter is bad, throw a meaningful exception.
      If an underlying layer fails, propogate it's exception upward,
      preferabley without munging it along the way.

      Kyle Cordes
      www.kylecordes.com
    • J. B. Rainsberger
      So said ericheikkila on 12/4/2002 -------------------- ... Often, i means something. Say what you mean; mean what you say. :) J. B. Rainsberger,
      Message 139 of 139 , Dec 7, 2002
        So said ericheikkila on 12/4/2002 --------------------

        >Single letter variables drive me nuts. ;)
        >I use 'index' instead of 'i' (or loop, or maybe count, depending on
        >the context).
        >As far as abbreviations go...if the entire team agrees, fine.
        >If someone on the team doesn't know that itr is the same as iterator,
        >just change it to iterator.
        >
        >Usually, I'll not abbrev ;)

        Often, "i" means something. Say what you mean; mean what you say. :)

        J. B. Rainsberger,
        President, Diaspar Software Services
        Let's write software that people understand.
        http://www.diasparsoftware.com/
        telephone: +1 416 791-8603
        All correspondence (c) 2002 Diaspar Software Services.
        If you want to use it, just ask; don't steal.
      Your message has been successfully submitted and would be delivered to recipients shortly.