Tuesday, May 5, 2009

TDD Pain Points, A Retrospective

This is the fourth weekend into writing about test driven development… taking agile methods I learned in boot-camp back to work.  Time for a retrospective…

First I will say that writing about this process has been a tremendous help in making these concepts gel.  Try teaching someone about something you are trying to learn.  I don’t care if no one ever reads these posts – the process of writing them has been invaluable to me.

Now, for the pain points:

Supervising controller:

I chose this pattern (a flavor of Model-View-Presenter) for two reasons.  1) We use .Net 2.0 at work and our developers have a lot invested in webforms.  2) It helps me separate functionality away from code-behind files and adhere to the Single Responsibility Principle, which is especially important if the code will be tested.

I like most of the Supervising Controller pattern in the context of webforms.  What I don’t like (pain point) is the "loop" of event handling: view fires event, then raises another event that the controller is subscribed to, then the controller responds by executing some logic and then calling a function back in the view to render results.  This is convoluted... I like the separation of concerns, but I don't like having to subscribe to events more than once.  Can I just call controller methods directly from the view?  Maybe what I'm describing is called the "Passive Controller"... I need to look into it.  This is really, probably, a pain point that should be attributed to webform development.  But hey, webforms pay the bills!

TDD:

Yes, as of now I’m listing Test Driven Development as a pain point.  I really like testing my code.  I don't really like the syntax I'm using to mock functionality.  Mocking my dependencies is necessary to write unit tests, but the Record, Replay, Verify syntax in Rhino Mocks is not natural for me to set up and harder to explain to my team.  I am still trying to shove the Rhino Mocks 3.3 RRV syntax into the Arrange, Act, Assert (AAA) method I learned in boot-camp.  I need to change the way I'm using Rhino Mocks, or I need to start using a different mocking framework (Rhino Mocks supports the AAA syntax and is explained really well... Using .net 3.x lamba expressions.  AAA is possible with Rhino Mocks, but the 2.0 syntax is painful.

That’s it for pain points for now.  These by no means mean I am giving up on TDD or Supervising Controller.  Although painful right now, I think these are birth-pangs… I am hopeful that in 2 or 3 months they will be big giant assets in my toolbox.  I’ll end now on a (what is the opposite of a pain point?) happy point: Resharper 4.5 is incredible.  It makes me go faster… I intend to dedicate a future post to my top X favorite features.

<< NCharlie: TDD – Part 3 (a UI test)

No comments:

Post a Comment