Stephen A. Fuqua (SAF) is a Bahá'í, software developer, and conservation and interfaith advocate in the DFW area of Texas.

Review: Growing Object-Oriented Software, Guided By Tests

May 12, 2012

Growing Object-Oriented Software, Guided by TestsGrowing Object-Oriented Software, Guided by Tests by Steve Freeman and Nat Pryce

I did not realize how much I still have to learn about writing good object-oriented (OO) code, and about hewing to a tight test driven development (TDD) methodology, before I read Growing Object-Oriented Software, Guided By Tests. My education in OO and unit testing has been largely theoretical, with no time spent directly learning from experienced OO programmers; my best mentor was a COBOL coder. Books like Design Patterns: Elements of Reusable Object-Oriented Software, Patterns of Enterprise Application Architecture, Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, Xunit Test Patterns: Refactoring Test Code, and others are wonderful but have few detailed real-world business-case examples.

Breaking Down a Unit Test from "Reggie" That Uses MoQ

April 21, 2012

Test driven development is hard. Perhaps it would not be if we were taught to think about OO development from a TDD perspective in the first place; but those muscles are poorly developed, and the exercise leaves you sore and panting a bit. As with physical exercise, there is a reward in the pain. Perhaps others do not see it, but I can already see the benefits accruing in Reggie as I rebuild it with SOLID principles in mind, driven by tests. To help me consolidate where I’m going, and help others whose TDD muscles are likewise under-developed, let us walk through a test, shall we?

Moles: No Longer Fit for Unit Tests

April 19, 2012

noMoles.png

Moles is a powerful and useful framework for unit testing. Or was. But even then, it was overused (at least by me). But no more!

Reggie Converted to Use Caliburn Micro, Ninject

April 17, 2012

Reggie, my regular expression testing application, has been rebuilt in the Caliburn Micro framework, using Ninject for Inversion of Control and MoQ to round out the unit tests.

Now that I've learned something about WPF, and that "out of the box" it is not entirely trivial to work with, it seemed worthwhile to rebuild the app using a standard framework, viz Caliburn Micro. The Mindscape Blog offers a friendlier CM tutorial than the one on the project's website.

In addition, I simplified the architecture by removing the separate business layer. The business logic is so light that it is not worth the effort (20 lines!). I will refactor if doing so provides a real benefit.

[Reggie v0.2]

Breaking My Moles Habit, With MoQ

April 16, 2012

Mockery

For several years now, I have been relying on Microsoft’s Moles for isolating one method from another in my unit tests. Recently I’ve begun to understand that this was not the best approach. I’ll dig into that more in a future post. Having come to this conclusion, I need to start ripping out Moles. Based on the user feedback across the web, and the powerful Lambda expression syntax I’ve grown used to, I’ve chosen MoQ as my replacement. Now for an exercise…

Unit vs. Integration Tests When Querying Nullable Columns

April 12, 2012

Here’s an interesting scenario: I have a Linq-to-Entities query that is giving me no results when performing a system test, but when I look in the database, logically there should be results. Better yet, the unit test passes. How can that be?

Using Windows CNAMEs to Reduce Server Confusion

April 3, 2012

A common challenge for development teams is remembering the names for all of the different servers in an enterprise environment when the server naming convention is either not descriptive ("Deathstar", "Falcon", "XWing") or obscure ("abcDBS001", "abcDBS002", "abcWEB01"). The Star Wars names suffer from an obvious problem of mapping description to purpose. Those obscure names are commonly used to help distinguish between dozens to hundreds of different servers in an enterprise. Arguably they are helpful to the infrastructure team as they manage this motley collection. But for a developer, remembering if "abcWEB01" is the test web server or prod can be challenging; even when remembered, it would be simple enough to overlook or accidentally type "abcWEB04".

Test Naming Convention

March 30, 2012

Historically I've advocated naming test methods after the method under test, in order to help find the tests when you need to modify them. Growing Object-Oriented Software, Guided by Tests has shown me that this is a relic of a code-first mentality rather than good application of test driven development, primarily in the section "Test Names Describe Features" (ch 21). "Test driven" development implies that we do not know the name of the method we're going to test. But we do know the functionality (feature) that we are going after, and that knowledge should be used when writing out a test name. For example:

SSIS Deployment Headache

March 18, 2012

For years I've had problems with SSIS deployments to production. In fact, I completely abandoned SSIS packages because it was so difficult to deploy to production (in SQL Server 2005): I always ended up with errors that would require me to hand-edit the file and hard-code paths. That, despite the fact that my config files have the database connection strings and file paths in them. And despite the fact that my packages usually work fine on the test server but fail in production. After years of this problem, it suddenly occurred to me that one piece in particular is probably at fault. But given that I do not have access to production such that I can investigate, it will always be a hypothesis: using a template that sets various properties with the help of variable expressions.

Entity Framework Connection Strings

March 11, 2012

This is a shout out to an agony-saving explanation of the connection string used for Entity Framework: Troubleshooting Entity Framework Connection Strings.

Complete Archives