Trivia.NET, save me from my self.

At times, one hears that the reason a husband/wife strays is because they aren't getting it at home. I don't know if that's true or not, but I do know that the latest batch of updates done to the project is directly related to the lack of coding I am getting to do at my paying gig.

And its the nature of this code, too. I am supposed to be doing TDD: writing tests and passing those tests with the simplest implementation. My blogging partner accused me the other night of making test cases that were a bit too complex. I, of course, would hear none of it, because I wanted to code.

I am not even supposed to be coding this project. In this exercise, I am supposed to be acting in the role of the Business, answering the questions of the developers.

BUT I NEEDED TO CODE, DAMMIT!!!

You see, while I have a job and I am paid as a developer, I haven't gotten to develop a whole lot lately. And the last thing I did get to code got a bit shredded in a code review after a disagreement over the definition of "elegance". So without that outlet, I have gone a bit over board in this latest implementation.

For those not familiar, the Trivia.NET project is essentially an attempt to implement an electronic scoreboard for the 20 question live trivia games that are played in bars and restaurants. We are focusing on the particular implementation that is done by Team Trivia (http://teamtrivia.com/) sponsored games. The concept is simple, the game is divided into halves (10 questions), and the halves are divided into 3 rounds of 3 questions each with a half-ending question(a half-time and a final question). The rounds themselves have points that available to be wagered, determined by the half. So a round in the first half will have points of 1, 3, or 5 per question, usable once per round. Its 2, 4, or 6 in the second half. The half-time and final questions behave a little differently. Half-time is generally a multi-part question that you get credit for each part (Name the original ABA teams that are still active today as part of the NBA, 2 points for each correct answer). The final question is generally a wager of 0 to 15 points that you will then gain or lose those points from your final score.

So after creating an initial test case to test something seemingly simple (like making sure that a point value cannot be re-wagered within the same round) I went deep down the rabbit hole, creating code and tests and refactoring, over and over and over again.

Now, I am done and very pleased with myself. After several refactors and re-tests, I have a very OO solution. Through the use of interfaces and abstract classes I am able to hit all the high points on A PIE (A PIE - as in "OO Developement is simple as a pie -- Abstraction, Polymorphism, Inheritance, and Encapsulation). I was also able to use Generics and got compile-time checks on the code (which caused me to drop a few tests. Actually, I was testing for a feature[placing 2nd Half Questions into 1st Round containers] that now cant be tested because it just wont compile unless its written right in the first place.

Note to Self: There has got to be a future piece in there somewhere about designing using compile-time checks to eliminate some tests.

At anyrate, I feel better now. I know Corey is going to look at what I have done and tell me I am missing it, that I am doing to much in my test cases and there for writing too much code to get them to pass. But hey, I had to code.

If you'll check out revision 37, you will see what I have added.