Tim Murphy's .NET Software Architecture Blog

March 2006 Entries

A TDD Holy War

Rocky Lhotka was recently on DNR and made some comments about TDD that have created quite a stir.  Rocky has posted a deeper explanation of his comments from the show.

I first must place myself as a TDD skeptic who finds the topic worthy of more research.  Personally, I have many of the same concerns that Rocky brought up.  Much of what I have read on the subject focuses on building one piece of functionality at a time.  I try to keep an open mind, and maybe I am missing something, but it seems that this narrow focus would lead to code that does not play well with others and a lot of rework.

I think people need to remember that no matter how much you believe in your approach others are going to disagree with you.  Saying or implying that a person is irresponsible because their viewpoint differs to me is the sign of a closed mind.

Back to Our Regularly Scheduled Program

I finally sent off my Logging Application Block chapter to the main author, Keenan Newton, for an upcoming Apress Enterprise Library book.  I have to say that I share Craig Shoemaker's sense of accomplishment at completing this type of endeavor.  It gives me a new appreciation for all the authors that put out the tomes that I rely on to keep up with our industry.

Of course now that this is done I have time again to pursue other topics.  I will be doing more work with ASP.NET, GAT and SC-BAT.  As that moves along you will see more posts here about their cool features and gotchas.  Until then ...

MONAD Is the Answer

I almost made a mistake and skipped this week's Hanselminutes.  This week Scott covers MONAD.  I a nutshell, this is the command shell on object steroids.

Most people who know me have heard me say that my ideal environment has the ease of use that comes with a windowing, event-driven environment with the power of a command line.  Well it looks like the computer gods are smiling on me.  MONAD sounds like it makes Windows really close to what I am looking for.  Call me a dinosaur geek, but this is way too cool.

The one place that I know you can get a version of MONAD is the Windows SDK For January 2006 CTP.  I'm not sure about anywhere else.  Of course in order to get the CTP you need to be an MSDN subscriber.  I will post more about the product once the MSDN download application decides to give me the last 1% of the download. 

So is MONAD the answers to my prayers of years gone by?  Tune in next time and see.

Making TDD Real

I just finished listening to this week's DNR with Jean-Paul Boodhoo on TDD.  Now I will say right up front that I have not actually done TDD on any of my projects.  This discussion with JP really brought home the ideas in a way that was easy to understand.  Carl and Richard also asked him many tough questions about pair programming, continuous integration and what happens to the rest of the team.

One thing that struck close to home is with regard to what is and isn't TDD.  Before I started with my current employer I interviewed with another consulting company.  Coincidentally they wanted to send me to the same client I am at right now.  They asked if I knew or at least understood TDD because that is what the client did.  Not to put the client down, but they do unit test and not test driven development.  They are being driven by another large consulting firm to put 1000 layers of documentation on every project.  We could not touch a line of code until we had full detailed designs showing what every class was going to look like and sequence diagrams showing how they would interact.  So beware when a client or an employer says they do TDD.

This does bring up a good question.  No matter what you need to get your requirements before starting to do coding.  For those of you out there that are doing test driven project, how much planning are you doing up front and what kind of planning?  JP states that architecting does not go away on these projects.  I am interested in what form it takes with this different mindset.

Well, check out the DNR episode as well as JP's blog.  Carl and Jean-Paul also recoreded a dnrTV episode and will be putting another out this week.  Here are the links.

Internal Struggle

This is just one of those things that is going to take a while to get used to.  Twice now I have lost significant amounts of time trying to track down a problem only to find out that it was a matter of my expectations.  I am so used to creating classes in VS2003 where classes are automatically public that it is not even something I think about.  So when I try to access a class outside of its assembly that was created in VS2005 I cannot figure out why the class is not found.

The reason is that the classes are now internal by default.  This means that they are only accessible by classes within the same assembly.  Most of the time I write code for the business and data layers of an application.  These classes are normally external facing so that the layer above them can use their functionality.  Because of this most of my classes should be public by default.  Only helper classes would be internal.

I understand why this was done, but after spending so much time in an environment that did the opposite it will take a while to get used to.

The Importance of Having the Right Index

Here is another story from the trenches.  My current project was having mysterious errors coming from its Oracle database, but only under load.  Specifically we were getting the following:

ORA-01013: user requested cancel of current operation

This one had me stumped.  How could this happen.  I searched the code line by line.  I got assurances from the testing team that the testing tool was waiting for the last byte to return before navigating away from the page.  I scoured the web for any hint of what could cause this.

We ran some more tests with the DBA monitoring the database.  What we found was large number of locks being held for an unusually long time.  This of course results in other requests being blocked and eventually timing out.

Unfortunately I couldn't execute my own explain plans.  For any who don't already know, this is a function within Oracle that tells you the cost of the query you are trying to execute.  Once the DBA ran them for us it showed that the query that was getting a lock was doing a table scan.  It was reading row by row until it finally found the one it was looking for.

We added an index specifically for this query and the result was that the locks were being released so quickly that the DBA's monitoring tool didn't even see them.

Lesson: Know they query plan!

To Transfer Or Not To Transfer, That Is The Questions

This is one that bit me the other day and re-enforces the need to think about why you use a certain method.  I was doing some testing at the client I am working at and a page suddenly started rendering twice in the same browser window.  So what I ended up with was:

My Page

My Page

Now how the heck can that happen?  I was a victum of my own code.  The application's detail page was catching a custom exception type and then using Server.Transfer to go to an overview page.  No problem, right? 

The problem is that calling Server.Transfer causes a ThreadAbortException in the originating page.  After the custom exception was caught and the page was transferred and the new page completed its load the thread abort was caught by the original page looking for any System.Exception errors.  Guess what was being performed in this catch.  That's right.  Transfer to the overview page resulting in the scenario above.

I had never seen this behavior before, but then again, I normally use Redirect instead of Transfer.  I have read a number of articles and none of them mention the possibility of this happening.  All of them say that the page terminates and transfers to the new page.  Evidently this is the case for all situations other than exceptions.

Note:  This was written in ASP.NET 1.1

Why I like Rocky

I found this post by Rocky Lhotka rather entertaining as well as rather directly pointing out what we as architects and developers should all understand.  Suddenly I am hungry. :)