Quick Data Access Layer

While trying to find information on what exceptions a table adapter could throw, I came across this blog post from Scott Guthrie on how to build a data access layer with XSDs in Visual Studio 2005. It’s a nicely-done set of tutorials with plenty of explanations and screenshots. I’m particularly interested in tutorial 8, which describes how custom code can be added (via subclassing or with partial classes). I’m responsible for one application that could probably make great use of this technique.

One of the concerns this technique raises is tight coupling with the database.  An older article by Brian Noyes provides a comparison between strongly-typed datasets and custom business objects that covers the issue quite well.


The Obsolete Attribute

One of the consultants I work with told me about an alternative use of the Obsolete attribute last week.  Its original intent was to identify methods and classes that shouldn’t be used anymore.  But using this:

[Obsolete("",true)]
turns out to be a rather nice refactoring tool as well.  Passing "true" as the second parameter instructs the compiler to flag all uses of a method or class so decorated as errors.  So far, this practice has helped me hunt down the one instance in code where a particular method was used.  Today, I should be able to eliminate an unnecessary custom exception class with it.

Don't Derive from ApplicationException

According to this blog entry (or rather, the annotations), deriving from Exception is the correct course to take. ApplicationException apparently doesn’t provide any discernible value. Coming from the folks who actually built the .NET Framework, that’s quite a surprise to me. I can’t think of any example I’ve seen from Microsoft (or anyone else) on exceptions that doesn’t derive from ApplicationException.

A quick look at my office bookshelf confirms that this guidance is even older than the blog post. In Applied Microsoft .NET Framework Programming, Jeffrey Richter writes the following on pages 410-411:

"... I don't think there is any value in having the SystemException and ApplicationException base types in the exception hierarchy.  In fact, I think having them is just confusing."

Hackers and Fighters

I found this post on "street programmers" and computer scientists quite interesting because I manage a staff where the former outnumbers the latter significantly. In this environment, his conclusion that the street programmer is better than the CS graduate is wrong. The staff that have formal training consistently deliver higher-quality results when compared to the street programmers. The code they produce is easier to maintain and better-tested.

Mark Tarver's definition of street programmer is the exception, not the rule, when it comes to people who write software for a living. It doesn't include the people who got into this line of work because of Internet bubble; people who did it because they saw dollar signs rather than out of a genuine interest. I believe the person who self-teaches well is quite rare indeed.

I can't dispute Tarver's points about the state of computer science education. Far too many of them have been confirmed by friends of mine who are in Ph.D programs now. He's certainly right about the conservatism of CS courses too. I still remember learning Pascal in the early 90s as part of my CS curriculum.

Even with the shortcomings of today's computer science departments, the degree still serves as a useful filter when trying to decide if an interview with someone is likely to be time well spent.  I've also encountered enough good programmers in my time with degrees in math or physics that I'd certainly hire them if they interview well enough.


.NET Progress Bar

I’d managed to avoid all .NET WinForms work of any consequence until today.  We’ve assigned one of our developers to fix an application in need of a working progress bar.  Since I haven’t done this before today, I’m scrambling to get up to speed on the right way to do this.

This article looks like a good place to start.


Microsoft vs. Open Source--Don't Worry

That’s the gist of this rather comforting post at groklaw.net about Microsoft’s claims of Linux patent infringement. It baffles me that a company which made over $12 billion in profits last fiscal year would stoop to the sort of patent trolling last seen from SCO Group.  It seems desperate.  It’s the kind of move I would expect from a company who had clearly lost the battle in the marketplace and didn’t have any other cards to play.


UML Sequence Diagrams Intro

I came across this link on UML sequence diagrams via Mike Gunderloy’s blog.  While the site is pitching a product (TraceModeler), it does a nice job of explaining the utility of sequence diagrams.


Another MacBook Pro Owner

I picked up my Intel Mac last week.  It will soon replace the Mac mini I bought in February 2005, and the Dell PC I bought a couple of years before that.  It’s the first laptop I’ve had that wasn’t issued to me by an employer.  So far, I think I’m going to be very happy with it.

The first impromptu performance test was this: can the MacBook Pro handle simultaneous installations of Windows XP Pro (in Parallels for Mac) and World of Warcraft (direct to the Mac)?  The answer turned out to be yes, even with over a gigabyte worth of WoW upgrades (and nearly 80 patches to Windows XP Pro, not including SP2).

The next items on the the to-do list for setting it up are these:

  • Install most of the stuff described here
  • Transfer data from the Mac mini
  • Install Microsoft Office 2003 on the Windows XP virtual machine
Sometime after this, I'll attempt to install Visual Studio 2005 in the virtual machine and see how it works.

Resetting passwords with .NET membership provider

Say you have a user with no password question and answer. It turns out that calling ResetPassword() on that user will throw an exception. There’s an overload that takes password answer as a parameter, which also throws an exception if the wrong answer is provided.

The way to get around this issue for me turned out to be changing “requiresQuestionAndAnswer” to “false” in the membership provider configuration.


Classic OO Anti Patterns

I started reading programming.reddit.com not long ago. Today, I came across Classic Oo Anti Patterns. It does a great job of describing many of the problems I see in code I inherited at my current job (and a lot of the previous ones too).


GUID vs. Identity Column for Primary Keys

From the time I started using databases (Sybase 10, Microsoft SQL Server 6.5), I’d always used identity columns for primary keys in tables.  So when I came to my current employer and saw GUIDs all over the place, I wondered if that wasn’t overkill.

I did a bit of searching on the issues, and came up with these links:

The authors of these pieces can reasonably be described as pro-GUID.  They are up-front about the drawbacks of their preferred option (performance is a big one).  I tried the tip on using NewSequentialId() instead of NewId() (from Jeff Atwood) , but SQL Server Management Studio kept giving me errors when I attempted to update the default value of a table column to use it.

Recursive FindControl with Generics

Came across this via Larkware.  I’ll have to make sure this code finds its way into our custom base pages.


Unit testing framework for BizTalk solutions

I didn’t know such a thing existed before today, but thanks to a couple of consultants in my office, now I do. The cleverly-named BizUnit is available at codeplex.

The information on this project indicates no dependencies on any existing unit-testing frameworks (NUnit, MbUnit, etc).  Having not used BizUnit, I’m not sure whether that’s good or bad either way.


Unit testing assemblies with internals

How do you unit test an assembly if the vast majority of its methods are declared “internal” (in C#)? Before today, I had no idea. Fortunately for me, one of my consultants had this exact problem last year. The solution:

[assembly: InternalsVisibleTo("UnitTestAssemblyName")]
Putting the following line in AssemblyInfo.cs for the assembly you wish to unit test makes everything declared "internal" available to UnitTestAssemblyName.

This is a vastly superior option to cloning the assembly you want to test and making all the internal members public.


A rant on programmers who can't program

I came across this post today and wasn’t sure what to make of it.  In my current job and my previous one, interviewing potential hires for programming was part of my job.  I can’t say I ever used “FizzBuzz” types of questions on candidates, and I’m not sure that would tell me the sort of things I need to know about someone.  I find myself asking a lot more design questions and process questions with perhaps one or two programming questions thrown in.  But before even getting to that stage, I have to feel good about their resume.  I think the majority of people give you enough information in their resume that you can figure out whether a phone screen is worthwhile in a relatively short period of time.


Working with virtual machines

A few weeks ago, my employer updated the RAM on a bunch of our machines to 2GB. The reasons was so we could do our development using virtual machines.  I haven’t done development work this way before (probably because I never worked anywhere before that gave you enough RAM).

So far, it’s only been a bit different than working with everything directly installed.  Visual Studio 2005 is a bit slower (of course).  The other minor inconvenience is that I can’t add new users to TFS from my virtual machine.  I suspect this has more to do with it being configured incorrectly than with the virtual machine not being part of the domain.  Access to network shares is virtually unchanged, since you can map network drives and connect using a different user name.


What Makes a Good Software Developer?

TSS.NET posed this question in one of their newsgroups on March 1.  Here are the comments I added to the thread:

- They only write what they need to. They tend to choose open source libraries and components for needed functionality instead of writing things themselves. They definitely don't replicate functionality already provided by whatever platform they're coding against (whether it's .NET or Java). - A companion characteristic is that they're good integrators. Because they use third-party components to develop solutions, they're skilled at making them play well with each other. - They're good at refactoring. The first version of any application is always the worst one. A good software developer refines and otherwise improves their code as they go along. - The companion characteristic to refactoring is unit testing. No developer can consider themselves good unless this practice is part of their everyday work. A robust set of unit tests is the first line of defense when it comes to high-quality code.
This was what I came up with off the top of my head.  I'd be curious to hear opinions from others (yes, all three of my loyal readers) on what makes a good software developer.

App_Offline.htm

I came across a couple of useful posts from Scott Guthrie about App_Offline.htm. This page appears and disappears automatically when the “Publish Web Site” option is used. What I didn’t know is that it’s part of the .NET framework (not the IDE). This means the page can be added and removed manually. This will be especially useful in my current environment, where we depend on network engineers to deploy web applications to test and production sites.

Here are the posts: App_Offline.htm and IE Friendly Errors

Announcing App_Offline.htm


The Honest Boss

Some friends of mine on a mailing list I belong to are having an interesting dialogue on ways to deal with co-workers when they make mistakes.  One of the list members posted a link to the interview with an honest boss e-card from Hallmark.  Mostly, it’s good for a laugh.  But what the “honest boss” says about promotions is a bit too true to be funny.


SQL Server Cursors

Personally, I dislike them. I avoid using them whenever possible. But I came across this excellent post that talks about cursors, alternatives to cursors, and provides a performance comparison between them.

The performance comparison in particular was quite useful.  If I’m able to reproduce the results for myself in a local environment, I may have to revise my current stance on cursors.