They grow up so fast

A few days ago, a developer at work said something that made me cringe, “Every day we write more legacy code”. My first instinct was to reinstate our corporal punishment policy. Then he said something quite amazing that I didn’t expect, “Any code we are afraid to change, because it isn’t thoroughly tested, is legacy code.” I cried. Literally. Figuratively. I know he read this in Working Effectively with Legacy Code, but to really see him get the importance of testing is awesome. »

Code Wars

You know software development is mainstream when you hear an argument about programming languages at a bar. “Dude, I program in C, it is way more pure than Java” “Whatever, you probably have memory leaks everywhere” “At least I know what memory management is, tool” I am not joking, I heard something similar tonight. Obviously I embellished a tiny bit, but I would never have expected to hear an argument like that in a bar from a group that I am not a part of. »

The Smell of Assertionless Tests

Today I found myself at a crossroads regarding testing. In my efforts to have pure unit tests, I had created tests with no assertions. Each test contained a mock object that verified multiple expectations, but no assertions. While each mock expectation could be thought of as an assertion, is it really a good idea to test the algorithm? I say no. The algorithm shouldn’t matter. The only thing that should matter is the input and output of each function. »

Using NHaml, from Source

The NHaml project is a super simple view engine that can be used with ASP.NET MVC. Unfortunately, like many young projects, it has changed so much in recent months, many articles on it are out of date. In fact, I don’t think I have seen any setup guides that still actually work. So, here is how to setup NHaml on SVN revision 98. Couple of prerequisites before you get started. I am assuming you have TortoiseSVN and ASP.NET MVC Here is the section outline so you can jump a head if you already have some of the steps done. »

Suppress .NET Compiler Warnings

Every now and again, the compiler will throw a warning message for a known issue. For example, some member variable may be set by reflection or an ORM tool like NHibernate. Using the pragma directive can easily solve these issues. public class PragmaExample { #pragma warning disable 0649 private int neverSetVariable; #pragma warning restore 0649 } To figure out what warning to disable, just right click on the warning. Then click on Show Error Help, which will bring up a dialog where you should select to view to show online help. »

Using Powershell for MD5 Checksums

The older I get, the more paranoid I get about things I download. Today I downloaded a freeware program from a 3rd party download site, since the publisher doesn’t actually allow downloading from their site. All they give is an MD5 checksum. Well, I decided to write a quick Powershell script to do the checksum for me. (Got some pointers from another blog writing a cmd-let to do the same thing) param ( $file ) $algo = [System.Security.Cryptography.HashAlgorithm]::Create("MD5") $stream = New-Object System.IO.FileStream($file, [System.IO.FileMode]::Open) $md5StringBuilder = New-Object System.Text.StringBuilder $algo.ComputeHash($stream) | % { [void] $md5StringBuilder.Append($_.ToString("x2")) } $md5StringBuilder.ToString() $stream.Dispose() I probably should add a try/catch for the stream disposal and file existence validation. »

The trouble with Big Up Front Design

Agile methodologies say that big up front design (BUFD) is bad. What happens when requirements change? What happens when scalability issues are encountered? How can you know solution X is better than Y? BUFD fails in these cases because unpredictable issues changed the design. For the most part, I agree in that it is impossible to plan for everything. But I don’t believe it to mean that design is dead. For example, if you are designing Windows Vista, would you want to have the Windows XP architect involved? »

Liskov Substitution Principle

Last night I was reading Agile Software Development, Principles, Patterns, and Practices (freaking amazing book) and came across the Liskov Substitution Principle. I had never heard of this principle, so it got me intrigued. What it is… The idea is very simple. For any client using a base class, any child class should be able to be substituted in that client. It seems very straightforward, but the example Martin gives blew my mind. »

In love

I wish ASP.NET MVC and NHaml existed a year ago when I started my last ASP.NET project. I am in love with the simplicity and elegance. At first, I was worried about losing some of the power of Web Forms. I was way off. I created my first MVC + NHaml application (CRUD for one model) in a few hours. The same can’t be said for the learning curve of Web Forms. »

Powershell? Yes

I have read over Scott Hanselman’s Tool List at least a dozen times. The first time I read it, I saw that Powershell was on his top 10. I knew a little about Powershell from Exchange 2007 but hadn’t taken any time to look at it. About a month ago, I had to write some server maintenance scripts. Things like deleting files older than X days, SQL Server maintenance, etc. These tasks were perfect for scripting, so I picked up a Powershell book and went to town. »