DuraSoft  TechLet 04, 2003

In this issue
Welcome to the April 2003 TechLet. If you have received this through some one you know and would like to subscribe directly for our future issues, please send an email to techlet@durasoftcorp.com with a subject subscribe. This subscription currently is absolutely free.

In this issue, we have a detailed article on "Polymorphic Stored Procedure?"

Message from us
If you like any question to be addressed or topic to be discussed, please send us an email to techlet@durasoftcorp.com. At the end of the year, one person will be randomly selected from the list of respondents for a special prize. We would like to hear from you.

Please send suggestions, corrections and comments to techlet@durasoftcorp.com.

In depth
Polymorphic Stored Procedure? A typical user of JDBC or ASP.NET issues a SQL query to the underlying database, grabs the fields returned by the record set/result set (or dataset) and then populates an object with the data fetched. Not considering the use of Entity Beans and JDO in Java, what does one do if the object being fetched is one of several types derived from a common base type? This article addresses one way this can be solved in an extensible manner. The complete article can be found at http://www.durasoftcorp.com/download
Quiz corner
This one should be easy. Given the following Java code excerpt:
	{
		foo(); // foo may throw an Exception
		doSomeThing();

		doSomeThingElse(); //... rest of the code
	}
I want doSomeThing() to be executed irrespective of whether foo throws an exception or not. What is the minimal code I should write to achieve this?

Send your response to techlet@durasoftcorp.com, and you may become the winner of this year's TechLet special prize.


Quiz from the past issue

Make minimal change to the following C# code so that it prints the following output: $22.25 & 89.00 %

using System;

namespace Sample
{
	class Test
	{
		[STAThread]
		static void Main(string[] args)
		{
			double val1 = 22.25;
			double val2 = 0.89;

			Console.WriteLine(val1.ToString() + " & " + val2.ToString());
		}
	}
}

Answer!

Thanks to those who wrote to us with a response to this quiz. Your names have been entered for the year end drawing!

If one should aim for minimum change, here it is. Modify the statement:
Console.WriteLine(val1.ToString() + " & " + val2.ToString());
to:
Console.WriteLine(val1.ToString("c") + " & " + val2.ToString("p"));
Alternately, you may write Console.WriteLine("{0:c} & {1:p}", val1, val2);
Martin, you were the first to respond with a correct answer, though Keith sent us the most accurate answer a couple of hours later!

Thus spake...
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Albert Einstein.