Tuesday, April 13, 2010

Mr. Graffin: My Uneaten Greens Are a Feast for Some, I Say

I just went two days without a substantive meal.  That's right: Fatty go hungry.  After two freaking days, I prepared for myself a meal I would never have previously considered eating and, guess what: It tasted great.

It takes me back to when I was a boy scout.  We went on this one hike that felt like forever.  At the end of the day, we made ourselves "hobo dinners."  Right up until now, that dining experience is still my fondest.  When I try to recreate it, I never succeed because I am not famished.

Here we are, the fattest, most abundantly fed nation in the known history of the world, and we can't get a decent meal.  The constant availability of relatively cheap, delicious food has driven our expectations to the point where we are difficult to satisfy and impossible to wow.

So, when I listen to the Bad Religion song "Quality or Quantity" - which I often do - and I hear Mr. Graffin lament the woes of the poor folk who live on "just seventy cents a day," I am forced to wonder "Do they really have it so bad?"

My point is this:
Have no sympathy for people who are living off of "less than the cost of a cup of coffee" a day; they are eating better than we do.

Monday, April 12, 2010

Book Titles

As some of you know, I am in the process of writing a book having to do with Agile database development. This book contains a lot of the ideas I cover in my course (shameless plug).

Since a lot of Agility ports straight across to database development, I'm largely not dealing with those issues. I'm trying to come up with a name that conveys "this book helps you overcome the technical impediments to Agile database design." Following are my ideas.  Any votes or suggestions would be welcome:


  • Agile Database Design: Just-Right, Just-in-Time
  • Agile Database Development: A Technical Perspective
  • Just-in-Time Database Design: And All It Entails
  • The Test-Driven Database: Building Solid, Flexible Data Stores
  • The JIT Database: How To
Basically, I'd love to hear any suggestions you have.

Sunday, April 04, 2010

Very Simple Sequencer for Moq...

Following is a very simple tool for testing Moq...


public class MoqSequence
{
  private int expectedSteps;
  private int actualSteps;

  private MoqSequence() { }

  internal static MoqSequence GetInstance()
  {
    return new MoqSequence();
  }

  private class SequenceException : Exception
  {
    private SequenceException(string message)
      : base(message)
    {
    }

    internal static SequenceException GetInstance(
      int expectedStep, int actualStep)
    {
      return GetInstance(
        "Step " + expectedStep + " executed when step "
        + actualStep + " should have been.");
    }

    internal static SequenceException GetInstance(
      string message)
    {
      return new SequenceException(message);
    }
  }

  public void InSequence<T>(ISetup<T> iSetup)
    where T : class
  {
    var expectedStep = expectedSteps++;

    iSetup.Callback(
      () =>
      {
        if (actualSteps != expectedStep)
        {
          throw SequenceException.GetInstance(
            expectedStep, actualSteps);
        }

        actualSteps++;
      });
  }

  public void Verify()
  {
    if (expectedSteps != actualSteps)
    {
      throw SequenceException.GetInstance(
        "Expected " + expectedSteps + 
        " steps but only got " + actualSteps +
        " steps");
    }
  }
}
Here is an example of how to use it:



[Test]
public void ExecutesStepsInCorrectOrder()
{
  var sequence = MoqSequence.GetInstance();

  sequence.InSequence(transactionMock.Setup(
    t => t.Lock()));
  sequence.InSequence(transactionMock.Setup(
    t => t.TransferAssetsIntoEscrow(escrowMock.Object)));
  sequence.InSequence(transactionMock.Setup(
    t => t.SchedulePayouts(escrowMock.Object)));
  sequence.InSequence(escrowMock.Setup(
    e => e.ReconcilePayoutsWithHoldings()));
  sequence.InSequence(escrowMock.Setup(
    e => e.ExecutePayouts()));
  sequence.InSequence(transactionMock.Setup(
    t => t.Complete()));

  transactionCoordinator
    .RunTransaction(transactionMock.Object);

  sequence.Verify();
}