This is the programming edition of interesting notes.
First of all, if you have anything to do with application development, be sure to have a copy of Don’t Make Me Think! on hand at all times. I just finished reading the book and it’s full of information accessible to designers, developers, managers, and business folks. A lot of it is simple common sense, but it’s a good thing to read and remember once you start getting into the trenches.
Triggers are too evil! I give Louis Davidson points for contrarianism, and I’ll readily admit that they have their uses. Every once in a while, they make life better, even. But that set of uses is very small and quickly becomes a burden if you do not have clean, clear, readily available, up-to-date, and accurate documentation on exactly what is going on with them. Unintended consequences are a terrible thing when you’re looking back into a project several months later and trying to do one little thing which just happens to break your beautiful but precarious links.
Here’s a fun article about how to perform an “impossible” delete in SQL Server 2000. All I can say is that I’m glad we don’t live in a world of intense space constraints anymore…
Just shy of two weeks ago, I sketched out and developed a process for uploading XML files for an application I developed. I originally intended this to be a web service, but the end users wanted to have a location where they could manually upload files. Err, okay, I guess… As part of my development, I wanted to write up a schema that they could validate their XML files against, and it turns out that schema validation is remarkably simple in .Net. As the Microsoft XML Team point out, you can validate an XML file against a schema with about 7 lines of code using Linq. Incidentally, I really like Linq to Objects and Linq to XML. If you prefer the MSDN way of doing things, here you go. For notes on schemas, O’Reilly’s (via Eric van der Vlist’s) has a very nice tutorial that I made good use of in designing my schema. W3CSchools also has plenty of information on the topic.
I really like Linq… Set-based logic in C# makes programming so much easier, like when you need to break out a particular sub-set of objects. You can do in one well-designed query what would otherwise have taken you many more lines of code.
Finally, because I like to be security-conscious, I should point out that you should always be on the lookout for SQL injections. This article is relatively simple and designed to be an after-action debreifing, but you can learn a lot from it, as well as the more formal links at the bottom of the article.