Posts
1150
Comments
891
Trackbacks
1
Maintainability Update

This is a follow-up to the maintainability post, which was picked up by Ayende here, and then all over the place.

Quick recap of relevant points:

- I've got an application that is a working prototype, standard WinForms GUI thing.  I have to extend it for new requirements.  If it was entirely up to me, I'd use MVP, ORM, and TDD.

- I know I'm leaving.  I feel an obligation to leave code that the existing developers are going to be able to maintain.

- The developers are good people, hard working, intelligent, willing to learn.

- None of them have experience with MVP, ORM or TDD.

- There is a common architecture that is, at best, mediocre.  As an example, basically, call a stored procedure that returns three related data sets, loop through them with a reader to populate POCO objects.  Ugly.  But, it is common, so they know how to do it.  So, in the one sense I talked about in the previous post, it would be more maintainable, in this situation, with these people, to use the common architecture.

One of the developers has this thing about unit testing.  He's a very good WinForms developer.  Out of the blue, last week I'm there, he starts asking me about unit testing and how it would apply to a GUI.  I'm able to direct him to David Hayden's screencast on MVP (a very short and concise intro on it...I first thought when seeing it "I'm not learning anything new with this", then it occurs to me, "Hey, this actually makes sense because I'm starting to get proficient with it") and also Billy McCafferty's Best Practices article, which very effectively pitches ORM and TDD and MVP.  Nice.

So, anyway, two days left (after fulfilling my main obligation of passing off knowledge about the main project I was working on), I have to make a decision.  MVP, I can't do, not enough time.  TDD, not enough time, but I can do some Unit/Integration tests, and tie it into NHibernate.  I know I will have one hour to do a code review.  Fuck it.  Let's see what I can do.

I am a huge fan of Wilson's OR Mapper and have never used NHibernate.  What can I do?

Okay, let's set up a test that creates an ISessionFactory and Session.  Fails repeatedly as I try to learn in a few hours how NHibernate syntax works.  Finally get all things in order to get it to pass.

Don't even have enough time to create a true singleton class to do all this, so I'm hacking away to be able to get a *single* call to work, creating ISessionFactory in the call itself.  Ugly, I know, it's all the time I have.

One of the best developers I've ever worked with (unfortunately, never really got a chance to work with him since he's in a different part of the organization, learned tons from him, feel I paid back at least a little by pushing him in the direction of Rhino Mocks, but hope to pay it back better in the future) is using NHibernate in his stuff, so I'm IM'ing him a bit through all this.  I tell him "I'm hacking away at a suckfest" as I implement persistence logic in POCO classes (to which he responds negatively as expected) since I'm under the gun.  He helpfully corrects NHibernate syntax errors.

I implement one of the four existing system calls to use NHibernate, the other three using the common architecture.  It's all I can do with the time I have.

Last day.  Have my one hour to walk through the code with the developer.  Show the basic data structure.  Show the GUI and what it is supposed to do.  Show the old common architecture way of doing the one system call, show the NHibernate way (and this is someone who has never written a true data layer ever, because he never needed to).  Try to explain why the ORM way is better, and he eventually turns to me and says (paraphrasing) "You don't need to be trying to convince me, of course this is better.  I've done it the old way and it sucks.  I'm going to do it this way instead."

With more time, there's so much more I could have done, but I was able to plant some seeds.  They are good people, and they will be able to learn.

posted on Friday, June 29, 2007 10:48 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 4 and 6 and type the answer here: