May 2005 Entries

On C++

There has been some discussion lately about the rise of C++ to first class citizen status in .NET country. Unfortunately, C++ still has one major flaw: the preprocessor. The criminally insane have used the C++ preprocessor over the years to pervert, subvert, and convert otherwise good source code into an atrocious collection of tokens and symbols. I was witness to one of these atrocities in graduate school. One semester I came across a professor who was a Pascal zealot and book author. Although C++ was the official language of the curriculum, Dr. Pascal used the magic of the preprocessor to...

nContract

If you are a fan of Design By Contract, then you’ll find Wes Haggard’s thesis work, nContract, to be an impressive package. nContract allows you to specify contract validations by decorating types and their members with custom attributes. For example: [Pre("value != null")] [Post("Contents.Count == old.Contents.Count + value.Length")] public virtual void Append(string value) {     stringBuilder.Append(value);     numberOfChars += value.Length; } Custom attributes are the perfect place for contract specifications. The pre-condition and post-condition for the Append method will be forever bound to the method and packaged into the metadata. The Append method itself remains clean and easily readable. To actually perform the contract checking, nContract code-gens a subclass for the component using...

That Wacky Office API

Like Ben @ CodeBetter, I admire the power behind the Office API. We finally have some customers buying into the promise of smart clients, and it is amazing to see the amount of functionality available through the object model of Word, Excel, and the rest of the family. But, after reviewing the code, I still think it sucks. The rough edges of interop poke out in every corner, and the constant appearance of Sytem.Object in parameter lists and return values ruins the discoverability. object currentDateBookmark = "CurrentDate"; Word.Range range =     thisDocument.Bookmarks.get_Item(ref currentDateBookmark).Range; "Quit whining", I hear you say. "There is a...

Trouble Pairing?

Having troubles getting pair programming started in your shop? Do you feel it would be easier to breed giant pandas in captivity then it would be to get Pat and Gunther to program together? You need the DICA solution! DICA is a revolutionary new drug manufactured in the best underground pharmaceutical laboratories available, and is guaranteed* to kick start an Xtreme Pair Programming Xperience in your office. For just $99.99 we will send you the DICA Starter Kit, which includes 100 doses of DICA! We are pratically giving it away! Enough DICA for over 800 hours of Xtreme Pair Programming!...

Look Ma, Almost No Dispose

The following code shows some interesting differences when executing under the 1.1 and 2.0 runtimes. class Class1 {     static void Main(string[] args)     {         try         {             for (Int32 i = 0; i < Int32.MaxValue; i++)             {                 SqlConnection connection = new SqlConnection(connectionString);                 connection.Open();                 Thread.Sleep(30);                 Console.WriteLine(i.ToString());             }         }         catch(Exception ex)         {             Console.WriteLine(ex.Message);         }           Console.WriteLine("Finished");     }       static string connectionString = "Data Source=.;Integrated Security=True"; } The program eventuallys throw an exception under both versions of the runtime:: Timeout expired. The timeout period...

A Tip On Query Hints

I try to avoid join and query hints in T-SQL. Adding a hint to a query is like buying a tailored suit. As long as your body doesn’t change - the suit will look great, but a little variation in your weight can turn a great suit into a disaster. Likewise, a query hint might boost the performance of a query on today’s data – but what about next week’s (or the next client’s) data? A hint might handcuff and prevent the query optimizer from formulating a better query plan. In my experience - join hints, index hints, and FORCE...

Included Columns In SQL 2005

Non-clustered indexes in SQL Server contain only the values for the columns they index, and then a ‘pointer’ to the row with the rest of the data. This is similar to the index in a book: the index contains only the key word, and a page reference you can turn to for the rest of the information. Generally, the database will have to follow pointers from the index to other pages (known as bookmark lookups) to gather all the information required for a query. If, however, the index contains all of the columns requested in a query, the savings in disk IO can...

Lurching Out Of Las Vegas

The day after VSLive! wrapped up I stood outside the casino waiting for a shuttle bus to the airport. Unfortunately, the bus drivers seemed mostly grumpy that day and unwilling to cooperate, so another guest and I decided to split the cost of a cab. The cab driver, a tall man with a cowboy hat, lifted our bags into the trunk while the other gentleman and I exchanged the typical pleasantries: where we were from, where we were going, and why we were in Las Vegas. When the cab driver heard I was in software development he asked me if...

Direct Reports

A good place to see the new ReportViewer control in action is in the Web Log Analyzer Starter Kit for Visual Studio Beta 2. This news is via Brian Welcker’s new blog: Direct Reports. Brian is a Group PM for Reporting Services, and the blog is already trove of tips and information.

Last Stop

I’m on the last stop of “the tour” in Las Vegas, Nevada. There are two conferences in town – VSLive! and MEDC. I’ll be presenting twice at VSLive!, and them I’m going to relax with an open schedule for the foreseeable future. Hopefully I’ll get back to doing more writing in the evenings. Here is some old news I’m just catching up on…. Reporting Services Service Pack 2 came out a few weeks ago. One anticipated feature was the client side print capability which adds a print icon to the report toolbar. Behind the little icon is a downloadable...

MAD Code Camp Report

I had a great deal of fun presenting at the Code Camp today, even though one of my Virtual PC’s flaked out and I had to improvise a great deal. Argh! The entire IIS / Visual Studio .NET coupling cannot die soon enough for me. Congrats to G. Andrew D, the MS staff, all the volunteers, and all the speakers for putting on a great camp. Here’s a quick pic of Bill Ryan, Sahil Malik, Wally McClure and Julie Lerhman hanging out by the mobile devices. Hopefully it's legible - the sunlight coming in the window killed my camera

When You've Had Rotten Day ...

.. it's uplifting to find kind words at the Inbox : ... I feel empowered now that the website modification is performing as I designed it. The instructions in Chapter 8 of your book have been my bible the last couple of months in my early a.m. efforts; and now they've paid off. I really feel that I understand the CSK. I wish you much success and entreat you to call upon me if I can somehow humbly be of help to your efforts ... Blue skies to you too, Mike.

APress

Every so often, someone asks me a question about a topic covered in a C# database book with my name on the cover. I sometimes have difficulty answering the question – because I’ve never seen the book. Last October APress contacted me and said that a book I wrote for the old Wrox company was about to be tweaked and republished. I was told to expect paperwork and copies of the book in the mail. The book went on sale in November. The last contact I had with APress was in February. I’m still waiting for anything to arrive in...