<$BlogRSDUrl$>

Wednesday, August 27, 2003

Reading through the whitepaper on .NET Framework Resource Management I noticed a very simple illustration of how nice the using statement is in C#. Consider the following:


MessageQueue queue;
try{
queue = new MessageQueue(“server\\queueName”);
queue.Send(“Hello World”);
}
finally{
queue.Dispose()
}


This try/finally pattern known from Java makes simple code quite verbose, especially if there are multiple objects that need to be released.

Luckily, C# has a very nice way to fix this: the using statement. It provides some very tasty syntactic sugar when dealing with multiple objects:


using(
MessageQueue source = new MessageQueue(“server\\sourceQueue”),
destination = new MessageQueue(“server\\destinationQueue”)
){
Message message = source.Receive();
destination.Send(message);
}



It guarantees that Dispose is called, and you get to write simple, readable code. Syntactic sugar, indeed, but it makes coding in C# a very sweet experience.

Tuesday, August 26, 2003

Jon just IMed me a link to the KartOO search engine. It displays its results as interactive maps. Very nice. I wonder if "to kartoo" will replace the mot-de-jour for searching, "to google"?

I came across this nice tribute to the wonders of espresso in The Economist. Read it, and be prepared to run off for a quick infusion afterwards:

Economist.com | Espresso coffee:

(excerpt)
"Perfect espresso is the ultimate coffee. It ranks with fine wine for the complexity of its chemistry. Unlike wine, however, it does not improve with age. “Espresso” means prepared on the spur of the moment, and it has become the trademark of rich, intense coffee that must also be consumed at once. Its taste is so dense, though, that it can remain in the mouth for up to half an hour after drinking. "
One of my favourite authors, Neil Stephenson, has a new trilogy of books in the works. Read the interview at Wired 11.09: Neal Stephenson Rewrites History: "The Baroque Cycle has scope: The ancestors of Cryptonomicon characters cross paths with Isaac Newton and his peers against a backdrop of several continents, a couple of wars, and one fundamental change in the way humans view the world. In the context of the 1600s, Stephenson examines the nature of money, the interdependency of Europe, and the consequences of transformative scientific advances."

This page is powered by Blogger. Isn't yours?