Friday, September 11, 2009

What's Wrong with this Code?


I am working on a new presentation entitled "Software Craftsmanship for Working Class Developers" where I want to talk about this movement and the difficulties most of us have implementing its ideals in the average work place. The last exercise I want to do in the presentation is a group refactor of some actual code (with details and names changed to protect the guilty). In preparation I have shown it to several co-workers and asked them to tell me what is wrong with the code and what would they do to fix it. If I do this with no real preamble it is interesting how many different responses I get that even included "I see nothing wrong with it."

So I'd like to post this little demo project for people to download and then tell me what is wrong with it and refactor it to something more adherent to the principles we all know we should follow, but sometime don't always get the chance.

Here is a little background on the code. The Order class is used to hold data for an order (for what does not really matter to the task at hand) for a given Customer. We assign the Order to a specific Customer by assigning it a Customer number which is a 3 digit alpha-numeric identifier. We serialize these Orders and drop them into a directory for storage and processing. The Orders are given a sequential 3 digit order number based on the last Order in the drop directory.


This is some what based on a real situation and when you download the project you will see that it has a few unit tests (and I use that term loosely) that pass. The code works. It does exactly what it is supposed to do. So when you start refactoring remember that you would be having to justify every change to management who is currently perfectly happy with how it functions. I've put a subdirectory called Refactored.1 where you can put your refactored version and there is a text document that has a list I already started with what is wrong (IMHO) with the current code and feel free to add to it.


I plan to eventually post all the solutions that get sent back to me and use some of the examples in my presentation. I may even try to get a cool prize to giveaway to one of the people who submit via random selection. Happy coding!


You can download the demo project (C#) here: http://www.tommynorman.info/files/soliddemo.zip

Sunday, September 06, 2009

Agile 2009 Wrap Up



Agile 2009 is in the books and this was my first year to attend and lucky enough to present. Unfortunately duty called and I was only able to attend the first two days, but I still had a great experience.

The Location

This year's host city was Chicago and I had never visited before. We were right downtown with easy access to everything and my wife and kids went with me and had a blast at Navy Pier, the local parks, and Fields museum. The conference was setup at the Hyatt hotel. The hotel was nice but the wireless access was only available in the open area and not in most of the break out rooms. Plus I don't think anyone's cell phone worked as we were many levels underground. I had also wished there had been a pool for my girls, but it was still a very nice place to stay.

The Setup

I've helped put on a conference before (http://www.devlink.net/) so I know how much work goes into getting everything setup. The staff was very well organized and they all did a great job. I loved the open jam area. I spent many hours sitting in a bean bag checking email or chatting with attendees. The session rooms were large, well laid out, and equipped with very nice projectors and large screens.

The first night I spent a few hours in the Music Masti room jamming with a handful of other attendees. There were some seriously good musicians and playing some very cool jazz. I only wish I could have spent more time there.

My Session

I presented "Implementing Scum and XP using Team System" Monday morning. There were many other big hitters presenting at the same time and with .NET being the minority representative I was pleasantly surprised with the number of people who attended. Everything went well and the crowd was very engaging. Plenty of conversations sprang up afterwards and someone even recorded the audio and should be posting it soon. The main criticism was that many wanted to see VSTS 2010 rather than 2008. Next year!

Other Sessions

Since I was only there for two days and I had several long chats with colleagues that captured a large amount of my time, I only was able to attend two full sessions. While I have seen most of the presentation before, I went to Robert Martin's Software Craftsmanship session because he is always an inspirational speaker. My table had a few people new to the concepts and a few zealots. Our resulting conversation afterwards inspired me to start writing a blog post on Software Craftsmanship for the Working Class Developer to be posted next week. The idea is that most shops do not initially have the experience or commitment to implement many of the practices from this movement. I think there is a middle ground for these shops to strive for as a gateway to a more in-depth adherence in the future.

I went to two sessions, one on TDD and one of refactoring, that were not introducing any new concepts to me and were in Java and Ruby so I was not as in tune with the examples. While these were both good presentations, I left early to connect with some people I only get to see every now and then at gathering like this (more on this later).

The second full session I attended was the keynote on the second day by Alistair Cockburn entitled "I Come Not to Praise Agile, But to Bury It." Of course everyone will talk about his grand entrance complete with bagpipes and his own twist on the matching soliloquy from Shakespeare's Julius Caesar. I really liked his presentation as he talked about how Agile is not dead, but ready to evolve into something new. He did not say what that something would be but talked about some of the concepts that would be involved.

The People

One of my main goals for this conference was to make some good connections and I was not disappointed. I ran into Corey Haines who I met at devLink 2008. I did not get to spend anytime in his infamous debates because he as volunteering the days I was there, but there is always next year. I finally got to meet David Starr in person after talking to him online for years. We had some great chats in the Open Jam bean bags covering Scrum certifications, software craftsmanship, and Team System. David and I recorded an episode for his podcast at http://www.elegantcode.com/ that should be out next month.

I got to meet several members of the Team System product team which included the main man Sam Guckenheimer. Sam was great. As we talked, if I mentioned any resource I needed or contact I wanted to make he whipped out his laptop and boom sent the email to get me what I needed. I also ran into the guys from Conchango, Colin Bird and Simon Bennett. Colin and I dove into the beta version of their Scrum process template for VSTS 2010. It was nice to see many of the common extensions I made to the 2008 version made it into the new one. Simon and I talked about the changes coming to the Sprint Task Board and some other new applications coming out with the release of 2010. They also had a very cool Microsoft Surface app for planning poker that can be yours for the low, low price of $10K!

It was also very cool to be able to meet some of the biggest thought leaders in Agile. Early the first day they had not yet setup all the signs for the conference and as I wondered around I asked a nice lady for directions only to find out she was Mary Poppendieck who was so great. Later that same day I was having a great conversation with some of the guys from Thoughtworks when Martin Fowler joins us. I ran into Jeff Sutherland again who I was lucky enough to attend his CSM course last year. I would love to name drop some more, but those were the main people I met.

The Conversations

While there were tons of great sessions I absolutely love just sitting with other Agile enthusiasts talking shop. Day one I was sitting with some guys from CarFax who were describing a great sounding XP shop where Ron Jefferies had come in and worked with management as well as the developers to get them setup. We had a very interesting conversation around technical debt.

There were many conversations about using Team System for Agile and implementing practices from the Software Craftsmanship movement. I t was nice to see many people from Microsoft there being so involved in the Agile community. It was a bit sad that so many people still make cracks about .NET (and Microsoft) being second class citizens in the Agile movement. Sometimes for a community supposedly open to embracing everyone they can be a bit elitist.

The one conversation I was disappointed with was the one around Scrum certifications. I totally understand that the CSM and CSP are benign as a measure of anyone ability. I currently hold both of these and they really only signify that you have been exposed to a certain amount of training on the subject. My main concern is that the Scrum framework itself gets the brunt of the rancor from the community. Scrum is not hurting Agile, poorly trained people are hurting Agile. Even with the paper tiger certifications, the Scrum Alliance marketed the process like no one else and helped get Agile more widely accepted in the mainstream. If our worry is that the core concepts are going to be diluted by the mainstream adoption of Scrum's mechanics, then let's not bash Scrum, let's find ways to maintain the ideals.

Conclusion

I cam away from this year's conference reinvigorated and ready to get back out there even more so in the Agile community. Next year's conference is going to be in Nashville and I am already trying to get our local Agile community amped up. Can't wait to see everyone here!