<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>exceptions &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/exceptions/</link>
	<description>Feed of posts on WordPress.com tagged "exceptions"</description>
	<pubDate>Sat, 05 Dec 2009 11:30:45 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Previously Married Persons and Contract of Sale or Lease]]></title>
<link>http://willemsteynproperties.wordpress.com/2009/12/03/previously-married-persons-and-contract-of-sale-or-lease/</link>
<pubDate>Thu, 03 Dec 2009 12:26:51 +0000</pubDate>
<dc:creator>Adminlady</dc:creator>
<guid>http://willemsteynproperties.wordpress.com/2009/12/03/previously-married-persons-and-contract-of-sale-or-lease/</guid>
<description><![CDATA[Anyone who has never married can enter into a contract of sale or lease, provided that he/she is: -N]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Anyone who has never married can enter into a contract of sale or lease, provided that he/she is:</p>
<p>-Not a minor, except for exceptions such as mentioned in Minors and a Contract of Sale or Lease”;<br />
-Not under the influence of alcohol or drugs at the time of conclusion of the contract;<br />
-Not insane;<br />
-Not prohibited from concluding contracts without the assistance of a curator, in terms of a Court Order;<br />
-Not an unrehabilitated insolvent.</p>
<p>Widows, widowers and divorcees have full contractual capacity, except for the exceptions mentioned above. </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[The non-statistic statistic.]]></title>
<link>http://ideapalace.wordpress.com/2009/12/02/the-non-statistic/</link>
<pubDate>Wed, 02 Dec 2009 23:29:03 +0000</pubDate>
<dc:creator>freethinker30</dc:creator>
<guid>http://ideapalace.wordpress.com/2009/12/02/the-non-statistic/</guid>
<description><![CDATA[I think most everyone believes they are the exception to the rule. But, just ask yourself, what type]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I think most everyone believes they are the exception to the rule.</p>
<p>But, just ask yourself, what type of pants do you wear?</p>
<p>Do you wear contacts?</p>
<p>Do you eat at the same time as everyone?</p>
<p>Do you watch any t.v.?</p>
<p>Do you have a mother and father?</p>
<p>Do you have siblings?</p>
<p>Did you go to school?</p>
<p>Do you work?</p>
<p>We all fall into literally hundreds of similar patterns, just like everyone around us.</p>
<p>There are no exceptions, because exceptions themselves fall into a pattern: the pattern of exceptions.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[CRUCERO A LAS ISLAS GALAPAGOS]]></title>
<link>http://cruisestogalapagos.wordpress.com/2009/12/01/crucero-a-las-islas-galapagos/</link>
<pubDate>Tue, 01 Dec 2009 21:06:02 +0000</pubDate>
<dc:creator>cruisestogalapagos</dc:creator>
<guid>http://cruisestogalapagos.wordpress.com/2009/12/01/crucero-a-las-islas-galapagos/</guid>
<description><![CDATA[&gt; RESERVAR AHORA Salidas especiales: Diciembre 7-10 3 Noches/4Dias Desde USD: $ 1,230 Diciembre 3]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://www.kleintours.com/galapagos/lpLastMinute.php?lang=sp"><img src="http://www.kleintours.com/images/banners/anuncio_es.gif" alt="GALAPAGOS CRUISES" width="635" height="152" border="0" longdesc="CRUCERO A LAS ISLAS GALAPAGOS" /></a><a href="http://www.kleintours.com/galapagos/lpLastMinute.php?lang=en"><br />
&#62; RESERVAR AHORA </a></p>
<p><strong>Salidas especiales:</strong></p>
<p><em><strong>Diciembre 7-10 </strong></em><br />
  3 Noches/4Dias<br />
  Desde USD: <a href="http://www.kleintours.com/galapagos/lpLastMinute.php?lang=sp">$ 1,230</a></p>
<p><em><strong>Diciembre 3-7</strong></em><br />
  4 Noches/5Dias<br />
  Desde USD: <a href="http://www.kleintours.com/galapagos/lpLastMinute.php?lang=sp">$1,660</a></p>
<p><em><strong>Diciembre 3-10 / 7-14</strong></em><br />
  7 Noches/8Dias<br />
  Desde USD: <a href="http://www.kleintours.com/galapagos/lpLastMinute.php?lang=sp">$2,890</a></p>
<p>( incluye ticket a&#233;reo desde/hacia las islas ahorre hasta USD 400.00 )</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Issues when trying to access a LINQ to Entity Layer from a WCF Service]]></title>
<link>http://duthiega.wordpress.com/2009/12/01/issues-when-trying-to-access-a-linq-to-entity-layer-from-a-wcf-service/</link>
<pubDate>Tue, 01 Dec 2009 11:46:11 +0000</pubDate>
<dc:creator>Gordon Duthie</dc:creator>
<guid>http://duthiega.wordpress.com/2009/12/01/issues-when-trying-to-access-a-linq-to-entity-layer-from-a-wcf-service/</guid>
<description><![CDATA[Listed below are some issues and solution you may come across when trying access a LINQ to Entity la]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Listed below are some issues and solution you may come across when trying access a LINQ to Entity layer from a WCF Service located in a separate project.</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong><strong>Problem: </strong><br />
</strong>Argument Exception: &#8220;The specified named connection is either not found in the configuration, not intended to be used with the EntityClient Provider, not valid.&#8221;</p>
<p><a href="http://duthiega.wordpress.com/files/2009/12/argument-exception.png"><img class="alignnone size-full wp-image-25" title="Argument Exception" src="http://duthiega.wordpress.com/files/2009/12/argument-exception.png" alt="Argument Exception: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid" width="452" height="265" /></a></p>
<p><strong>Solution: </strong></p>
<p><strong><span style="font-weight:normal;">The class library which contains the EDMX file contains an app.config file with the entity connection string. When access this from the WCF layer, there is no reference to it unless you include it in the web.config of the WCF layer</span></strong></p>
<p>To fix the problem, copy the connection string from the app.config to the ConnectionStrings section of the web.config of the WCF project.</p>
<p>However, on doing this, you may receive another exception message:</p>
<p>MetadataException: Unable to load the specified metadata resource.<br />
<a href="http://duthiega.wordpress.com/files/2009/12/metadataexception.png"><img src="http://duthiega.wordpress.com/files/2009/12/metadataexception.png" alt="MetadataException : Unable to load the specified metadata resource" title="Metadataexception" width="452" height="252" class="alignnone size-full wp-image-29" /></a></p>
<div class="context"> connectionString=&#8221;metadata=res://*/Model.Project.csdl&#124;res://*/Model.Project.ssdl&#124;res://*/Model.Project.msl;
</div>
<p>to</p>
<div class="context"> connectionString=&#8221;metadata=res://*/;</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MVC (model view controller)]]></title>
<link>http://kingring.wordpress.com/2009/11/28/mvc-model-view-controller/</link>
<pubDate>Sat, 28 Nov 2009 04:22:37 +0000</pubDate>
<dc:creator>kingring</dc:creator>
<guid>http://kingring.wordpress.com/2009/11/28/mvc-model-view-controller/</guid>
<description><![CDATA[Yesterday i finished oops basics and its concepts with java basics and exceptions in java, soon i po]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Yesterday i finished oops basics and its concepts with java basics and exceptions in java, soon i post a new page for visitors to know what is oop and java basics that may be a clear view for readers they can easily understand, by today i&#8217;m going to start with MVC~model view controller and somemore in exceptions.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Galapagos Last Minute Departure Deals!!!!]]></title>
<link>http://cruisestogalapagos.wordpress.com/2009/11/27/galapagos-last-minute-departure-deals/</link>
<pubDate>Fri, 27 Nov 2009 16:40:10 +0000</pubDate>
<dc:creator>cruisestogalapagos</dc:creator>
<guid>http://cruisestogalapagos.wordpress.com/2009/11/27/galapagos-last-minute-departure-deals/</guid>
<description><![CDATA[&gt; RESERVE NOW]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://www.kleintours.com/galapagos/lpLastMinute.php"><img src="http://www.kleintours.com/images/banners/anuncio.gif" border="0" alt="BEST GALAPAGOS TRIP" width="635" height="151" /></a></p>
<p><a href="http://www.kleintours.com/galapagos/lpLastMinute.php">&#62; RESERVE NOW </a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[catch InvalidAuthenticityToken Error]]></title>
<link>http://jvnill.wordpress.com/2009/11/26/catch-invalidauthenticitytoken-error/</link>
<pubDate>Thu, 26 Nov 2009 09:16:51 +0000</pubDate>
<dc:creator>jvnill</dc:creator>
<guid>http://jvnill.wordpress.com/2009/11/26/catch-invalidauthenticitytoken-error/</guid>
<description><![CDATA[Experienced an ActionController::InvalidAuthenticityToken error? The following code will catch the e]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Experienced an <code>ActionController::InvalidAuthenticityToken</code> error? The following code will catch the error and redirect to a logout url.</p>
<p><code>ActionController::RequestForgeryProtection.module_eval do</code></p>
<p style="padding-left:20px;"><code>alias :vat :verify_authenticity_token</code></p>
<p>&#160;</p>
<p style="padding-left:20px;"><code>def verify_authenticity_token(*args)</code></p>
<p style="padding-left:40px;"><code>vat(*args) rescue redirect_to logout_path</code></p>
<p style="padding-left:20px;"><code>end</code></p>
<p><code>end</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Exceptions]]></title>
<link>http://amysantidiet.wordpress.com/2009/11/24/exceptions/</link>
<pubDate>Tue, 24 Nov 2009 17:59:34 +0000</pubDate>
<dc:creator>amysantidiet</dc:creator>
<guid>http://amysantidiet.wordpress.com/2009/11/24/exceptions/</guid>
<description><![CDATA[Ok so there will be exceptions. The thing about them though, is that for there to be an exception th]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Ok so there will be exceptions.</strong></p>
<p>The thing about them though, is that for there to be an exception there has to be a rule, and the rule has to be the primary force.   So, you are following the rules right?  That is great.  So when and how do you make exceptions?</p>
<p>I had to make exceptions this week while I was sick.  I couldn&#8217;t eat for days and then when I finally could I still was unable to sit up, so I made an exception to eat in bed, made an exception to eat on the couch (yes in front of the TV) and an exception to eat in the kitchen.  I was just not well enough to follow the rule.</p>
<p>In general I think exceptions should be no more than a 1 to 20 ratio . . . so you go for a week, and only make one exception for not eating at the table.  </p>
<p>As soon as I was able to sit up, I was back at the table.  At first it didn&#8217;t feel right, but now it does again.  It also felt like A LOT of work.  I really did not want to be sitting there, I wanted to just grab and go.</p>
<p>The key I think is to not give myself so many reasons to make exceptions.  I have so many great reasons to not sit down.  So do you I expect.  If we load ourselves up with all the reasons we can&#8217;t sit to eat, or drink water, we won&#8217;t do it, we&#8217;ll just slip back into our crappy habits again.  Then we won&#8217;t see if what we &#8220;know&#8221; we are supposed to do will actually result in eating less and exercising more. </p>
<p>Keep to the rules, make exceptions when necessary but then hop right back on the rule bandwagon.  We&#8217;re going to permanent changes here, not a quick fix, we&#8217;re changing the way we eat one rule at a time.  You can do, it and so can I.   I&#8217;m hoping we are doing it together.</p>
<p>Don&#8217;t slip, keep it up, keep your exceptions &#8211; exceptional.  I haven&#8217;t heard from anyone in a while, so I hope at least a few people out there are still listening.    Spread the word, there was very little activity while I was sick.  Get others to join in.  And, comment &#8211; please?</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[try/catch en C (Exception handling)]]></title>
<link>http://pedorro.wordpress.com/2009/11/22/trycatch-en-c-exception-handling/</link>
<pubDate>Sun, 22 Nov 2009 18:59:43 +0000</pubDate>
<dc:creator>pobre</dc:creator>
<guid>http://pedorro.wordpress.com/2009/11/22/trycatch-en-c-exception-handling/</guid>
<description><![CDATA[Esto no es algo que me divierta de sobremanera, de hecho, me siento bastante boludo al haberlo hecho]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Esto no es algo que me divierta de sobremanera, de hecho, me siento bastante boludo al haberlo hecho, la verdad no era necesario pero bueh&#8217;, lo hecho, hecho está. Necesitaba que queda claro que no es algo que vaya a usar. Pero bien, luego de este preámbulo del arrepentido comencemos.</p>
<p>Hace un par de semanas, en mi trabajo tuve que lidiar con <em>setjmp.h</em> que basicamente, la verdad de la finalidad de esta característica de POSIX es poder guardar el estado de la ejecución de un proceso hasta que quieras volver a ese estado. De allí se deriva casi automaticamente que sirva para lograr un pseudo manejo de excepciones.</p>
<p>Odio la estructura de control <em>try{}catch(e){}</em>. La veo como una aberración de un lenguaje de programación antiguo que se vale de saltos sucios. Y me resulta bastante increíble que quienes las usan, se espanten al ver un <em>goto</em> en el código.</p>
<p>En fin, por estas cosas del laburo que nadie me pide hacer, pero que tuve que investigar terminé aprendiendo como se usan el par de funciones <em>setjmp</em> (try) y <em>longjmp </em>(raise).</p>
<p>Ahora que estoy tranquilo y en casita, me puse a jugar un poco con la idea de crear macros para proveer a C de esta estructura de control. Debo reconocer que quedó bastante limpia, salvo por el cierre. Seguramente se pueda mejorar muchísimo más pero insisto, estaba jugando un rato, creo que me llevó 10&#8242; (más pruebas).</p>
<p>El resultado es una librería (si, digo librería, no biblioteca), cuya funcionalidad es <strong>no reentrante</strong>. Las <strong>excepciones</strong> en sí no son excepciones (no tienen funcionalidad, aunque <strong>creo que se podrían castear algunos punteros a función</strong> (imaginen las posibilidades).</p>
<p>En fin, aquí va el código:</p>
<pre class="brush: cpp;">
/* except.c */
#include&#60;setjmp.h&#62;

jmp_buf _jmp_;
</pre>
<pre class="brush: cpp;">
/* except.h */
#ifndef __EXCEPT_H__
#define __EXCEPT_H__
#include&#60;setjmp.h&#62;

extern jmp_buf _jmp_;

#define try switch (setjmp(_jmp_)) { case 0:
#define catch(e) break; case e:
#define yrt break; default: fprintf(stderr,&#34;Exception not handled!\n&#34;); break; }

#define raise(err) longjmp(_jmp_,err)

#endif /* __EXCEPT_H__ */
</pre>
<pre class="brush: cpp;">
/* modouso.c */

#include &#60;stdio.h&#62;
#include &#34;except.h&#34;

#define DIVISION_BY_ZERO -1

float test(float num, float deno)
{
    if ( deno == 0.0 )
    {
        raise(DIVISION_BY_ZERO);
    }
    else
    {
        return (num/deno);
    }
}

int main (int argc, char* argv[])
{
    try {
        float rv;
        printf (&#34;Hello World normal execution, %f\n&#34;, test(2.3,4.3));
        rv = test(2.3,0.0);
        printf (&#34;Hello World error execution, %f\n&#34;, rv);
    } catch(DIVISION_BY_ZERO) {
        printf (&#34;Error -1 raised!\n&#34;);
    } yrt;
    return 0;
}
</pre>
<p>Como se puede ver, lo más fiero de todo este intento de implementar las macros es que no se me ocurrió (no pensé demasiado) como cerrar y tuve que agregar la macro <em>yrt</em> <del datetime="2009-11-22T18:54:32+00:00">(try al revés para la mente poco perspicaz)</del>. El yrt da la posibilidad de manejar excepciones no manejadas.</p>
<p><span style="text-decoration:line-through;">Como detalle a tener en cuenta y no estoy seguro del por qué, cuando generé la excepción llamando a la función test con dividendo = 0 dentro de la llamada del printf, no entró nunca en el catch, imagino que hubo algún otro setjmp en el medio que lo bloqueó.</span></p>
<p>Insisto, no quiero que se vea esto como un agregado ni me gustaría que alguien lo use, es a modo informativo/educativo de como se podría implementar y que no es demasiado complejo. Para mayor información sugiero las páginas de manual del unix que estemos usando</p>
<p><strong>man 3 setjmp</strong></p>
<p><strong>man 3 longjmp</strong></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Derek Motion 'corer']]></title>
<link>http://crashrattleandroll.wordpress.com/2009/11/21/derek-motion-corer/</link>
<pubDate>Sat, 21 Nov 2009 22:26:49 +0000</pubDate>
<dc:creator>Paul Squires</dc:creator>
<guid>http://crashrattleandroll.wordpress.com/2009/11/21/derek-motion-corer/</guid>
<description><![CDATA[I don&#8217;t like Derek, he doesn&#8217;t much like me. But ad hominem, that is unimportant. We mus]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I don&#8217;t like Derek, he doesn&#8217;t much like me. But ad hominem, that is unimportant. We must transcend our petty egos. Which brings me to this beautifully made poem.</p>
<p><a href="http://typingspace.wordpress.com/2009/11/08/corer/" target="_self">&#8216;corer&#8217;</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[BugsVoice (beta) is out!!]]></title>
<link>http://pupunzi.open-lab.com/2009/11/18/bugsvoice-beta-is-out/</link>
<pubDate>Wed, 18 Nov 2009 18:59:12 +0000</pubDate>
<dc:creator>Matteo Bicocchi</dc:creator>
<guid>http://pupunzi.open-lab.com/2009/11/18/bugsvoice-beta-is-out/</guid>
<description><![CDATA[Using the BugsVoice service you will supply friendly error pages and collect user feedback on except]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h3>Using the BugsVoice service you will supply friendly error pages and collect user feedback on exceptions.</h3>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/A7RRJXGD_hY&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' /><param name='allowfullscreen' value='true' /><param name='wmode' value='transparent' /><embed src='http://www.youtube.com/v/A7RRJXGD_hY&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='transparent'></embed></object></span></p>
<p>For everyone who makes web applications and needs to manage exceptions in a friendly way; if you get a trapped exception in your application (or in your web server), this will print out the script copied from your BugsVoice account, display the friendly error page to your customers, and collect their eventual feedback. All this will be saved in your account, and you can access any time to inspect the bug, feedback the customer etc.</p>
<h3>try <a href="http://bugsvoice.com" target="_blank"><strong>BugsVoice!</strong></a></h3>
<h3>site: <a href="http://bugsvoice.com" target="_blank"> http://bugsvoice.com</a></h3>
<p>see also:<a href="http://blog.bugsvoice.com/2009/11/17/setting-up-an-example-error-trapping-page/" target="_blank"><br />
setting up an example error trapping page</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Interest Expense]]></title>
<link>http://informationforbusinesses.wordpress.com/2009/11/18/interest-expense/</link>
<pubDate>Wed, 18 Nov 2009 18:09:23 +0000</pubDate>
<dc:creator>mycpaweb</dc:creator>
<guid>http://informationforbusinesses.wordpress.com/2009/11/18/interest-expense/</guid>
<description><![CDATA[Allocation of Interest The rules for deducting interest vary, depending on whether the loan proceeds]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2><span style="color:#888888;"> </span></h2>
<h3><span style="color:#888888;"><a href="http://informationforbusinesses.wordpress.com/files/2009/11/interest-expense1.jpg"><img class="alignleft size-full wp-image-88" title="interest expense" src="http://informationforbusinesses.wordpress.com/files/2009/11/interest-expense1.jpg" alt="" width="130" height="82" /></a>Allocation of Interest</span></h3>
<p>The rules for deducting interest vary, depending on whether the loan proceeds are used for business, personal, or investment activities. If you use the proceeds of a loan for more than one type of expense, you must make an allocation to determine the interest for each use of the loan&#8217;s proceeds.</p>
<p>Allocate your interest expense to the following categories.</p>
<ul>
<li>Nonpassive trade or business activity interest</li>
<li>Passive trade or business activity interest</li>
<li>Investment interest</li>
<li>Portfolio interest</li>
<li>Personal interest</li>
</ul>
<p>In general, you allocate interest on a loan the same way you allocate the loan proceeds. You allocate loan proceeds by tracing disbursements to specific uses.</p>
<p>The easiest way to trace disbursements to specific uses is to keep the proceeds of a particular loan separate from any other funds.</p>
<p><strong>Secured loan.</strong> The allocation of loan proceeds and the related interest is not generally affected by the use of property that secures the loan.</p>
<p><strong>Example.</strong></p>
<p>You secure a loan with property used in your business. You use the loan proceeds to buy an automobile for personal use. You must allocate interest expense on the loan to personal use (purchase of the automobile) even though the loan is secured by business property.</p>
<p>If the property that secures the loan is your home, you generally do not allocate the loan proceeds or the related interest. The interest is usually deductible as qualified home mortgage interest, regardless of how the loan proceeds are used.</p>
<p><strong>Allocation period.</strong> The period for which a loan is allocated to a particular use begins on the date the proceeds are used and ends on the earlier of the following dates.</p>
<ul>
<li>The date the loan is repaid.</li>
<li>The date the loan is reallocated to another use.</li>
</ul>
<p><strong>Proceeds not disbursed to borrower.</strong> Even if the lender disburses the loan proceeds to a third party, the allocation of the loan is still based on your use of the funds. This applies whether you pay for property, services, or anything else by incurring a loan, or you take property subject to a debt.</p>
<p><strong>Proceeds deposited in borrower&#8217;s account.</strong> Treat loan proceeds deposited in an account as property held for investment. It does not matter whether the account pays interest. Any interest you pay on the loan is investment interest expense. If you withdraw the proceeds of the loan, you must reallocate the loan based on the use of the funds.</p>
<p><strong>Example.</strong></p>
<p>Connie, a calendar-year taxpayer, borrows $100,000 on January 4 and immediately uses the proceeds to open a checking account. No other amounts are deposited in the account during the year and no part of the loan principal is repaid during the year. On April 2, Connie uses $20,000 from the checking account for a passive activity expenditure. On September 4, Connie uses an additional $40,000 from the account for personal purposes.</p>
<p>Under the interest allocation rules, the entire $100,000 loan is treated as property held for investment for the period from January 4 through April 1. From April 2 through September 3, Connie must treat $20,000 of the loan as used in the passive activity and $80,000 of the loan as property held for investment. From September 4 through December 31, she must treat $40,000 of the loan as used for personal purposes, $20,000 as used in the passive activity, and $40,000 as property held for investment.</p>
<p><em><strong>Order of funds spent.</strong></em> Generally, you treat loan proceeds deposited in an account as used (spent) before either of the following amounts.</p>
<ul>
<li>Any unborrowed amounts held in the same account.</li>
<li>Any amounts deposited after these loan proceeds.</li>
</ul>
<p><strong>Example.</strong></p>
<p>On January 9, Edith opened a checking account, depositing $500 of the proceeds of Loan A and $1,000 of unborrowed funds. The following table shows the transactions in her account during the tax year.</p>
<table style="height:195px;" border="0" cellspacing="0" cellpadding="0" width="484">
<tbody>
<tr>
<td valign="top"><strong><span style="text-decoration:underline;">Date</span></strong><strong> </strong></td>
<td valign="top"><strong> <span style="text-decoration:underline;">Transaction</span></strong><strong> </strong></td>
</tr>
<tr>
<td valign="top">January 9</td>
<td valign="top">$500 proceeds of Loan A and $1,000 unborrowed funds deposited</td>
</tr>
<tr>
<td valign="top">January 14</td>
<td valign="top">$500 proceeds of Loan B  deposited</td>
</tr>
<tr>
<td valign="top">February 19</td>
<td valign="top">$800 used for personal purposes</td>
</tr>
<tr>
<td valign="top">February 27</td>
<td valign="top">$700 used for passive activity</td>
</tr>
<tr>
<td valign="top">June 19</td>
<td valign="top">$1,000 proceeds of Loan C deposited</td>
</tr>
<tr>
<td valign="top">November20</td>
<td valign="top">$800 used for an investment</td>
</tr>
<tr>
<td valign="top">December 18</td>
<td valign="top">$600 used for personal purposes</td>
</tr>
</tbody>
</table>
<p>Edith treats the $800 used for personal purposes as made from the $500 proceeds of Loan A and $300 of the proceeds of Loan B. She treats the $700 used for a passive activity as made from the remaining $200 proceeds of Loan B and $500 of unborrowed funds. She treats the $800 used for an investment as made entirely from the proceeds of Loan C. She treats the $600 used for personal purposes as made from the remaining $200 proceeds of Loan C and $400 of unborrowed funds.</p>
<p>For the periods during which loan proceeds are held in the account, Edith treats them as property held for investment.</p>
<p><em><strong>Payments from checking accounts.</strong></em> Generally, you treat a payment from a checking or similar account as made at the time the check is written if you mail or deliver it to the payee within a reasonable period after you write it. You can treat checks written on the same day as written in any order.</p>
<p><em><strong>Amounts paid within 30 days.</strong></em> If you receive loan proceeds in cash or if the loan proceeds are deposited in an account, you can treat any payment (up to the amount of the proceeds) made from any account you own, or from cash, as made from those proceeds. This applies to any payment made within 30 days before or after the proceeds are received in cash or deposited in your account.</p>
<p>If the loan proceeds are deposited in an account, you can apply this rule even if the rules stated earlier under <em>Order of funds spent </em>would otherwise require you to treat the proceeds as used for other purposes. If you apply this rule to any payments, disregard those payments (and the proceeds from which they are made) when applying the rules stated under <em>Order of funds spent.</em></p>
<p>If you received the loan proceeds in cash, you can treat the payment as made on the date you received the cash instead of the date you actually made the payment.</p>
<p><strong>Example.</strong></p>
<p>Frank gets a loan of $1,000 on August 4 and receives the proceeds in cash. Frank deposits $1,500 in an account on August 18 and on August 28 writes a check on the account for a passive activity expense. Also, Frank deposits his paycheck, deposits other loan proceeds, and pays his bills during the same period. Regardless of these other transactions, Frank can treat $1,000 of the deposit he made on August 18 as being paid on August 4 from the loan proceeds. In addition, Frank can treat the passive activity expense he paid on August 28 as made from the $1,000 loan proceeds treated as deposited in the account.</p>
<p><em><strong>Optional method for determining date of reallocation.</strong></em> You can use the following method to determine the date loan proceeds are reallocated to another use. You can treat all payments from loan proceeds in the account during any month as taking place on the later of the following dates.</p>
<ul>
<li>The first day of that month.</li>
<li>The date the loan proceeds are deposited in the account.</li>
</ul>
<p>However, you can use this optional method only if you treat all payments from the account during the same calendar month in the same way.</p>
<p><em><strong>Interest on a segregated account.</strong></em> If you have an account that contains only loan proceeds and interest earned on the account, you can treat any payment from that account as being made first from the interest. When the interest earned is used up, any remaining payments are from loan proceeds.</p>
<p><strong>Example.</strong></p>
<p>You borrowed $20,000 and used the proceeds of this loan to open a new savings account. When the account had earned interest of $867, you withdrew $20,000 for personal purposes. You can treat the withdrawal as coming first from the interest earned on the account, $867, and then from the loan proceeds, $19,133 ($20,000 − $867). All the interest charged on the loan from the time it was deposited in the account until the time of the withdrawal is investment interest expense. The interest charged on the part of the proceeds used for personal purposes ($19,133) from the time you withdrew it until you either repay it or reallocate it to another use is personal interest expense. The interest charged on the loan proceeds you left in the account ($867) continues to be investment interest expense until you either repay it or reallocate it to another use.</p>
<p><strong>Loan repayment.</strong> When you repay any part of a loan allocated to more than one use, treat it as being repaid in the following order.</p>
<ol>
<li>Personal use.</li>
<li>Investments and passive activities (other than those included in (3)).</li>
<li>Passive activities in connection with a rental real estate activity in which you actively participate.</li>
<li>Former passive activities.</li>
<li>Trade or business use and expenses for certain low-income housing projects.</li>
</ol>
<p><strong>Line of credit (continuous borrowings).</strong> The following rules apply if you have a line of credit or similar arrangement.</p>
<ol>
<li>Treat all borrowed funds on which interest accrues at the same fixed or variable rate as a single loan.</li>
<li>Treat borrowed funds or parts of borrowed funds on which interest accrues at different fixed or variable rates as different loans. Treat these loans as repaid in the order shown on the loan agreement.</li>
</ol>
<p><strong>Loan refinancing.</strong> Allocate the replacement loan to the same uses to which the repaid loan was allocated. Make the allocation only to the extent you use the proceeds of the new loan to repay any part of the original loan.</p>
<p><strong>Debt-financed distribution.</strong> A debt-financed distribution occurs when a partnership or S corporation borrows funds and allocates those funds to distributions made to partners or shareholders. The manner in which you report the interest expense associated with the distributed debt proceeds depends on your use of those proceeds.</p>
<p><em><strong>How to report.</strong></em> If the proceeds were used in a nonpassive trade or business activity, report the interest on Schedule E (Form 1040), line 28; enter “interest expense” and the name of the partnership or S corporation in column (a) and the amount in column (h). If the proceeds were used in a passive activity, follow the Instructions for Form 8582, Passive Activity Loss Limitations, to determine the amount of interest expense that can be reported on Schedule E (Form 1040), line 28; enter “interest expense” and the name of the partnership in column (a) and the amount in column (f). If the proceeds were used in an investment activity, enter the interest on Form 4952. If the proceeds are used for personal purposes, the interest is generally not deductible.</p>
<h3><span style="color:#888888;">Interest You Can Deduct</span></h3>
<p>You can generally deduct as a business expense all interest you pay or accrue during the tax year on debts related to your trade or business. Interest relates to your trade or business if you use the proceeds of the loan for a trade or business expense. It does not matter what type of property secures the loan. You can deduct interest on a debt only if you meet all the following requirements.</p>
<ul>
<li>You are legally liable for that debt.</li>
<li>Both you and the lender intend that the debt be repaid.</li>
<li>You and the lender have a true debtor-creditor relationship.</li>
</ul>
<p><strong>Partial liability.</strong> If you are liable for part of a business debt, you can deduct only your share of the total interest paid or accrued.</p>
<p><strong>Example.</strong></p>
<p>You and your brother borrow money. You are liable for 50% of the note. You use your half of the loan in your business, and you make one-half of the loan payments. You can deduct your half of the total interest payments as a business deduction.</p>
<p><strong>Mortgage.</strong> Generally, mortgage interest paid or accrued on real estate you own legally or equitably is deductible. However, rather than deducting the interest currently, you may have to add it to the cost basis of the property as explained later under <em>Capitalization of Interest.</em></p>
<p><em><strong>Statement.</strong></em> If you paid $600 or more of mortgage interest (including certain points) during the year on any one mortgage, you generally will receive a Form 1098 or a similar statement. You will receive the statement if you pay interest to a person (including a financial institution or a cooperative housing corporation) in the course of that person&#8217;s trade or business. A governmental unit is a person for purposes of furnishing the statement.</p>
<p>If you receive a refund of interest you overpaid in an earlier year, this amount will be reported in box 3 of Form 1098. You cannot deduct this amount. For information on how to report this refund, see <em>Refunds of interest </em>later in this chapter.</p>
<p><em><strong>Expenses paid to obtain a mortgage.</strong></em> Certain expenses you pay to obtain a mortgage cannot be deducted as interest. These expenses, which include mortgage commissions, abstract fees, and recording fees, are capital expenses. If the property mortgaged is business or income-producing property, you can amortize the costs over the life of the mortgage.</p>
<p><em><strong>Prepayment penalty.</strong></em> If you pay off your mortgage early and pay the lender a penalty for doing this, you can deduct the penalty as interest.</p>
<p><strong>Interest on employment tax deficiency.</strong> Interest charged on employment taxes assessed on your business is deductible.</p>
<p><strong>Original issue discount (OID).</strong> OID is a form of interest. A loan (mortgage or other debt) generally has OID when its proceeds are less than its principal amount. The OID is the difference between the stated redemption price at maturity and the issue price of the loan.</p>
<p>A loan&#8217;s stated redemption price at maturity is the sum of all amounts (principal and interest) payable on it other than qualified stated interest. Qualified stated interest is stated interest that is unconditionally payable in cash or property (other than another loan of the issuer) at least annually over the term of the loan at a single fixed rate.</p>
<p>You generally deduct OID over the term of the loan. Figure the amount to deduct each year using the constant-yield method, unless the OID on the loan is de minimis.</p>
<p><em><strong>De minimis OID.</strong></em> The OID is de minimis if it is less than one-fourth of 1% (.0025) of the stated redemption price of the loan at maturity multiplied by the number of full years from the date of original issue to maturity (the term of the loan).</p>
<p>If the OID is de minimis, you can choose one of the following ways to figure the amount you can deduct each year.</p>
<ul>
<li>On a constant-yield basis over the term of the loan.</li>
<li>On a straight-line basis over the term of the loan.</li>
<li>In proportion to stated interest payments.</li>
<li>In its entirety at maturity of the loan.</li>
</ul>
<p>You make this choice by deducting the OID in a manner consistent with the method chosen on your timely filed tax return for the tax year in which the loan is issued.</p>
<p><strong>Example.</strong></p>
<p>On January 1, 2008, you took out a $100,000 discounted loan and received $98,500 in proceeds. The loan will mature on January 1, 2018 (a 10-year term), and the $100,000 principal is payable on that date. Interest of $10,000 is payable on January 1 of each year, beginning January 1, 2009. The $1,500 OID on the loan is de minimis because it is less than $2,500 ($100,000 × .0025 × 10). You choose to deduct the OID on a straight-line basis over the term of the loan. Beginning in 2008, you can deduct $150 each year for 10 years.</p>
<p><em><strong>Constant-yield method.</strong></em> If the OID is not de minimis, you must use the constant-yield method to figure how much you can deduct each year. You figure your deduction for the first year using the following steps.</p>
<ol>
<li>Determine the issue price of the loan. Generally, this equals the proceeds of the loan. If you paid points on the loan (as discussed later), the issue price generally is the difference between the proceeds and the points.</li>
<li>Multiply the result in (1) by the yield to maturity.</li>
<li>Subtract any qualified stated interest payments from the result in (2). This is the OID you can deduct in the first year.</li>
</ol>
<p>To figure your deduction in any subsequent year, follow the above steps, except determine the adjusted issue price in step (1). To get the adjusted issue price, add to the issue price any OID previously deducted. Then follow steps (2) and (3) above.</p>
<p>The yield to maturity is generally shown in the literature you receive from your lender. If you do not have this information, consult your lender or tax advisor. In general, the yield to maturity is the discount rate that, when used in computing the present value of all principal and interest payments, produces an amount equal to the principal amount of the loan.</p>
<p><strong>Example.</strong></p>
<p>The facts are the same as in the previous example, except that you deduct the OID on a constant yield basis over the term of the loan. The yield to maturity on your loan is 10.2467%, compounded annually. For 2008, you can deduct $93 [($98,500 × .102467) − $10,000]. For 2009, you can deduct $103 [($98,593 × .102467) − $10,000].</p>
<p><em><strong>Loan or mortgage ends.</strong></em> If your loan or mortgage ends, you may be able to deduct any remaining OID in the tax year in which the loan or mortgage ends. A loan or mortgage may end due to a refinancing, prepayment, foreclosure, or similar event.</p>
<p>If you refinance with the original lender, you generally cannot deduct the remaining OID in the year in which the refinancing occurs, but you may be able to deduct it over the term of the new mortgage or loan. See Interest paid with funds borrowed from original lender under Interest You Cannot Deduct, later.</p>
<p><strong>Points.</strong> The term “points” is used to describe certain of the charges paid, or treated as paid, by a borrower to obtain a loan or a mortgage. These charges are also called loan origination fees, maximum loan charges, discount points, or premium charges. If any of these charges (points) are solely for the use of money, they are interest.</p>
<p>Because points are prepaid interest, you generally cannot deduct the full amount in the year paid. However, you can choose to fully deduct points in the year paid if you meet certain tests. For exceptions to the general rule, see Publication 936.</p>
<p>The points reduce the issue price of the loan and result in original issue discount, deductible as explained in the preceding discussion.</p>
<p><strong>Partial payments on a non-tax debt.</strong> If you make partial payments on a debt (other than a debt owed the IRS), the payments are applied, in general, first to interest and any remainder to principal. You can deduct only the interest. This rule does not apply when it can be inferred that the borrower and lender understood that a different allocation of the payments would be made.</p>
<p><strong>Installment purchase.</strong> If you make an installment purchase of business property, the contract between you and the seller generally provides for the payment of interest. If no interest or a low rate of interest is charged under the contract, a portion of the stated principal amount payable under the contract may be recharacterized as interest (unstated interest). The amount recharacterized as interest reduces your basis in the property and increases your interest expense.</p>
<h3><span style="color:#888888;">Interest You Cannot Deduct</span></h3>
<p>Certain interest payments cannot be deducted. In addition, certain other expenses that may seem to be interest are not, and you cannot deduct them as interest.</p>
<p>You cannot currently deduct interest that must be capitalized, and you generally cannot deduct personal interest.</p>
<p><strong>Interest paid with funds borrowed from original lender.</strong> If you use the cash method of accounting, you cannot deduct interest you pay with funds borrowed from the original lender through a second loan, an advance, or any other arrangement similar to a loan. You can deduct the interest expense once you start making payments on the new loan.</p>
<p>When you make a payment on the new loan, you first apply the payment to interest and then to the principal. All amounts you apply to the interest on the first loan are deductible, along with any interest you pay on the second loan, subject to any limits that apply.</p>
<p><strong>Capitalized interest.</strong> You cannot currently deduct interest you are required to capitalize under the uniform capitalization rules. See <em>Capitalization of Interest, </em>later. In addition, if you buy property and pay interest owed by the seller (for example, by assuming the debt and any interest accrued on the property), you cannot deduct the interest. Add this interest to the basis of the property.</p>
<p><strong>Commitment fees or standby charges.</strong> Fees you incur to have business funds available on a standby basis, but not for the actual use of the funds, are not deductible as interest payments. You may be able to deduct them as business expenses.</p>
<p>If the funds are for inventory or certain property used in your business, the fees are indirect costs and you generally must capitalize them under the uniform capitalization rules. See <em>Capitalization of Interest,</em> later.</p>
<p><strong>Interest on income tax.</strong> Interest charged on income tax assessed on your individual income tax return is not a business deduction even though the tax due is related to income from your trade or business. Treat this interest as a business deduction only in figuring a net operating loss deduction.</p>
<p><em><strong>Penalties.</strong></em> Penalties on underpaid deficiencies and underpaid estimated tax are not interest. You cannot deduct them. Generally, you cannot deduct any fines or penalties.</p>
<p><strong>Interest on loans with respect to life insurance policies.</strong> You generally cannot deduct interest on a debt incurred with respect to any life insurance, annuity, or endowment contract that covers any individual unless that individual is a key person.</p>
<p>If the policy or contract covers a key person, you can deduct the interest on up to $50,000 of debt for that person. However, the deduction for any month cannot be more than the interest figured using Moody&#8217;s Composite Yield on Seasoned Corporate Bonds (formerly known as Moody&#8217;s Corporate Bond Yield Average-Monthly Average Corporates) (Moody&#8217;s rate) for that month.</p>
<p><em><strong>Who is a key person?</strong></em> A key person is an officer or 20% owner. However, the number of individuals you can treat as key persons is limited to the greater of the following.</p>
<ul>
<li>Five individuals.</li>
<li>The lesser of 5% of the total officers and employees of the company or 20 individuals.</li>
</ul>
<p><em><strong>Exceptions for pre-June 1997 contracts.</strong></em> You can generally deduct the interest if the contract was issued before June 9, 1997, and the covered individual is someone other than an employee, officer, or someone financially interested in your business. If the contract was purchased before June 21, 1986, you can generally deduct the interest no matter who is covered by the contract.</p>
<p><em><strong>Interest allocated to unborrowed policy cash value.</strong></em> Corporations and partnerships generally cannot deduct any interest expense allocable to unborrowed cash values of life insurance, annuity, or endowment contracts. This rule applies to contracts issued after June 8, 1997, that cover someone other than an officer, director, employee, or 20% owner. For more information, see section 264(f) of the Internal Revenue Code.</p>
<h3><span style="color:#888888;">Capitalization of Interest</span></h3>
<p>Under the uniform capitalization rules, you generally must capitalize interest on debt equal to your expenditures to produce real property or certain tangible personal property. The property must be produced by you for use in your trade or business or for sale to customers. You cannot capitalize interest related to property that you acquire in any other manner.</p>
<p>Interest you paid or incurred during the production period must be capitalized if the property produced is designated property. Designated property is any of the following.</p>
<ul>
<li>Real property.</li>
<li>Tangible personal property with a class life of 20 years or more.</li>
<li>Tangible personal property with an estimated production period of more than 2 years.</li>
<li>Tangible personal property with an estimated production period of more than 1 year if the estimated cost of production is more than $1 million.</li>
</ul>
<p><strong>Property you produce.</strong> You produce property if you construct, build, install, manufacture, develop, improve, create, raise, or grow it. Treat property produced for you under a contract as produced by you up to the amount you pay or incur for the property.</p>
<p><strong>Carrying charges.</strong> Carrying charges include taxes you pay to carry or develop real estate or to carry, transport, or install personal property. You can choose to capitalize carrying charges not subject to the uniform capitalization rules if they are otherwise deductible. For more information, see chapter 7.</p>
<p><strong>Capitalized interest.</strong> Treat capitalized interest as a cost of the property produced. You recover your interest when you sell or use the property. If the property is inventory, recover capitalized interest through cost of goods sold. If the property is used in your trade or business, recover capitalized interest through an adjustment to basis, depreciation, amortization, or other method.</p>
<p><strong>Partnerships and S corporations.</strong> The interest capitalization rules are applied first at the partnership or S corporation level. The rules are then applied at the partners&#8217; or shareholders&#8217; level to the extent the partnership or S corporation has insufficient debt to support the production or construction costs.</p>
<p>If you are a partner or a shareholder, you may have to capitalize interest you incur during the tax year for the production costs of the partnership or S corporation. You may also have to capitalize interest incurred by the partnership or S corporation for your own production costs. To properly capitalize interest under these rules, you must be given the required information in an attachment to the Schedule K-1 you receive from the partnership or S corporation.</p>
<p><strong>Additional information.</strong> The procedures for applying the uniform capitalization rules are beyond the scope of this publication. For more information, see sections 1.263A-8 through 1.263A-15 of the regulations and Notice 88-99. Notice 88-99 is in Cumulative Bulletin 1988-2.</p>
<h3><span style="color:#888888;">When To Deduct Interest</span></h3>
<p>If the uniform capitalization rules, discussed under <em>Capitalization of Interest,</em> earlier, do not apply to you, deduct interest as follows.</p>
<p><strong>Cash method.</strong> Under the cash method, you can generally deduct only the interest you actually paid during the tax year. You cannot deduct a promissory note you gave as payment because it is a promise to pay and not an actual payment.</p>
<p><em><strong>Prepaid interest.</strong></em> You generally cannot deduct any interest paid before the year it is due. Interest paid in advance can be deducted only in the tax year in which it is due.</p>
<p><em><strong>Discounted loan.</strong></em> If interest or a discount is subtracted from your loan proceeds, it is not a payment of interest and you cannot deduct it when you get the loan. For more information, see <em>Original issue discount (OID)</em> under <em>Interest You Can Deduct,</em> earlier.</p>
<p><em><strong>Refunds of interest.</strong></em> If you pay interest and then receive a refund in the same tax year of any part of the interest, reduce your interest deduction by the refund. If you receive the refund in a later tax year, include the refund in your income to the extent the deduction for the interest reduced your tax.</p>
<p><strong>Accrual method.</strong> Under an accrual method, you can deduct only interest that has accrued during the tax year.</p>
<p><em><strong>Prepaid interest.</strong></em> See <em>Prepaid interest,</em> above.</p>
<p><em><strong>Discounted loan.</strong></em> See <em>Discounted loan,</em> above.</p>
<p><em><strong>Tax deficiency.</strong></em> If you contest a federal income tax deficiency, interest does not accrue until the tax year the final determination of liability is made. If you do not contest the deficiency, then the interest accrues in the year the tax was asserted and agreed to by you.</p>
<p>However, if you contest but pay the proposed tax deficiency and interest, and you do not designate the payment as a cash bond, then the interest is deductible in the year paid.</p>
<p><em><strong>Related person.</strong></em> If you use an accrual method, you cannot deduct interest owed to a related person who uses the cash method until payment is made and the interest is includible in the gross income of that person. The relationship is determined as of the end of the tax year for which the interest would otherwise be deductible. See section 267 of the Internal Revenue Code for more information.</p>
<h3><span style="color:#888888;">Below-Market Loans</span></h3>
<p>If you receive a below-market gift or demand loan and use the proceeds in your trade or business, you may be able to deduct the forgone interest. See <em>Treatment of gift and demand loans </em>later in this discussion.</p>
<p>A below-market loan is a loan on which no interest is charged or on which interest is charged at a rate below the applicable federal rate. A gift or demand loan that is a below-market loan generally is considered an arm&#8217;s-length transaction in which you, the borrower, are considered as having received both the following.</p>
<ul>
<li>A loan in exchange for a note that requires the payment of interest at the applicable federal rate.</li>
<li>An additional payment in an amount equal to the forgone interest.</li>
</ul>
<p>The additional payment is treated as a gift, dividend, contribution to capital, payment of compensation, or other payment, depending on the substance of the transaction.</p>
<p>For any period, forgone interest is:</p>
<ol>
<li>The interest that would be payable for that period if interest accrued on the loan at the applicable federal rate and was payable annually on December 31,<br />
minus</li>
<li>Any interest actually payable on the loan for the period.</li>
</ol>
<p>Applicable federal rates are published by the IRS each month in the Internal Revenue Bulletin. Internal Revenue Bulletins are available on the IRS web site at <a href="http://www.irs.gov/irb" target="_top">www.irs.gov/irb</a>. You can also contact an IRS office to get these rates.</p>
<p><strong>Loans subject to the rules.</strong> The rules for below-market loans apply to the following.</p>
<ol>
<li>Gift loans (below-market loans where the forgone interest is in the nature of a gift).</li>
<li>Compensation-related loans (below-market loans between an employer and an employee or between an independent contractor and a person for whom the contractor provides services).</li>
<li>Corporation-shareholder loans.</li>
<li>Tax avoidance loans (below-market loans where the avoidance of federal tax is one of the main purposes of the interest arrangement).</li>
<li>Loans to qualified continuing care facilities under a continuing care contract (made after October 11, 1985).</li>
</ol>
<p>Except as noted in (5) above, these rules apply to demand loans (loans payable in full at any time upon the lender&#8217;s demand) outstanding after June 6, 1984, and to term loans (loans that are not demand loans) made after that date.</p>
<p><strong>Treatment of gift and demand loans.</strong> If you receive a below-market gift loan or demand loan, you are treated as receiving an additional payment (as a gift, dividend, etc.) equal to the forgone interest on the loan. You are then treated as transferring this amount back to the lender as interest. These transfers are considered to occur annually, generally on December 31. If you use the loan proceeds in your trade or business, you can deduct the forgone interest each year as a business interest expense. The lender must report it as interest income.</p>
<p><em><strong>Limit on forgone interest for gift loans of $100,000 or less.</strong></em> For gift loans between individuals, forgone interest treated as transferred back to the lender is limited to the borrower&#8217;s net investment income for the year. This limit applies if the outstanding loans between the lender and borrower total $100,000 or less. If the borrower&#8217;s net investment income is $1,000 or less, it is treated as zero. This limit does not apply to a loan if the avoidance of any federal tax is one of the main purposes of the interest arrangement.</p>
<p><strong>Treatment of term loans.</strong> If you receive a below-market term loan other than a gift or demand loan, you are treated as receiving an additional cash payment (as a dividend, etc.) on the date the loan is made. This payment is equal to the loan amount minus the present value, at the applicable federal rate, of all payments due under the loan. The same amount is treated as original issue discount on the loan. See <em>Original issue discount (OID)</em> under <em>Interest You Can Deduct</em>, earlier.</p>
<p><strong>Exceptions for loans of $10,000 or less.</strong> The rules for below-market loans do not apply to any day on which the total outstanding loans between the borrower and lender is $10,000 or less. This exception applies only to the following.</p>
<ol>
<li>Gift loans between individuals if the loan is not directly used to buy or carry income-producing assets.</li>
<li>Compensation-related loans or corporation-shareholder loans if the avoidance of any federal tax is not a principal purpose of the interest arrangement.</li>
</ol>
<p>This exception does not apply to a term loan described in (2) above that was previously subject to the below-market loan rules. Those rules will continue to apply even if the outstanding balance is reduced to $10,000 or less.</p>
<p><strong>Exceptions for loans without significant tax effect.</strong> The following loans are specifically exempted from the rules for below-market loans because their interest arrangements do not have a significant effect on the federal tax liability of the borrower or the lender.</p>
<ol>
<li>Loans made available by lenders to the general public on the same terms and conditions that are consistent with the lender&#8217;s customary business practices.</li>
<li>Loans subsidized by a federal, state, or municipal government that are made available under a program of general application to the public.</li>
<li>Certain employee-relocation loans.</li>
<li>Certain loans to or from a foreign person, unless the interest income would be effectively connected with the conduct of a U.S. trade or business and not exempt from U.S. tax under an income tax treaty.</li>
<li>Any other loan if the taxpayer can show that the interest arrangement has no significant effect on the federal tax liability of the lender or the borrower. Whether an interest arrangement has a significant effect on the federal tax liability of the lender or the borrower will be determined by all the facts and circumstances. Consider all the following factors.
<ol>
<li>Whether items of income and deduction generated by the loan offset each other.</li>
<li>The amount of the items.</li>
<li>The cost of complying with the below-market loan provisions if they were to apply.</li>
<li>Any reasons, other than taxes, for structuring the transaction as a below-market loan.</li>
</ol>
</li>
</ol>
<p><strong>Exception for loans to qualified continuing care facilities.</strong> The below-market interest rules do not apply to a loan owed by a qualified continuing care facility under a continuing care contract if the lender or lender&#8217;s spouse is age 62 or older by the end of the calendar year.</p>
<p>A qualified continuing care facility is one or more facilities (excluding nursing homes) meeting the requirements listed below.</p>
<ol>
<li>Designed to provide services under continuing care contracts (defined below).</li>
<li>Includes an independent living unit, and either an assisted living or nursing facility, or both.</li>
<li>Substantially all of the independent living unit residents are covered by continuing care contracts.</li>
</ol>
<p>A continuing care contract is a written contract between an individual and a qualified continuing care facility that includes all of the following conditions.</p>
<ol>
<li>The individual or individual&#8217;s spouse must be entitled to use the facility for the rest of their life or lives.</li>
<li>The individual or individual&#8217;s spouse will be provided with housing, as appropriate for the health of the individual or individual&#8217;s spouse in an:
<ol>
<li>independent living unit (which has additional available facilities outside the unit for the provision of meals and other personal care), and</li>
<li>assisted living or nursing facility available in the continuing care facility.</li>
</ol>
</li>
<li>The individual or individual&#8217;s spouse will be provided with assisted living or nursing care available in the continuing care facility, as required for the health of the individual or the individual&#8217;s spouse.</li>
</ol>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[List of Return Codes for SOA]]></title>
<link>http://artofsoftwarereuse.com/2009/11/18/list-of-return-codes-for-soa/</link>
<pubDate>Wed, 18 Nov 2009 11:48:52 +0000</pubDate>
<dc:creator>vijaynarayanan</dc:creator>
<guid>http://artofsoftwarereuse.com/2009/11/18/list-of-return-codes-for-soa/</guid>
<description><![CDATA[List of Return Codes I wrote earlier about the idea of using consistent error codes for reusable ass]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div id="attachment_2154" class="wp-caption alignright" style="width: 160px"><a href="http://www.box.net/shared/6qmb1irji0"><img class="size-full wp-image-2154 " title="soa_return_codes" src="http://softwarereuse.wordpress.com/files/2009/11/soa_return_codes.jpg" alt="" width="150" height="101" /></a><p class="wp-caption-text">List of Return Codes</p></div>
<p>I wrote earlier about the idea of using <a href="http://artofsoftwarereuse.com/2009/04/14/standardize-error-codes-for-reusable-error-handling/">consistent</a> error codes for reusable assets. As a follow up, here is a <a href="http://www.box.net/shared/6qmb1irji0">document </a>with a list of reusable return codes that can be used when building service capabilities as part of SOA initiatives. They are categorized into:</p>
<ul>
<li> request processing</li>
<li>data processing</li>
<li>dependency access</li>
<li>transactions</li>
</ul>
<p>This isn&#8217;t an exhaustive list by any means but can get you started in  terms of achieving consistency across services and projects.The service consumer can use the return code to understand the service provider&#8217;s response. This consistent, uniform categorization of return codes can help you reuse error handlers (e.g. handle a particular error in the same way regardless of which service capability raised it).  It will also help with production support and troubleshooting &#8211; less learning curve for support staff and developers to categorize errors at runtime.</p>
<p><em><span style="text-decoration:underline;">Note:</span> The return code derived based on errors need not necessarily be the return code sent back to the service consumer. It is entirely possible that you return a friendly error to the consumer and a detailed error to production support. </em></p>
<p>Are there additional ones to include in this list?</p>
<p><strong>Like this post?</strong> Subscribe to <a href="http://feeds2.feedburner.com/SoftwareReuseInTheRealWorld">RSS feed</a> or get blog <a href="http://feedburner.google.com/fb/a/mailverify?uri=SoftwareReuseInTheRealWorld&#38;loc=en_US">updates via email</a>.</p>
<p style="text-align:right;"><strong> <a href="http://twitter.com/home?status=http://wp.me/ptCiB-yt"><img title="tweet this" src="/files/2009/10/twitter2.png" alt="tweet this" width="32" height="32" /></a> <a href="http://del.icio.us/post?url=http://wp.me/ptCiB-yt&#38;title=List of Return Codes for SOA"><img title="del.icio.us:List of Return Codes for SOA" src="/files/2009/10/dellicious.png" alt="add to del.icio.us" width="32" height="32" /></a></strong> <a href="http://www.facebook.com/sharer.php?u=http://wp.me/ptCiB-yt&#38;title=List of Return Codes for SOA"><img title="facebook:List of Return Codes for SOA" src="/files/2009/10/48x48.png" alt="post to facebook" width="32" height="32" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Exceptions]]></title>
<link>http://interviewboard.wordpress.com/2009/11/17/exceptions/</link>
<pubDate>Tue, 17 Nov 2009 18:53:44 +0000</pubDate>
<dc:creator>technospider</dc:creator>
<guid>http://interviewboard.wordpress.com/2009/11/17/exceptions/</guid>
<description><![CDATA[Q1) What is an Exception? Ans) The exception is said to be thrown whenever an exceptional event occu]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><table cellspacing="15">
<tbody>
<tr>
<td><a name="Q1" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q1"><strong>Q1) What is an Exception?</strong></p>
<p></a></p>
<div id="divQ1">
<p>Ans) The exception is said to be thrown whenever an exceptional event occurs in java which signals that something is not correct with the code written and may give unexpected result. An exceptional event is a occurrence of condition which alters the normal program flow. Exceptional handler is the code that does something about the exception.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q2" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q2"><strong>Q2) Exceptions are defined in which java package?</strong></p>
<p></a></p>
<div id="divQ2">
<p>Ans)All the exceptions are subclasses of java.lang.Exception</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q3" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q3"><strong>Q3) How are the exceptions handled in java?</strong></a></p>
<div id="divQ3">
<p>Ans)When an exception occurs the execution of the program is transferred to an appropriate exception handler.The try-catch-finally block is used to handle the exception.<br />
The code in which the  exception may occur is enclosed in a try block, also called as a guarded region.<br />
The catch clause matches a  specific exception to a block of code which handles that exception.<br />
And the clean up code which  needs to be executed no matter the exception occurs or not is put inside the finally block</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q4" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q4"><strong>Q4) Explain the exception hierarchy in java.</strong></p>
<p></a></p>
<div id="divQ4">
<p>Ans) The hierarchy is as follows:</p>
<p><img src="http://www.java-questions.com/%5Cimg%5CExceptionClasses.png" alt="Exception" /></p>
<p>Throwable is a parent class off all Exception classes. They are two types of Exceptions: Checked exceptions and UncheckedExceptions. Both type of exceptions extends Exception class.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q5" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q5"><strong>Q5) What is Runtime Exception or unchecked exception?</strong></p>
<p></a></p>
<div id="divQ5">
<p>Ans) Runtime exceptions represent problems that are the result of a programming problem. Such problems include arithmetic exceptions, such as dividing by zero; pointer exceptions, such as trying to access an object through a null reference; and indexing exceptions, such as attempting to access an array element through an index that is too large or too small. Runtime exceptions need not be explicitly caught in try catch block as it can occur anywhere in a program, and in a typical one they can be very numerous. Having to add runtime exceptions in every method declaration would reduce a program&#8217;s clarity. Thus, the compiler does not require that you catch or specify runtime exceptions (although you can). The solution to rectify is to correct the programming logic where the exception has occurred or provide a check.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q6" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q6"><strong> Q6) What is checked exception? </strong></p>
<p></a></p>
<div id="divQ6">
<p>Ans) Checked exception are the exceptions which forces the programmer to catch them explicitly in try-catch block. It is a subClass of Exception. Example: IOException.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q7" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q7"><strong> Q7) What is difference between Error and Exception? </strong></p>
<p></a></p>
<div id="divQ7">
<p>Ans) An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime.Though error can be caught in catch block but the execution of application will come to a halt and is not recoverable.</p>
<p>While exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference. In most of the cases it is possible to recover from an exception (probably by giving user a feedback for entering proper values etc.)</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q8" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q8"><strong>Q8) What is difference between ClassNotFoundException and NoClassDefFoundError?</strong></p>
<p></a></p>
<div id="divQ8">
<p>Ans) A ClassNotFoundException is thrown when the reported class is not found by the ClassLoader in the CLASSPATH. It could also mean that the class in question is trying to be loaded from another class which was loaded in a parent classloader and hence the class from the child classloader is not visible.</p>
<p>Consider if NoClassDefFoundError occurs which is something like</p>
<p>java.lang.NoClassDefFoundError</p>
<p>src/com/TestClass</p>
<p>does not mean that the TestClass class is not in the CLASSPATH. It means that the class TestClass was found by the ClassLoader however when trying to load the class, it ran into an error reading the class definition. This typically happens when the class in question has static blocks or members which use a Class that&#8217;s not found by the ClassLoader. So to find the culprit, view the source of the class in question (TestClass in this case) and look for code using static blocks or static members.</p>
</div>
</td>
</tr>
<tr>
<td><a name="throw_keyword" href="http://www.java-questions.com/Exceptions_interview_questions.html#throw_keyword"><strong>Q9) What is throw keyword?</strong></p>
<p></a></p>
<div id="divQ28">
Ans) Throw keyword is used to throw the exception manually. It is mainly used when the program fails to satisfy the given condition and it wants to warn the application.The exception thrown should be subclass of Throwable.</p>
<div>public void parent(){<br />
try{<br />
child();<br />
}catch(MyCustomException e){	}<br />
}</p>
<p>public void child{<br />
String iAmMandatory=null;<br />
if(iAmMandatory == null){<br />
throw (new MyCustomException(&#8220;Throwing exception using throw keyword&#8221;);<br />
}<br />
}</p></div>
</div>
</td>
</tr>
<tr>
<td><a name="throws_keyword" href="http://www.java-questions.com/Exceptions_interview_questions.html#throws_keyword"><strong>Q10) What is use of throws keyword?</strong></p>
<p></a></p>
<div id="divQ29">
Ans) If the function is not capable of handling the exception then it can ask the calling method to handle it by simply putting the <strong>throws clause</strong> at the function declaration.</p>
<div>public void parent(){<br />
try{<br />
child();<br />
}catch(MyCustomException e){	}<br />
}</p>
<p>public void child throws MyCustomException{<br />
//put some logic so that the exception occurs.<br />
}</p></div>
</div>
</td>
</tr>
<tr>
<td><a name="Q9" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q9"><strong>Q11) What are the possible combination to write try, catch  finally block?</strong></p>
<p></a></p>
<div id="divQ9">
<p>Ans)</p>
<blockquote><p>&#160;</p>
<div>1)  try{</p>
<blockquote><p>//lines of code that may throw an exception</p></blockquote>
<p>}catch(Exception e){</p>
<blockquote><p>//lines of code to handle the exception thrown in try block</p></blockquote>
<p>}finally{</p>
<blockquote><p>//the clean code which is executed always no matter the exception occurs or not.</p></blockquote>
<p>}</p>
</div>
<div>
<p>2 try{</p>
<p>}finally{}</p>
<p>3 try{</p>
<p>}catch(Exception e){</p>
<p>//lines of code to handle the exception thrown in try block</p>
<p>}</p>
</div>
</blockquote>
<p>The catch blocks must always follow the try block. If there are more than one catch blocks they all must follow each other without any block in between. The finally block must follow the catch block if one is present or if the catch block is absent the finally block must follow the try block.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q10" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q10"><strong> Q12) How to create custom Exception?</strong> </a></p>
<div id="divQ10">
<p>Ans) To create you own exception extend the Exception class or any of its subclasses.</p>
<p>e.g.</p>
<p>1 class New1Exception extends Exception { } // this will create Checked Exception</p>
<p>2 class NewException extends IOExcpetion { } // this will create Checked exception</p>
<p>3 class NewException extends NullPonterExcpetion { } // this will create UnChecked exception</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q11" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q11"><strong>Q13) When to make a custom checked Exception or custom unchecked Exception?</p>
<p></strong></a></p>
<div id="divQ11">
<p>Ans) If an application can reasonably be expected to recover from an exception, make it a checked exception. If an application cannot do anything to recover from the exception, make it an unchecked exception.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q12" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q12"><strong>Q14)What is StackOverflowError?</strong></p>
<p></a></p>
<div id="divQ12">
<p>Ans) The StackOverFlowError is an Error Object thorwn by the Runtime System when it Encounters that your application/code has ran out of the memory. It may occur in case of recursive methods or a large amount of data is fetched from the server and stored in some object. This error is generated by JVM.</p>
<p>e.g. 				void swap(){</p>
<blockquote>
<blockquote><p>swap();</p></blockquote>
<p>}</p></blockquote>
</div>
</td>
</tr>
<tr>
<td><a name="Q13" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q13"><strong>Q15) Why did the designers decide to force a method to specify all uncaught checked exceptions that can be thrown within its scope?</strong></p>
<p></a></p>
<div id="divQ13">
<p>Ans) Any Exception that can be thrown by a method is part of the method&#8217;s public programming interface. Those who call a method must know about the exceptions that a method can throw so that they can decide what to do about them. These exceptions are as much a part of that method&#8217;s programming interface as its parameters and return value.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q14" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q14"><strong>Q16) Once the control switches to the catch block does it return back to the try block to execute the balance code?</strong></p>
<p></a></p>
<div id="divQ141">
<p>Ans) No. Once the control jumps to the catch block it never returns to the try block but it goes  to finally block(if present).</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q15" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q15"><strong>Q17) Where is the clean up code like release of resources is put in try-catch-finally block and why?</strong></p>
<p></a></p>
<div id="divQ15">
<p>Ans) The code is put in a finally block because irrespective of try or catch block execution the control will flow to finally block. Typically finally block contains release of connections, closing of result set etc.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q16" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q16"><strong>Q18) Is it valid to have a try block without catch or finally?</strong></a></p>
<div id="divQ16">
<p>Ans) NO. This will result in a compilation error. 			The try block must be followed by a catch or a finally block. 			It is legal to omit the either catch or the finally block but not both.</p>
<p>e.g.  The following code is illegal.</p>
<blockquote><p>try{<br />
int i =0;<br />
}<br />
int a = 2;<br />
System.out.println(“a =  “+a);</p></blockquote>
</div>
</td>
</tr>
<tr>
<td><a name="Q17" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q17"><strong> Q19) Is it valid to place some code in between try the catch/finally block that follows it?</strong></a></p>
<div id="divQ17">
<p>Ans) No. There should not be any line of code present between the try and the catch/finally block.</p>
<p>e.g.  The following code is wrong.</p>
<div>
<blockquote><p>try{}<br />
String str = “ABC”;<br />
System.out.println(“str  = “+str);<br />
catch(Exception e){}</p></blockquote>
</div>
</div>
</td>
</tr>
<tr>
<td><a name="Q18" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q18"> <strong>Q20) What happens if the exception is never caught and throws down the method stack?</p>
<p></strong></a></p>
<div id="divQ18">
<p>Ans) If the exception is not caught by any of the method in the method’s stack till you get to the main() method, the main method throws that exception and the JVM halts its execution.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q19" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q19"> <strong>Q21) How do you get the descriptive information about the Exception occurred during the program execution?</p>
<p></strong></a></p>
<div id="divQ19">
<p>Ans) All the exceptions inherit a method printStackTrace() from the Throwable class. This method prints the stack trace from where the exception occurred. It prints the most recently entered method first and continues down, printing the name of each method as it works its way down the call stack from the top.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q20" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q20"><strong>Q22) Can you catch more than one exceptions in a single catch block?</strong></p>
<p></a></p>
<div id="divQ20">
<p>Ans)Yes. If the exception class specified in the catch clause has subclasses, any exception object that is a subclass of the specified Exception class will be caught by that single catch block.</p>
<p>E.g..</p>
<div>
<blockquote><p>try {</p>
<p>// Some code here that can throw an IOException</p>
<p>}</p>
<p>catch (IOException e) {</p>
<blockquote><p>e.printStackTrace();</p></blockquote>
<p>}</p></blockquote>
</div>
<p>The catch block above will catch IOException and all its subclasses e.g. FileNotFoundException etc.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q21" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q21"><strong>Q23)Why is not considered as a good practice to write a single catchall handler to catch all the exceptions?</strong></p>
<p></a></p>
<div id="divQ21">
<p>Ans) You can write a single catch block to handle all the exceptions thrown during the program execution as follows :</p>
<div>
<blockquote><p>try {</p>
<blockquote><p>// code that can throw exception of any possible type</p></blockquote>
<p>}catch (Exception e) {</p>
<blockquote><p>e.printStackTrace();</p></blockquote>
<p>}</p></blockquote>
</div>
<p>If you use the Superclass Exception in the catch block then you will not get the valuable information about each of the exception thrown during the execution, though you can find out the class of the exception occurred. Also it will reduce the readability of the code as the programmer will not understand what is the exact reason for putting the try-catch block.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q22" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q22"> <strong>Q24) What is exception matching?</strong></a></p>
<div id="divQ22">
<p>Ans) Exception matching is the process by which the the jvm finds out the matching catch block for the exception thrown from the list of catch blocks. When an exception is thrown, Java will try to find by looking at the available catch clauses in the top down manner. If it doesn&#8217;t find one, it will search for a handler for a supertype of the exception. If it does not find a catch clause that matches a supertype for the exception, then the exception is propagated down the call stack. This process is called exception matching.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q23" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q23"> <strong>Q25) What happens if the handlers for the most specific exceptions is placed above the more general exceptions handler?</strong> </a></p>
<div id="divQ23">
<p>Ans) Compilation fails. 					The catch block for handling the most specific exceptions 					must always be placed above the catch block written to handle the more general exceptions.</p>
<p>e.g. The code below will not compile.</p>
<div>
<blockquote><p>1 try {</p>
<p>// code that can throw IOException or its subtypes</p>
<p>} catch (IOException e) {</p>
<p>// handles IOExceptions and its subtypes</p>
<p>} catch (FileNotFoundException ex) {</p>
<p>// handle FileNotFoundException only</p>
<p>}</p></blockquote>
</div>
<p>The code below will compile successfully :-</p>
<div>
<blockquote><p>try {<br />
// code that can throw IOException or its subtypes<br />
} catch (FileNotFoundException ex)  {<br />
// handles IOExceptions and its subtypes<br />
} catch (IOException e){<br />
// handle FileNotFoundException only<br />
}</p></blockquote>
</div>
</div>
</td>
</tr>
<tr>
<td><a name="Q24" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q24"> <strong> Q26) Does the order of the catch blocks matter if the Exceptions caught by them are not subtype or supertype of each other</strong></a></p>
<div id="divQ24">
<p>Ans) No. If the exceptions are siblings in the Exception class’s hierarchy i.e. If one Exception class is not a subtype or supertype of the other, then the order in which their handlers(catch clauses) are placed does not matter.</p>
</div>
</td>
</tr>
<tr>
<td><a name="Q25" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q25"><strong>Q27) What happens if a method does not throw an checked Exception directly but calls a method that does? What does &#8216;Ducking&#8217; the exception mean?</strong></p>
<p></a></p>
<div id="divQ25">
<p>Ans) If a method does not throw an checked Exception directly but calls a method that throws an exception then the calling method must handle the throw exception or declare the exception in its throws clause. If the calling method does not handle and declares the exception, the exceptions is passed to the next method in the method stack. This is called as ducking the exception down the method stack.</p>
<p>e.g. The code below will not compile as the getCar() method has not declared the CarNotFoundException which is thrown by the getColor () method.</p>
<div>
<blockquote><p>void getCar() {</p>
<blockquote><p>getColor();</p></blockquote>
<p>}</p>
<p>void getColor () {</p>
<blockquote><p>throw new CarNotFoundException();</p></blockquote>
<p>}</p></blockquote>
</div>
<p>Fix for the above code is</p>
<div>
<blockquote><p>void getCar() throws CarNotFoundException {</p>
<blockquote><p>getColor();</p></blockquote>
<p>}</p>
<p>void getColor () {</p>
<blockquote><p>throw new CarNotFoundException();</p></blockquote>
<p>}</p></blockquote>
</div>
</div>
</td>
</tr>
<tr>
<td><a name="Q26" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q26"> <strong>Q28) Is an empty catch block legal?</p>
<p></strong></a></p>
<div id="divQ26">
<p>Ans) Yes you can leave the catch block without writing any actual code to handle the exception caught.</p>
<p>e.g. The code below is legal but not appropriate, as in this case you will nt get any information about the exception thrown.</p>
<blockquote><p>try{</p>
<p>//code that may throw the FileNotFoundException</p>
<p>}catch(FileNotFound eFnf){</p>
<p>//no code to handle the FileNotFound exception</p>
<p>}</p>
<p>&#160;</p>
</blockquote>
</div>
</td>
</tr>
<tr>
<td><a name="Q27" href="http://www.java-questions.com/Exceptions_interview_questions.html#Q27"><strong>Q29)Can a catch block throw the exception caught by itself?</strong></p>
<p></a></td>
</tr>
</tbody>
</table>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Crawl In a Hole and Die]]></title>
<link>http://joelbennett.wordpress.com/2009/11/10/crawl_in_a_hole/</link>
<pubDate>Tue, 10 Nov 2009 16:15:06 +0000</pubDate>
<dc:creator>Joel</dc:creator>
<guid>http://joelbennett.wordpress.com/2009/11/10/crawl_in_a_hole/</guid>
<description><![CDATA[There are a few things of late that have really gotten on my nerves. Here they are: [em]Exceptions h]]></description>
<content:encoded><![CDATA[There are a few things of late that have really gotten on my nerves. Here they are: [em]Exceptions h]]></content:encoded>
</item>
<item>
<title><![CDATA[Things I learnt in the past week!]]></title>
<link>http://dipanjantalks.wordpress.com/2009/11/01/things-i-learnt-in-the-past-week/</link>
<pubDate>Sat, 31 Oct 2009 18:34:30 +0000</pubDate>
<dc:creator>dipanjantalks</dc:creator>
<guid>http://dipanjantalks.wordpress.com/2009/11/01/things-i-learnt-in-the-past-week/</guid>
<description><![CDATA[As the title says&#8230; Boys can’t concentrate nicely, when girls send them love letters. There are]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>As the title says&#8230;</p>
<ul>
<li>Boys can’t concentrate nicely, when girls send them love letters. There are exceptions.</li>
<li>Girls, who don’t like you, always have some problem with you. They just hate you.</li>
<li>Fox News isn’t News. <span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/o3LUid0IZ2w&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' /><param name='allowfullscreen' value='true' /><param name='wmode' value='transparent' /><embed src='http://www.youtube.com/v/o3LUid0IZ2w&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='transparent'></embed></object></span></li>
<li>Dhoni has not lost his touch, yet. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </li>
<li>The <a href="http://ultrabrown.com/posts/the-kolkata-derby" target="_blank">Kolkata Derby</a> has not lost its sheen. But it is ruining Indian Football.</li>
<li>The New Facebook Live Feed is lame although innovative.</li>
<li>Tanmay is a Philosopher.</li>
<li>Iohannes would chose playing PES 2010 over any other comfort in this world.</li>
<li>When I love someone, I become mad, and almost too passionate for the other person’s comfort.</li>
<li>Indira Gandhi still has her share of Haters and Fans, and still is as controversial as ever.</li>
<li>George Bush is not a hated personality in India. That&#8217;s why I say India is different from the World.</li>
<li>Aamir is going all out for his Next Film’s promotion, 3 Idiots. Maybe taking some cue from the Publicity Freak, SRK.</li>
<li>My sister has still not grown up. Sometimes, she is such a kiddo.</li>
<li>People read my Blog, even though I don’t ask them to.</li>
<li>Iohannes is less lazy than me.</li>
<li>2 States: Love Story of My Marriage, is Chetan Bhagat’s life story.</li>
<li>I can type very fast in my Cell phone. Very fast. At least, faster than others. That’s because I have a proper keyboard in my cell.</li>
<li>I hate Physics. I never did before.</li>
<li>I love Biology. I always did.</li>
<li>If given a chance, I can sleep for 15 hours or more.</li>
<li>I love School, when I go i.e.</li>
<li>I get screwed up much more than a normal person.</li>
<li>I miss my Childhood. Maybe, The moments I had in it more.</li>
<li>I should have become a Footballer. I was talented.</li>
<li>Channel [V] is no MTV. MTV is no VH1.</li>
<li>Pen is mightier than the sword. Sometimes, literally.</li>
<li>MS Windows 7 is better than Windows Vista. You expected something more? Don&#8217;t tell me!</li>
<li>I like KFC’s brand of chicken. I love McDonald&#8217;s more.</li>
<li>The applications available for iPhone is better, qualitatively and quantity wise too.</li>
<li>My Maa gains weight very damn fast. That’s more because of her thyroid problems.</li>
<li>I am very lazy. I cannot keep up to my promises. I forget things easily.</li>
<li>Mohit aspires to be a teacher.</li>
<li>Its fun annoying Maheen. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </li>
<li>Everybody in Bengal knows about Classical Music. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </li>
<li>Girls have a fetish for Bags, Shoes, Lip-Stick, Junk [Costume] Jewelery, Kajal. Some exceptions are always there.</li>
<li>I can love Physics, provided the teacher is good enough. And good-looking.</li>
</ul>
<p>I need to sleep now. Enough of what I have learnt.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[What is Real Peace?]]></title>
<link>http://citizenmundi.wordpress.com/2009/10/18/what-is-real-peace/</link>
<pubDate>Sun, 18 Oct 2009 23:52:32 +0000</pubDate>
<dc:creator>Administrator</dc:creator>
<guid>http://citizenmundi.wordpress.com/2009/10/18/what-is-real-peace/</guid>
<description><![CDATA[defeated option Peace is the absence of conflict. The greatest conflict that mankind faces is the co]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2><span style="color:#000080;"><em><em><em><em>defeated option</em></em></em></em></span></h2>
<p style="text-align:justify;"><span style="color:#333333;">Peace is the absence of conflict. The greatest conflict that mankind faces is the conflict between his natural instincts and the delusions he has created. Man’s natural instinct is to be free and independe<span style="color:#333333;">nt vs. a belief that he must control or obey.</span></span></p>
<p><span style="color:#333333;">As long as mankind has the delusion he has the right to control others, he will be in conflict with others. As long as mankind has the delusion he must obey, he will be in conflict with himself. Without freedom and independence mankind cannot even choose what to believe, his speech and behavior will be dictated by others.</span></p>
<p><span style="color:#333333;">Obedience, control of others and punishment have absolutely nothing to do with self-defense. We can all retain the right to defend ourselves while allowing others the same right. Punishment is having absolute control over others. When someone controls others, others cannot possibly have the same right.</span></p>
<p><span style="color:#333333;">Surrender is to relinquish possession or control of something because of coercion or force, it is not peace. The absence of violence is an illusion of peace. The conflict is temporally put on hold, while the conquered regroup.</span></p>
<p><span style="color:#333333;">Living in Utopia may not be possible, but peace is an ideal and perfect place or state, where everyone lives in harmony and everything is for the best.</span></p>
<p><span style="color:#333333;">Peace is the absence of conflict. Peace is NOT the subduing of an enemy.</span></p>
<p><span style="color:#333333;">Citizen Mundi support real peace?</span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Integrating Exception Handling Into the Development Cycle : LeeDumond.com]]></title>
<link>http://enggtech.wordpress.com/2009/10/15/integrating-exception-handling-into-the-development-cycle-leedumond-com/</link>
<pubDate>Thu, 15 Oct 2009 14:36:57 +0000</pubDate>
<dc:creator>Visitor Blogs</dc:creator>
<guid>http://enggtech.wordpress.com/2009/10/15/integrating-exception-handling-into-the-development-cycle-leedumond-com/</guid>
<description><![CDATA[The importance of handling only specific exceptions. I post a few articles and write a book about ex]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The <a href="http://leedumond.com/blog/friends-dont-let-friends-catch-exception/" target="_blank">importance of handling only specific exceptions</a>. I <a href="http://leedumond.com/tags/exception/" target="_blank">post a few articles</a> and <a href="http://www.wrox.com/WileyCDA/WroxTitle/Robust-ASP-NET-Exception-Handling.productCd-047050367X.html" target="_blank">write a book</a> about exception handling, and all of a sudden I’m Mr. Exception Guy. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<ol>
<li>Use the available documentation to discover which exceptions are possible.</li>
<li>Determine which exceptions you can safely ignore, based on current state.</li>
<li>Where possible, use defensive programming techniques to prevent exceptions from being thrown.</li>
<li>Determine which of the remaining exceptions you should handle, and develop a strategy for doing so.</li>
<li>Allow any exceptions you cannot completely handle in code to propagate to your default exception handler.</li>
</ol>
<p><a href="http://leedumond.com/blog/integrating-exception-handling-into-the-development-cycle/">Integrating Exception Handling Into the Development Cycle : LeeDumond.com</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Test Run: Group Determination In Software Testing]]></title>
<link>http://enggtech.wordpress.com/2009/10/14/test-run-group-determination-in-software-testing/</link>
<pubDate>Wed, 14 Oct 2009 18:23:23 +0000</pubDate>
<dc:creator>Visitor Blogs</dc:creator>
<guid>http://enggtech.wordpress.com/2009/10/14/test-run-group-determination-in-software-testing/</guid>
<description><![CDATA[Pure Plurality and Majority Runoff Borda Count System Condorcet Technique and Schulze Method The Sch]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span><a href="http://msdn.microsoft.com/en-us/magazine/dd148646.aspx#id0070007">Pure Plurality and Majority Runoff</a><br />
<a href="http://msdn.microsoft.com/en-us/magazine/dd148646.aspx#id0070019">Borda Count System</a><br />
<a href="http://msdn.microsoft.com/en-us/magazine/dd148646.aspx#id0070030">Condorcet Technique and Schulze Method</a><br />
<a href="http://msdn.microsoft.com/en-us/magazine/dd148646.aspx#id0070046">The Schulze Method in Code</a><br />
<a href="http://msdn.microsoft.com/en-us/magazine/dd148646.aspx#id0070114">More to Evaluate</a></span></p>
<p>two different multi-attribute decision techniques in the June 2005 (<a href="http://msdn.microsoft.com/magazine/cc163785">msdn.microsoft.com/magazine/cc163785</a>) and October 2006 (<a href="http://msdn.microsoft.com/magazine/cc300812">msdn.microsoft.com/magazine/cc300812</a>) installments of the Test Run column.</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/dd148646.aspx">Test Run: Group Determination In Software Testing</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Garbage Collection]]></title>
<link>http://enggtech.wordpress.com/2009/10/12/garbage-collection/</link>
<pubDate>Mon, 12 Oct 2009 06:50:14 +0000</pubDate>
<dc:creator>Visitor Blogs</dc:creator>
<guid>http://enggtech.wordpress.com/2009/10/12/garbage-collection/</guid>
<description><![CDATA[In the .NET Framework version 1.0, the common language runtime (CLR) has a separate memory manager f]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In the .NET Framework version 1.0, the common language runtime (CLR) has a separate memory manager for the large object heap. Under some circumstances this memory manager does not return unused memory to the operating system, and in a few cases it does not make the memory available for garbage collection. This results in failure to allocate memory due to virtual address space fragmentation. In the .NET Framework versions 1.1 and 2.0, the large object heap is composed of contiguous areas of memory called heap segments, properly aligned to minimize virtual memory fragmentation. During garbage collection, the space reclaimed from large objects is consolidated and placed in a free list. Heap segments containing only free list items are freed and the memory is returned to the operating system. These changes to the large object heap have effectively eliminated memory allocation failures caused by this form of virtual address space fragmentation.</p>
<p>via <a href="http://msdn.microsoft.com/en-us/library/0xy59wtx.aspx">Garbage Collection</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using Statement (Visual Basic)]]></title>
<link>http://enggtech.wordpress.com/2009/10/12/using-statement-visual-basic/</link>
<pubDate>Mon, 12 Oct 2009 05:18:19 +0000</pubDate>
<dc:creator>Visitor Blogs</dc:creator>
<guid>http://enggtech.wordpress.com/2009/10/12/using-statement-visual-basic/</guid>
<description><![CDATA[Behavior A Using block behaves like a Try&#8230;Finally construction in which the Try block uses the]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h3 class="subHeading">Behavior</h3>
<div class="subsection">
<p>A <span><span class="input">Using</span></span> block behaves like a <span><span class="input">Try</span></span>&#8230;<span><span class="input">Finally</span></span> construction in which the <span><span class="input">Try</span></span> block uses the resources and the <span><span class="input">Finally</span></span> block disposes of them. Because of this, the <span><span class="input">Using</span></span> block guarantees disposal of the resources, no matter how you exit the block. This is true even in the case of an unhandled exception, except for a <span><a id="ctl00_MTCS_main_ctl21_ctl00_ctl00" href="http://msdn.microsoft.com/en-us/library/system.stackoverflowexception.aspx">StackOverflowException</a></span>.</p>
<p>The scope of every resource variable acquired by the <span><span class="input">Using</span></span> statement is limited to the <span><span class="input">Using</span></span> block.</p>
<p>If you specify more than one system resource in the <span><span class="input">Using</span></span> statement, the effect is the same as if you nested <span><span class="input">Using</span></span> blocks one within another.</div>
<h3 class="subHeading">Structured Exception Handling Within a Using Block</h3>
<div class="subsection">
<p>If you need to handle an exception that might occur within the <span><span class="input">Using</span></span> block, you can add a complete <span><span class="input">Try</span></span>&#8230;<span><span class="input">Finally</span></span> construction to it. If you need to handle the case where the <span><span class="input">Using</span></span> statement is not successful in acquiring a resource, you can test to see if <span class="parameter">resourcename</span> is <span><span class="input">Nothing</span></span>.</div>
<h3 class="subHeading">Structured Exception Handling Instead of a Using Block</h3>
<div class="subsection">
<p>If you need finer control over the acquisition of the resources, or you need additional code in the <span><span class="input">Finally</span></span> block, you can rewrite the <span><span class="input">Using</span></span> block as a <span><span class="input">Try</span></span>&#8230;<span><span class="input">Finally</span></span> construction. The following example shows skeleton <span><span class="input">Try</span></span> and <span><span class="input">Using</span></span> constructions that are equivalent in the acquisition and disposal of <span class="code">resource</span>.</p>
<p><span id="ctl00_MTCS_main_ctl21_ctl00_ctl01"></p>
<div id="ctl00_MTCS_main_ctl21_ctl00_ctl01_" class="libCScode">
<div class="CodeSnippetTitleBar">
<div class="CodeDisplayLanguage"></div>
</div>
<div style="background-color:#dddddd;" dir="ltr">
<pre class="libCScode" style="white-space:pre-wrap;">Using resource As New resourceType
    ' Insert code to work with resource.
End Using
' THE FOLLOWING TRY CONSTRUCTION IS EQUIVALENT TO THE USING BLOCK
Dim resource As New resourceType
Try
    ' Insert code to work with resource.
Catch ex As Exception
    ' Insert code to process exception.
Finally
    ' Insert code to do additional processing before disposing of resource.
    resource.Dispose()
End Try</pre>
</div>
</div>
<p></span></div>
<p><a href="http://msdn.microsoft.com/en-us/library/htd05whh.aspx">Using Statement (Visual Basic)</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Exceptions, Error Handlers: How to Guides: .NET Reference]]></title>
<link>http://enggtech.wordpress.com/2009/10/11/exceptions-error-handlers-how-to-guides-net-reference/</link>
<pubDate>Sun, 11 Oct 2009 19:34:44 +0000</pubDate>
<dc:creator>Visitor Blogs</dc:creator>
<guid>http://enggtech.wordpress.com/2009/10/11/exceptions-error-handlers-how-to-guides-net-reference/</guid>
<description><![CDATA[Exception Class (System). Visual Basic (Declaration) &lt;SerializableAttribute&gt; _ &lt;ComVisibleA]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span><span id="ctl00_MTCS_main_ctl222_ctl00_ctl00"></p>
<div id="ctl00_MTCS_main_ctl222_ctl00_ctl00_VisualBasicDeclaration" class="libCScode">
<div class="CodeSnippetTitleBar">
<div class="CodeDisplayLanguage"><strong><a href="http://msdn.microsoft.com/en-us/library/system.exception.aspx">Exception Class (System)</a></strong>.</div>
<div class="CodeDisplayLanguage"></div>
<div class="CodeDisplayLanguage">Visual Basic (Declaration)</div>
</div>
<div style="background-color:#dddddd;" dir="ltr">
<pre class="libCScode" style="white-space:pre-wrap;">&#60;SerializableAttribute&#62; _
&#60;ComVisibleAttribute(<span style="color:blue;">True</span>)&#62; _
&#60;ClassInterfaceAttribute(ClassInterfaceType.None)&#62; _
<span style="color:blue;">Public</span> <span style="color:blue;">Class</span> Exception _
    <span style="color:blue;">Implements</span> ISerializable, _Exception</pre>
</div>
</div>
<p></span></span></p>
<p><span>A <span><span class="input">catch</span></span> block handles an exception of type <span><span class="input">T</span></span> if the type filter of the catch block specifies <span><span class="input">T</span></span> or any type that <span><span class="input">T</span></span> derives from. The system stops searching after it finds the first <span><span class="input">catch</span></span> block that handles the exception. For this reason, in application code, a <span><span class="input">catch</span></span> block that handles a type must be specified before a <span><span class="input">catch</span></span> block that handles its <strong>base types</strong>, as demonstrated in the example that follows this section. A catch block that handles <strong><span><span class="input">System.Exception</span></span></strong> is specified last.</span></p>
<p><span>If none of the <span><span class="input">catch</span></span> blocks associated with the current <span><span class="input">try</span></span> block handle the exception, and the current <span><span class="input">try</span></span> block is nested within other <span><span class="input">try</span></span> blocks in the current call, the <span><span class="input">catch</span></span> blocks associated with the next enclosing <span><span class="input">try</span></span> block are searched. If no <span><span class="input">catch</span></span> block for the exception is found, the system searches previous nesting levels in the current call. If no <span><span class="input">catch</span></span> block for the exception is found in the current call, the exception is passed up the call stack, and the previous stack frame is searched for a <span><span class="input">catch</span></span> block that handles the exception. The search of the call stack continues until the exception is handled or until <strong>no more frames exist on the call stack</strong></span></p>
<p><span></p>
<h3 class="subHeading">Exception Type Categories</h3>
<div class="subsection">
<p>Two categories of exceptions exist under the base class <span><span class="selflink">Exception</span></span>:</p>
<ul>
<li>The pre-defined common language runtime exception classes derived from <span><a id="ctl00_MTCS_main_ctl223_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/system.systemexception.aspx">SystemException</a></span>.</li>
<li>The user-defined application exception classes derived from <span><a id="ctl00_MTCS_main_ctl223_ctl00_ctl03" href="http://msdn.microsoft.com/en-us/library/system.applicationexception.aspx">ApplicationException</a></span>.</li>
</ul>
<p><span></p>
<h3 class="subHeading">Performance Considerations</h3>
<div class="subsection">
<p>A significant amount of system resources and execution time are used when you throw or handle an exception. Throw exceptions only to handle truly extraordinary conditions, not to handle predictable events or flow control. For example, your application can reasonably throw an exception if a method argument is invalid because you expect to call your method with valid parameters. An invalid method argument means something extraordinary has occurred. Conversely, do not throw an exception if user input is invalid because you can expect users to occasionally enter invalid data. In such a case, provide a retry mechanism so users can enter valid input.</p>
<p>Throw exceptions only for extraordinary conditions, then catch exceptions in a general purpose exception handler that applies to the majority of your application, not a handler that applies to a specific exception. The rationale for this approach is that most errors can be handled by validation and error handling code in proximity to the error; no exception needs to be thrown or caught. The general purpose exception handler catches truly unexpected exceptions thrown anywhere in the application.</p>
<p>In addition, do not throw an exception when a return code is sufficient; do not convert a return code to an exception; and do not routinely catch an exception, ignore it, then continue processing.</p>
<p><span> </span><span></p>
<div class="MTPS_CollapsibleRegion">
<div class="CollapseRegionLink"><!-- ApplyClick with current id --> <strong> Thread Safety </strong></div>
<div class="MTPS_CollapsibleSection" style="display:block;"><a id="threadSafetyToggle"></a>Any public <span class="input">static</span> (<span class="input">Shared</span> in Visual Basic)  members of this type are thread safe. Any instance members are not guaranteed to be thread safe.</div>
</div>
<p></span></div>
<p></span></div>
<p></span></p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.exception.aspx"><br />
</a></p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/5b2yeyab.aspx">Handling and Throwing Exceptions</a></strong>.</p>
<p>Allows exceptions to be thrown across process and even machine boundaries.</p>
<p>Exceptions offer several advantages over other methods of error notification, such as return codes. Failures do not go unnoticed. Invalid values do not continue to propagate through the system. You do not have to check return codes. Exception-handling code can be easily added to increase program reliability. Finally, the runtime&#8217;s exception handling is faster than Windows-based C++ error handling.</p>
<p>Because execution threads routinely traverse managed and unmanaged blocks of code, the runtime can throw or catch exceptions in either managed or unmanaged code. Unmanaged code can include both <strong>C++-style SEH </strong>Exceptions and <strong>COM-based</strong> HRESULTS.</p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/system.applicationexception.aspx">ApplicationException Class (System)</a></strong></p>
<p>If you are designing an application that needs to create its own exceptions, you are advised to derive custom exceptions from the Exception class. It was originally thought that custom exceptions should derive from the ApplicationException class; however in practice this has not been found to add significant value.</p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/system.systemexception.aspx">SystemException Class (System)</a></strong></p>
<p>SystemException does not provide information as to the cause of the Exception. In most scenarios, instances of this class should not be thrown. In cases where this class is instantiated, a human-readable message describing the error should be passed to the constructor.</p>
<p>SystemException is thrown by the common language runtime when errors occur that are nonfatal and recoverable by user programs. These errors result from failed runtime check (such as an array out-of-bound error), and can occur during the execution of any method. SystemException adds no new functionality to Exception.</p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/6kzk0czb.aspx">Exceptions Overview</a>.</strong></p>
<p><span>The runtime uses an exception handling model based on exception objects and protected blocks of code. An <span><a id="ctl00_MTCS_main_ctl19_ctl00_ctl00" href="http://msdn.microsoft.com/en-us/library/system.exception.aspx">Exception</a></span> object is created to represent an exception when it occurs.</p>
<p>The runtime creates an exception information table for each executable. Each method of the executable has an associated array of exception handling information (which can be empty) in the exception information table. Each entry in the array describes a protected block of code, any exception filters associated with that code, and any exception handlers (catch statements). This exception table is extremely efficient and there is no performance penalty in processor time or in memory use when an exception does not occur. You use resources only when an exception occurs.</p>
<p>The exception information table represents four types of exception handlers for protected blocks:</p>
<ul>
<li>A finally handler that executes whenever the block exits, whether that occurs by normal control flow or by an unhandled exception.</li>
<li>A fault handler that must execute if an exception occurs, but does not execute on completion of normal control flow.</li>
<li>A type-filtered handler that handles any exception of a specified class or any of its derived classes.</li>
<li>A user-filtered handler that runs user-specified code to determine whether the exception should be handled by the associated handler or should be passed to the next protected block.</li>
</ul>
<p>Each language implements these exception handlers according to its specifications. For example, Visual Basic 2005 provides access to the user-filtered handler through a variable comparison (using the <strong>When</strong> keyword) in the catch statement; C# does not implement the user-filtered handler.</p>
<p></span></p>
<p>Note that the order of exception handlers is important: the innermost exception handler is evaluated first. Also note that exception handlers can access the local variables and local memory of the routine that catches the exception, but any intermediate values at the time the exception is thrown are lost.</p>
<p>If no match occurs in the current method, the runtime searches each caller of the current method, and it continues this path all the way up the stack. If no caller has a match, the runtime allows the debugger to access the exception. If the debugger does not attach to the exception, the runtime raises the <span><a id="ctl00_MTCS_main_ctl19_ctl00_ctl01" href="http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx">UnhandledException</a></span> event. If there are no listeners for the <strong>UnhandledException</strong> event, the runtime dumps a stack trace and ends the program.</p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/5whzhsd2.aspx">Exception Class and Properties</a></strong>.</p>
<p>The <span><a id="ctl00_MTCS_main_ctl01" href="http://msdn.microsoft.com/en-us/library/system.exception.aspx">Exception</a></span> class is the base class from which exceptions inherit. Most exception objects are instances of some derived class of<strong> Exception</strong>, but you can throw any object that derives from the <span><a id="ctl00_MTCS_main_ctl02" href="http://msdn.microsoft.com/en-us/library/system.object.aspx">Object</a></span> class as an exception.</p>
<blockquote><p>Note that not all languages support throwing and catching objects that do not derive from <strong>Exception</strong>. In almost all cases, it is recommended to throw and catch only <strong>Exception</strong> objects.</p></blockquote>
<p><span> </span><strong>The <span><a id="ctl00_MTCS_main_ctl04" href="http://msdn.microsoft.com/en-us/library/system.exception.innerexception.aspx">InnerException</a></span> property. </strong></p>
<p>This property can be used to create and preserve a series of exceptions during exception handling. You can use this property to create a new exception that contains previously caught exceptions. The original exception can be captured by the second exception in the <strong>InnerException</strong> property, allowing code that handles the second exception to examine the additional information.</p>
<ul>
<li>For example, suppose you have a method that reads a file and formats the data. The code tries to read from the file, but a FileException is thrown. The method catches the FileException and throws a BadFormatException. In this case, the FileException can be saved in the <strong>InnerException</strong> property of the BadFormatException.</li>
</ul>
<p>To improve the caller&#8217;s ability to determine the reason an exception is thrown, it is sometimes desirable for a method to catch an exception thrown by a helper routine and then throw an exception more indicative of the error that has occurred. A new and more meaningful exception can be created, where the inner exception reference can be set to the original exception. This more meaningful exception can then be thrown to the caller. Note that with this functionality, you can create a series of linked exceptions that ends with the exception that was thrown first.</p>
<blockquote><p>It is not recommended that you catch a <strong>SystemException</strong>, nor is it good programming practice to throw a <strong>SystemException</strong> in your application.</p></blockquote>
<p>The most severe exceptions — those thrown by the runtime or in nonrecoverable conditions — include</p>
<ul>
<li><span><a id="ctl00_MTCS_main_ctl07" href="http://msdn.microsoft.com/en-us/library/system.executionengineexception.aspx">ExecutionEngineException</a></span>,</li>
<li><span><a id="ctl00_MTCS_main_ctl08" href="http://msdn.microsoft.com/en-us/library/system.stackoverflowexception.aspx">StackOverflowException</a></span>,</li>
<li><span><a id="ctl00_MTCS_main_ctl09" href="http://msdn.microsoft.com/en-us/library/system.outofmemoryexception.aspx">OutOfMemoryException</a></span>.</li>
</ul>
<p>Interoperation exceptions derive from <strong>SystemException</strong> and are further extended by <span><a id="ctl00_MTCS_main_ctl10" href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.externalexception.aspx">ExternalException</a></span>.</p>
<ul>
<li><span><a id="ctl00_MTCS_main_ctl11" href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comexception.aspx">COMException</a></span> is the exception thrown during COM interop operations and derives from <strong>ExternalException</strong>.</li>
<li><span><a id="ctl00_MTCS_main_ctl12" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.win32exception.aspx">Win32Exception</a></span></li>
<li><span><a id="ctl00_MTCS_main_ctl13" href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.sehexception.aspx">SEHException</a></span></li>
</ul>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/seyhszts.aspx">Best Practices for Handling Exceptions</a></strong>.</p>
<p>1. Know when to set up a try/catch block. For example, you can programmatically check for a condition that is likely to occur without using exception handling. In other situations, using exception handling to catch an error condition is appropriate.</p>
<p>The method you choose depends on how often you expect the event to occur. If the event is truly exceptional and is an error (such as an unexpected end-of-file), using exception handling is better because less code is executed in the normal case. If the event happens routinely, using the programmatic method to check for errors is better. In this case, if an exception occurs, the exception will take longer to handle.</p>
<ul>
<li>When creating <strong>user-defined exceptions,</strong> you must ensure that the metadata for the exceptions is available to code executing remotely, including when exceptions occur across application domains. For example, suppose <strong>Application Domain </strong>A creates Application Domain B, which executes code that throws an exception. For Application Domain A to properly catch and handle the exception, it must be able to find the assembly containing the exception thrown by Application Domain B. If Application Domain B throws an exception that is contained in an assembly under its application base, but not under Application Domain A&#8217;s application base, Application Domain A will not be able to find the exception and the common language runtime will throw a <span><a id="ctl00_MTCS_main_ctl07" href="http://msdn.microsoft.com/en-us/library/system.io.filenotfoundexception.aspx">FileNotFoundException</a></span>. To avoid this situation, you can deploy the assembly containing the exception information in two ways:
<ul>
<li>Put the assembly into a common application base shared by both application domains
<p>- or -</li>
<li>If the domains do not share a common application base, sign the assembly containing the exception information with a <strong>strong name </strong>and deploy the assembly into the <strong>global assembly cache</strong>.</li>
</ul>
</li>
</ul>
<ul>
<li>In C# and C++, use at least the <strong>three common constructors</strong> when creating your own exception classes. For an example, see <span><a id="ctl00_MTCS_main_ctl08" href="http://msdn.microsoft.com/en-us/library/87cdya3t.aspx">How to: Create User-Defined Exceptions</a></span>.</li>
</ul>
<div class="CollapseRegionLink"><strong><span id="ctl00_MTCS_main_ctl18_ctl00_ctl00"> Visual Basic </span>Example </strong></div>
<div class="MTPS_CollapsibleSection" style="display:block;"><a id="exampleToggle"></a><span id="ctl00_MTCS_main_ctl18_ctl00_ctl00"></p>
<div id="ctl00_MTCS_main_ctl18_ctl00_ctl00_VisualBasic" class="libCScode">
<div class="CodeSnippetTitleBar">
<div class="CodeDisplayLanguage"></div>
</div>
<div style="background-color:#dddddd;" dir="ltr">
<pre class="libCScode" style="white-space:pre-wrap;"><span style="color:blue;">Imports</span> System
<span style="color:blue;">Public</span> <span style="color:blue;">Class</span> EmployeeListNotFoundException
   <span style="color:blue;">Inherits</span> Exception

   <span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> <span style="color:blue;">New</span>()
   <span style="color:blue;">End</span> <span style="color:blue;">Sub</span> <span style="color:green;">'New</span>

   <span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> <span style="color:blue;">New</span>(message <span style="color:blue;">As</span> <span style="color:blue;">String</span>)
      <span style="color:blue;">MyBase</span>.New(message)
   <span style="color:blue;">End</span> <span style="color:blue;">Sub</span> <span style="color:green;">'New</span>

   <span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> <span style="color:blue;">New</span>(message <span style="color:blue;">As</span> <span style="color:blue;">String</span>, inner <span style="color:blue;">As</span> Exception)
      <span style="color:blue;">MyBase</span>.New(message, inner)
   <span style="color:blue;">End</span> <span style="color:blue;">Sub</span> <span style="color:green;">'New</span>
<span style="color:blue;">End</span> <span style="color:blue;">Class</span> <span style="color:green;">'EmployeeListNotFoundException</span></pre>
</div>
</div>
<p></span></div>
<ul>
<li>Return null for extremely common error cases. For example, <span><a id="ctl00_MTCS_main_ctl12" href="http://msdn.microsoft.com/en-us/library/system.io.file.open.aspx">Open</a></span> returns <span><span class="input">null</span></span> if the file is not found, but throws an exception if the file is locked.</li>
<li>Design classes so that an exception is <strong>never thrown in normal </strong>use. For example, a <span><a id="ctl00_MTCS_main_ctl13" href="http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx">FileStream</a></span> class exposes another way of determining whether the end of the file has been reached. This avoids the exception that is thrown if you read past the end of the file.</li>
<li>Use <strong>exception builder methods</strong>. It is common for a class to throw the same exception from different places in its implementation. To avoid excessive code, use helper methods that create the exception and return it. For example:
<p><span id="ctl00_MTCS_main_ctl18"></p>
<div id="ctl00_MTCS_main_ctl18_VisualBasic" class="libCScode">
<div class="CodeSnippetTitleBar">
<div class="CodeDisplayLanguage"><strong>Visual Basic </strong></div>
</div>
<div style="background-color:#dddddd;" dir="ltr">
<pre class="libCScode" style="white-space:pre-wrap;"><span style="color:blue;">Class</span> File
   <span style="color:blue;">Private</span> fileName <span style="color:blue;">As</span> <span style="color:blue;">String</span>

   <span style="color:blue;">Public</span> <span style="color:blue;">Function</span> Read(bytes <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> <span style="color:blue;">Byte</span>()
      <span style="color:blue;">If</span> <span style="color:blue;">Not</span> ReadFile(handle, bytes) <span style="color:blue;">Then</span>
         <span style="color:blue;">Throw</span> NewFileIOException()
      <span style="color:blue;">End</span> <span style="color:blue;">If</span>
   <span style="color:blue;">End</span> <span style="color:blue;">Function</span> <span style="color:green;">'Read</span>

   <span style="color:blue;">Function</span> NewFileIOException() <span style="color:blue;">As</span> FileException
      <span style="color:blue;">Dim</span> description <span style="color:blue;">As</span> <span style="color:blue;">String</span> = __unknown <span style="color:green;">' Build localized string, including fileName.</span>
      <span style="color:blue;">Return</span> <span style="color:blue;">New</span> FileException(description) <span style="color:green;">'</span>
   <span style="color:blue;">End</span> <span style="color:blue;">Function</span> <span style="color:green;">'NewFileIOException</span>
<span style="color:blue;">End</span> <span style="color:blue;">Class</span> <span style="color:green;">'File</span></pre>
</div>
</div>
<p></span></li>
</ul>
<p><a href="http://msdn.microsoft.com/en-us/library/awy7adbx.aspx">Handling COM Interop Exceptions</a>.</p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/s74yzzb5.aspx">Choosing When to Use Structured and Unstructured Exception Handling</a>.</strong></p>
<p>you might use unstructured exception handling under these circumstances:</p>
<ul>
<li>You are upgrading an application written in an <strong>earlier version </strong>of Visual Basic.</li>
<li>You are developing a preliminary or draft version of an application and you don&#8217;t mind if the program fails to shut down gracefully.</li>
<li>You know in advance <strong>exactly what will cause </strong>the exception.</li>
<li>A deadline is pressing, you need to take shortcuts, and are willing to sacrifice flexibility for speed.</li>
<li>Code is trivial or <strong>so short </strong>that you only need to test the branch of code generating the exception.</li>
<li>You need to use the <strong><span><span class="input">Resume Next</span></span> </strong>statement, which is not supported in structured exception handling.</li>
</ul>
<p><span>The <strong>common language runtime </strong>catches exceptions that are not caught by a catch block. Depending on how the runtime is configured, either a debug dialog box appears, or the program stops executing and a dialog box with exception information appears. For information about debugging, see <a id="ctl00_MTCS_main_ctl16_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/7fe0dd2y.aspx">Debugging and Profiling Applications</a>.</span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Men vs. Women: Financial Planning [INFOGRAPHIC]]]></title>
<link>http://pkrf1end.wordpress.com/2009/10/10/men-vs-women-financial-planning-infographic/</link>
<pubDate>Sat, 10 Oct 2009 22:40:14 +0000</pubDate>
<dc:creator>pkrf1end</dc:creator>
<guid>http://pkrf1end.wordpress.com/2009/10/10/men-vs-women-financial-planning-infographic/</guid>
<description><![CDATA[Statistics show that men and women handle money differently. While there are exceptions to every rul]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div style="margin-bottom:10px;border:1px solid #ccc;width:202px;height:142px;background-image:url('http://images.websnapr.com/?size=s&#38;url=http://www.billshrink.com/blog/men-vs-women-financial-planning/');"></div>
<p>Statistics show that men and women handle money differently. </p>
<blockquote><p><em>While there are exceptions to every rule, men generally are better prepared for retirement, are more willing to put money into savings, pay off credit card balances in full and are more educated about investing.</em></p></blockquote>
<p>Source:<br /><a href='http://www.billshrink.com/blog/men-vs-women-financial-planning/'>http://www.billshrink.com/blog/men-vs-women-financial-planning/</a></p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
