Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Checked exceptions in Java can cause an scalability problem when programmers fail to throw exceptions suitable to the method. (See <em>Effective Java</em>, Item 43: <em>Throw exceptions appropriate to the abstraction</em>).</p> <p>Lazy programmers tend to append exceptions to the <code>throws</code> clause of their method without considering whether they are appropriate. As a result, methods gather increasing numbers of exceptions as you look higher and higher in the application architecture. Top-level methods can throw ten or more exceptions if one is not careful.</p> <p>For instance, in a method designed to encrypt data, many low-level exceptions could be thrown (e.g. <code>IOException</code>, <code>NoSuchAlgorithmException</code>, <code>KeyNotFoundException</code>...). It is not necessary to expose these to an API user. Instead, an <code>EncryptionFailed</code> exception could be thrown, with the gory details stored in the <code>cause</code> field of the exception.</p> <hr> <p>I presume "dynamic exception checking" might refer to catching <code>Throwable</code> or <code>Exception</code> (one of the root classes) and dynamically deciding whether to handle the exception, based on some external stimulus. For example:</p> <pre><code>List&lt;Class&lt;?&gt;&gt; exceptionTypes = new ArrayList&lt;&gt;(); exceptionTypes.add(IllegalArgumentException.class); exceptionTypes.add(IOException.class); try { // do something } catch (Exception e) { if (exceptionTypes.contains(e.getClass())) { e.printStackTrace(); } } </code></pre> <p>Note: the above example is just an illustration. But imagine an IDE that executes code on behalf of the user and allows them to select exception classes they wish to catch.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload