Sergio and the sigil

Beginning Continuous Improvement, A Case Study

Posted by Sergio on 2008-06-27

by: Glenn Goodrich

This post is the winner of The Great Devlicio.us Giveaway.

The story you are about to read is true. The names and identities of the innocent have been changed to protect them and my job. No animals were harmed in the writing of this story.

Roughly three to five years ago I was an intermediate ASP.NET Webforms developer. I had produced several applications for various clients that were in different stages of test/production/maintenance /graveyard. Some of these applications were loved by my clients, others were tolerated, and still others were abhorred. The aspects all of these applications did have in common were a high level of difficulty to maintain and an almost violent resistance to change. Most of my clients tend to generate requirements in a management bubble so during the first round of testing, (if it existed) or the first weeks stumbling through production deployment, the user feedback was very large. Of course, the client always desired make changes accommodating this feedback, which is often where my real troubles began.

There had to be a better way. So, I started combing the web, hoping to find people that solved issues like mine. Googling phrases like “extensibility”, “webforms pain”, and “easy asp.net deployment”. If memory serves, the first fish on the line was Rails. I did the Rails “Hello World” and was amazed at how fast you could get going, how easy you could add views, and how much of my nerd life I had wasted. Realizing that my clients were not quite ready for Rails (“Ruby on what??? Where’s the msi?”) I started looking for MVC in .NET. This, as you’ve probably guessed, landed me at the Castle Project. Monorail was just what I needed. I could shoehorn it past my clients’ open source/never-heard-of-that worries, because it was .NET. But this was just the beginning.

The Castle Project also had the Windsor Inversion of Control (IoC) container, which led me to things like “separation of concerns”, “single responsibility”, and the “open-closed principle”. It really started me down the path of Test Driven Development (TDD) which was probably the single biggest positive change to my coding practices. It was a little bumpy at first, but once I saw that I could get all my code working before I even had a web site application AND I could really test it, I was hooked.

I started reading the Castle Forums as well as Hammet’s blog and Ayende’s blog. Figuring they weren’t the only really smart people out there, I started reading tons of blogs (CodeBetter, Martin Fowler’s Bliki, etc.) which showed me the endless world of better design practices. I started reading books that weren’t from Microsoft Press (nothing against them, but there are a lot of good books out there) including Head First Design Patterns, which was another huge A-HA! moment for my development career. I now read blogs everyday and have at least two books going at any moment in time. I read about Continuous Integration and CI Factory, as well as NHibernate and other OR/M frameworks. This was my first steps into Continuous Improvement.

So, where is this going? Is there a success story in our future? Before you object to the relevance of my opening statement, we have finally arrived at my success. We were handed a very large client from a business partner, partially because that partner could not satisfy the needs of the client. The client (who I will call BigCo) wanted a web-based application to put in front of their customer-facing employees to, basically, figure out if BigCo could provide any services to new clients. There were various factors that affected BigCo’s ability to provide services to a given customer, and the application would have to perform the logic that determined each of these factors. For this article, we will call the application ProviderApp. ProviderApp had to do the following:

Collect information about the customer. Find out where the customer lived. See if BigCo had the ability to provide services to that location. If the location was good, show the employee which of BigCo’s services were available. Persist the results of this interaction.

So, BigCo wanted a prototype. Tapping into my new approach and knowledge, I started writing tests for my (persistent ignorant!) domain model. Customer, Address, ProviderResult, and other classes were the result. All clean and responsible only for themselves and fully tested. I used separation of concerns to partition out the factors into services, being sure to use interfaces. These services were also open for extension, but closed for modification. In fact, for testing, I actually wrote test-only providers, removing the need to invoke some needed external services that would be used in production. I had all the logic for the factors written and tested, all the domain model designed and tested before I had even created a web application. Also, thanks to CI, I knew when the build was broken immediately, so bugs didn’t have a chance to get stale, causing me to have to hunt for hours or days because I didn’t know when the bug was introduced. By the time I got around to the user interface (the web application) it was simply a matter of writing my views and consuming my services. Oh, and the act of writing pure HTML views was a breath of fresh air.

I finished the prototype a couple of days early, so we had to time to actually perform real user tests, which I don’t think I had ever seen before. The bugs found here were relatively small but made a big difference in our demonstration of the prototype. On demo day, BigCo was very happy with the prototype. They were not wowed, they were not dazzled. Their reaction is not the success story. The success story comes from the fact that I was relaxed on demo day, confident the software was solid. I had no anxiety about getting off the beaten path, which was new for me. In fact, I let the BigCo folks drive the application at the end of the meeting and told them to show it to whomever they liked later. There is no way I would have been confident enough in my previous life to let a client demo my “prototype” code.

At the end of the meeting, the BigCo people asked me how long it would take to “make this real”, which is when my success story really sunk in. I realized, right there in front of them, that the application was done. My answer was a matter of days, as I did have to write new providers for a couple of the services, since they were using different back-ends then the prototype, but that was it. They also asked about some changes, a question that would have usually caused my ulcer to start. Each of their requests was a trivial change, taking me a few minutes to incorporate.

I remember walking out of that meeting realizing I had taken a huge step in my career. We are still doing a lot of work with BigCo, and they are a happy client. I no longer fear change, and am still continuously improving.

Well, I didn’t mention DDD, because I haven’t gotten to it yet (it’s on the list, which seems to get longer all the time) but I hope you’ll consider my contribution. Either way, I had a lot of fun writing this.

Giveaway result

Posted by Sergio on 2008-06-26

We've just finished tallying up our votes for the Great Devlicio.us Giveaway and we are pleased to announce that the winner is Glenn Goodrich. We had enough entries to make the contest worthwhile and we decided to give prizes for every story. Everyone got one of the books in the original list and the 2nd place also got Visual Studio Team System. You see? I told you that you should tell us your story.

Some people asked if there will be a contest where they could submit horror stories instead of success stories. Well, I'm considering running a contest for that, but I'm afraid the prize will be limited to a bag of Doritos.

Glenn runs a very nice blog and his story, which will be posted here tomorrow, shows that the quest for a better way to develop applications or, in broader terms, the constant pursuit of improvement should be in our DNA.

I'll quote from his story:

... Head First Design Patterns, which was another huge A-HA! moment for my development career. I now read blogs everyday and have at least two books going at any moment in time. I read about Continuous Integration and CI Factory, as well as NHibernate and other OR/M frameworks. This was my first steps into Continuous Improvement.
...I was relaxed on demo day, confident the software was solid. I had no anxiety about getting off the beaten path, which was new for me.

Congratulations to Glenn, we are very happy that the prizes are being given to such deserving hands. You make us proud, Glenn.

Be sure to check back tomorrow with the full story.

UdtTypeName and .NET data types in SQL

Posted by Sergio on 2008-06-11

We are working on SQL 2008 for a new project with the intent to leverage the new data types, in this case especially the HIERARCHYID data type. One of the stored procedures we created had a parameter of type HIERARCHYID.

The code that calls the stored procedure was something like this.

SqlHierarchyId nodeValue = GetNodeValueFromSomewhere();
var cmd =new SqlCommand("usp_EnableNode");
cmd.CommandType = CommandType.StoredProcedure;
var  nodeParam = myCommand.Parameters.Add("@Node", SqlDbType.SqlHierarchyId);
nodeParam.Value = nodeValue; 
var enableParam = myCommand.Parameters.Add("@Enable",  SqlDbType.SqlBit);
enableParam.Value = true;
cmd.ExecuteNonQuery();

When running this code we were getting the error "UdtTypeName property must be set for UDT parameters." Since the HIERARCHYID data type is a .NET type in SQL 2008 and we had not played with .NET types in SQL 2005 yet, we scratched our heads for a few minutes.

We tried both:

nodeParam.UdtTypeName = typeof(SqlHierarchyId).Name; 

And

nodeParam.UdtTypeName = typeof(SqlHierarchyId).FullName; 

But the solution was much simpler:

nodeParam.UdtTypeName = "HierarchyId";

This should be needed for the new GEOMETRY and GEOGRAPHY data types as well. Maybe this helps someone else.

The Great Devlicio.us Giveaway

Posted by Sergio on 2008-06-05

Because there's more than one kind of hero

Update: The contest is now closed. We cannot accept any more entries. Wait for the winner announcement is a few days. Thanks for all the great submissions.

Here's your chance to win a well-deserved prize for being a good developer — and not just any prize. Devlicio.us, with the generous support from Microsoft (via Somasegar) and Addison-Wesley, is proud to present you with a contest that will dump a truckload of goodness at your doorstep. This ultimate prize package contains the following items.

  1. Agile Principles, Patterns, and Practices in C#: Uncle Bob's must-have work. This book needs to be part of your Agile and OOD bookshelf.
  2. Domain-Driven Design: Tackling Complexity in the Heart of Software: Eric Evans describes DDD and how your software design can benefit from it.
  3. Applying Domain-Driven Design and Patterns: Armed with the DDD knowlegde, now it's time to let Jimmy Nilsson show us how to implement solid .NET code.
  4. Patterns of Enterprise Application Architecture: In this classic, Martin Fowler lays down the law on how an enterprise application needs to be designed.
  5. Working Effectively with Legacy Code: We've all been there. It's hard and Michael Feathers does a great job in guiding us through the challenges and techniques to get you out of the quicksand.
  6. Implementing Lean Software Development: This book by Tom and Mary Poppendieck distills practices to optimize the development process.
  7. The Pragmatic Programmer: From Journeyman to Master: No list of this caliber would be complete without Andy Hunt and Dave Thomas' ultimate guide to developer proficiency.
  8. Visual Studio 2008 Team Suite + MSDN Premium: No need for explanations here. A $10K+ retail value item with all you'll ever need in terms of Microsoft technology.



The Contest

I hope the prizes got you excited. I actually envy you because I cannot participate. The contest is pretty simple.

  1. We are looking for success stories. Submit a true story that happened to you or your team where adopting good software development practices rescued a project or even the entire organization. The stories we want to award are the ones that demonstrate a direct relation between good practices or good design (or both) and successful solutions. Examples:
    • Continuous Integration saved my job.
    • DDD made my application survive the test of time.
    • My team went from grumpy to engaged after we introduced collective design ownership.
    • etc...
  2. Submit your stories by email or using the Contact link to any of the Devlicio.us bloggers between today (June 5th 2008) and ~2 weeks from today (June 20th 2008 by 5 PM ET GMT-4:00).
  3. The winner will be chosen by voting among the Devlicio.us bloggers. This might take up to 1 week.
  4. The winner story will be announced on Devlicio.us on or before June 20th and it will become a guest blog post on the blog to which it was submitted (so remember to protect the innocent in your story.)
  5. Shortly after that, the winner will be contacted for mailing address information and the prize will be shipped.
  6. Other stories might be selected to feature as blog posts as well - with or without any prizes.

Restrictions

The stories need to be of your own personal experience, within your team or your organization. Since the story has a chance of being posted in Devlicio.us, make sure the people and organizations mentioned in the story are OK with that or replace their names.

We think we can ship the prize anywhere but if you're not in the U.S. and there's some form of export or import regulation that prohibits the shipment of software or even the books, then we may not be able to send it to you.

Get to the writing already

We are anxious to hear your stories. Prizes like these don't come by often and we really want to reward someone for doing the right thing.

Chicago ALT.NET Meeting on June 11th

Posted by Sergio on 2008-06-03

The Chicago ALT.NET crowd will be meeting on June 11th. This time we have a new location with the space graciously offered by ThoughtWorks. You can register and get more information about the event at the link below.

If you haven't been to one of our meetings yet, you should know that this is not your average user group meeting. The talks are not formal presentations and there's a lot of participation from the attendance. Bring your questions and, most importantly, your opinions.

After the talk, you're welcome to stick around and socialize at a nearby restaurant. Food and drinks make for great fuel for more tech and non-tech talk.

Resharper versus CodeRush

6:00 pm
Pizza and networking time

6:30 pm
Join us and watch while Ryan Rinaldi and Adam Tybor demonstrate how those invaluable addins can boost your productivity and help you write better code in Visual Studio.

After the demo let's open the floor for discussions on a topic to be determined in typical Open Spaces style