You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Andreas Hartmann <an...@apache.org> on 2003/08/08 12:19:23 UTC

Programming Style Issue

Hi Lenya developers,

there's a somewhat strange snippet in DublinCore.java.
Maybe it's just for debugging, but if not, I would suggest to
think it over:

     public String getSubject() throws PublicationException {
         return getDCNode("subject");
     }

     private String getDCNode(String node) {
         try {

             [...]

             } catch (Exception e) {
                 string = "";
             }
         } catch (Exception e) {
             string = e.toString();
         }

         return string;
     }

Obviously, exceptions are "eaten" and the exception message
is used as return value.

Aside from there's no javadoc explaining this behaviour,
exception handling is used for control flow which is generally
not recommended (see e.g.
http://c2.com/cgi/wiki?DontUseExceptionsForFlowControl)

Andreas



---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org


RE: Programming Style Issue

Posted by Robert Koberg <ro...@koberg.com>.
Hi,

How do you break out of a SAX parse when no more information is required? I
think this is the one exception, right?

Best,
-Rob

> -----Original Message-----
> From: news [mailto:news@main.gmane.org] On Behalf Of Andreas Hartmann
> Sent: Friday, August 08, 2003 3:19 AM
> To: lenya-dev@cocoon.apache.org
> 
> Hi Lenya developers,
> 
> there's a somewhat strange snippet in DublinCore.java.
> Maybe it's just for debugging, but if not, I would suggest to
> think it over:
> 
>      public String getSubject() throws PublicationException {
>          return getDCNode("subject");
>      }
> 
>      private String getDCNode(String node) {
>          try {
> 
>              [...]
> 
>              } catch (Exception e) {
>                  string = "";
>              }
>          } catch (Exception e) {
>              string = e.toString();
>          }
> 
>          return string;
>      }
> 
> Obviously, exceptions are "eaten" and the exception message
> is used as return value.
> 
> Aside from there's no javadoc explaining this behaviour,
> exception handling is used for control flow which is generally
> not recommended (see e.g.
> http://c2.com/cgi/wiki?DontUseExceptionsForFlowControl)
> 
> Andreas



---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org