Slimming down the FxCop rule set
I asked a group of consultants currently working in my office for advice on which FxCop rules were actually applicable to our environment. One particularly useful piece of advice was to consider whether or not unknown people or applications would be using what I’d written. It allowed me to disable the following rules:
- Mark assemblies with CLSCompliant. Since there won't be any third-party users of the assemblies I ran FxCop on, that rule can go away.
- Mark assemblies with ComVisible. The same argument as above applies to this rule.
- Assemblies should have valid strong names. Once we get certificates, we would reactivate this rule.
Safari on Windows
I’m trying it out on my laptop at work to see how I like it (I’m all Mac at home now). In regular use, the speed advantage Safari is supposed to have over Firefox isn’t really noticeable. Most sites I visit render correctly, except for the occasional message in Yahoo! Mail. It has the sort of problems I’d expect rendering ASP.NET web controls, but so does any browser that isn’t IE.
At least for now, I wouldn’t ditch Firefox for it. I might use it more on my Macs though.
Index Seeks versus Index Scans
We were pointed to this blog entry by one of the DBAs at work today. I didn’t fully understand the difference before I read this post. The bottom line: seeks are preferred. I know I’ll be looking more carefully at query plans from now on.
Use code coverage
Eric Sink wrote this post in favor of code coverage. I wasn’t terribly familiar with the concept before two years ago, and my current job is the first one where I’ve seen such tools used seriously.
The best applications our organization puts out (correctness, performance, ease of maintenance) are the ones that have unit tests. The application I have the most confidence in though, is the one that has code coverage.
I’m trying to develop that habit for the code I write, so I can be a better example to the team I manage.
Requirements
Eric Sink’s post on requirements is the best and most concise treatment of the subject I’ve read yet. The document vs. database treatment of requirements and his comparison of traceability to a compiler are inspired. He even touches briefly on the shortcomings of bug-tracking systems as requirements management systems.
I haven’t read the book he recommends in his post (Software Requirements, by Karl Wiegers), but I have no doubt that it’s good. The book on requirements that I can vouch for is Exploring Requirements: Quality Before Design. It has tons of great advice on the process of gathering requirements. If you analyze, design, build, and/or test software, read Eric Sink’s post. If you manage technology projects, you should definitely read it. Highly, highly recommended.
TFS: Scenario Coverage Analyzer
We use TFS at work, so I found this blog post on scenario coverage rather interesting. I especially liked the Project Traceability Matrix which indicates code that can’t be traced back to a requirement. Using attributes to connect assemblies and the methods they contain to individual requirements is a great idea.
I hope the author does a NCover-based version like he suggests.
I hate ObjectDataSource
They’re ok if all you want to do is display data in a GridView control (and sort it, page it, etc). They become a pain in the neck the moment you actually want to modify data. The only I could get modifications to work is was by naming the parameters of your class methods exactly the same as the table column names (I’m using strongly-typed datasets in this application). I suppose it’s not so bad if you’ve named the table columns sensibly. But the database I’ve inherited doesn’t have this property.
What’s worse is the error messages you get when you haven’t configured something correctly. You get an entirely unhelpful message like “ObjectDataSource could not find a non-generic method that has parameters”. The number of search results for that phrase should have clued me in that this control was sketchy.
That’s one of the drawbacks of these new controls from Microsoft. They’re supposed to be better than code you’d write yourself–but God help you if they don’t work and you have to figure out what’s wrong. It’s not like you can debug them.
A use for XCode that has nothing to do with writing software
I came across an old MacWorld tip while searching for a quick way to compare an iTunes folder on a backup drive with one on my new laptop. FileMerge turns out to be quite a capable tool for comparing folders as well as files. It made it a lot easier to figure out what was missing from the laptop and sync it to the backup drive. It took awhile, since we’re talking about gigabytes of music files, but it worked.
Richard Stallman on Software Patents
I came across this opinion on software patents via the programming reddit. It makes a great for why software patents are a problem without even mentioning Microsoft’s foray into patent trolling.
Stallman makes an interesting proposal for a new software-only form of intellectual property (IP) at the end of the piece. Unfortunately, I don’t think it would survive the gauntlet of legislators (and lobbyists) to become law.
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
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:
- Primary Keys: IDs versus GUIDs (Jeff Atwood of Coding Horror)
- The Cost of GUIDs as Primary Keys
- Identity vs. Uniqueidentifier (Joe Celko discussion thread post)
- What Should I Choose for My Primary Key