February 2009 Entries

What Are The “Never Events” for Software Quality?

Recent talk centered on software quality got me thinking of “never events”. The “never events” in health care are defined by the National Quality Forum to identity serious problems in the quality of a health care facility.  A “never event” has to be: Measureable Mostly preventable Have serious implications (like death or disability) Here are some examples of these events from the list of 28 defined by the NQF: Surgery on the wrong body part Leaving a foreign object inside a patient Artificial insemination with the wrong sperm These are not events...

Thoughts on the Code Contracts Preview for .NET 4.0

A new Code Contracts preview is now available on DevLabs. Code Contracts will be part of the base class library in .NET 4.0 (included in mscorlib), and facilitate a Design by Contract programming approach. You can describe pre-conditions, post-conditions, and object invariants. The Code Let’s borrow a couple ideas from Matt’s DbC post (he was using Spec#, which was a precursor) to see what Code Contracts will look like. public void Run() { TargetResult result = LaunchMissle(new Target()); } public TargetResult LaunchMissle(Target target) { Contract.Requires(target != null); Contract.Ensures(Contract.Result<TargetResult>() != null); return...

Mapping Objects with AutoMapper

At the end of last year I finished a project that required a fair amount of object-to-object mapping. Unfortunately, Jimmy Bogard didn’t release AutoMapper until this year, so I had to write a pile of object-to-object mapping goo on my own. AutoMapper is a convention based mapper. Let’s say you have an object implementing an interface like this…public interface IPatientDetailView { string Name { get; set; } IEnumerable<Procedure> Procedures { get; set; } // ... } …but all of the data you...

Why Would I Create A Custom LINQ Operator?

Here are three different reasons: For an operation that doesn’t exist. For readability. For performance. An example for reason #1 is Bart De Smet’s ForEach operator. While you are on Bart’s blog, you can read about the pros and cons of a ForEach in his comments. An example for reason #2 would be a custom join operator. Let’s say we are joining an object collection of employees to an object collection of departments. var employeeAndDepartments = employees.Join(departments, ...

More LINQ Optimizations

Not every optimization is a performance optimization. Imagine trying to get this XML:string xml = @"<people> <Person> <property value=""John"" name=""firstName""/> <property value=""Dow"" name=""lastName""/> <property value=""john@blah.com"" name=""email""/> </Person> <Person> <property value=""Jack"" name=""firstName""/> ...

Due Diligence and Code Comments

This is the silly tale of a strange due diligence process I experienced. It happened several years ago but I couldn’t talk about it at the time.  I’ve been on both sides of the technical due diligence table, and I’ve always felt that being reviewed is easy – you simply tell the truth when asked about the software and how it’s built. Anything else can get you into trouble. It is the reviewer who has the difficult job. Someone wants to buy or invest in a company and they are depending on you to help determine the fair value....

Thoughts on AJAX Preview 4 and JSINQ

ASP.NET AJAX 4.0 is adding client-side templates. You can bind data in the browser using declarative markup, imperative JavaScript code, or mix and match both approaches. The purely declarative approach looks like the following:<body xmlns:sys="java script:Sys" xmlns:dataview="java script:Sys.UI.DataView" sys:activate="*"> … <ul id="departmentManagerList" class="sys-template" sys:attach="dataview" dataview:serviceuri="DepartmentService.svc" ...