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!

Thursday, July 23, 2009

VersionOne's State of Agile Survey 2009 Open


For the past four years VersionOne has run a survey for Agile adoption and published the results to the community. While it tends to lean towards people already adopting Agile practices, it is nice to see some numbers on other people's adoptions. I always take surveys like this with a grain of salt since questions that gauge the success of different Agile practices are very subjective. A developer answering the survey may have a different view of Agile's "success" in the organization than management. But all in all it's a decent survey and I encourage you to take it to help make the results that much more meaningful. Go here to participate in the survey.

Thursday, July 09, 2009

Evolution of an Agile .NET Developer in Books


I've been re-reading a few books lately and in the process it made me start to think of how differently I approach software development than when I first started. It seemed that each time I reach another plateau of understanding one or more books helped me get started on the next level. So in this post I wanted to chronicle my growth (which is still happening!) as a developer using .NET along with the key books that helped me. While I did development before .NET (VB & some Java) I am going to only stick to .NET for brevity.

Phase One: Programmer
When you first learn how to write software you learn the syntax of the language (C# in my case) and how to construct programs using that language. I myself did not go to school to be a developer (I was actually on my way to being a professional pilot) so I had very little pretense on theory or approaches. So I wrote code in a very functional way usually.

When I first started in C# I bought Programming C# from Oreilly. This link is to the fifth edition which covers C# 3.0, but I started with the first edition on 1.0 which is now out of print. I always loved the Oreilly books because they were very direct and to the point. This book was a great help in getting started with the language.

As I started to do more with .NET I bought C# in a Nutshell also by Oreilly. This is not a "how to" book but rather a reference for the C# language and the .NET framework. I turned to this book over and over again to figure out which class to use and how to use it. It was a great companion to the Programming C# book.

Phase Two: Developer
Eventually I was more sure of my abilities that I did not have to concentrate so hard on the coding part of developing software. I had a decent grasp of the language and the framework so I started wanting to write software in a more consistent and productive way. Another consultant told me to pick up Code Complete and it started me on my way to adopting some best practices that I still adhere to today. While it had nothing to do with C#, its content was applicable to any development language.

Also during this time I read (or skimmed sometime) quite a few books from WROX on several areas of programming in .NET which all helped me start to address specific problems in my applications.

Phase Three: Architect (or so I thought)
As I started to get better a writing applications using C#, I was being asked more and more to help design these applications then systems of multiple applications. I was lucky to work with many people who were much smarter than I was and they turned me on to quite a few good resources.

During one design session I was complaining about finding a solution to a particular problem and a colleague shook his head at me and asked, "Haven't you read the gang of four Design Patterns book?" I had to sheepishly admit I have never heard of it and then immediately went out and read it that week. After which I realized I had been describing a picture perfect scenario for an Abstract Factory pattern. I then bought two books on design patterns for C#: Design Patterns in C# and C# Design Patterns: A Tutorial . Using all three books I really started to delve into learning how to write more solid, reusable software.

Phase Four: Team Lead
Once I had been the architect or lead developer on a few projects I was being asked to lead development teams on bigger projects and that when I started to dabble in the project management and business analysis side of the software development lifecycle more. Either I was frustrated by the people in these positions or the project was small enough where the development team took on these duties. Either way I felt there were better ways to do both.

One of the project managers I worked with who was very good at his job loaned me a copy of the Mythical Man Month and it helped me start to think about projects in a wider scope than just the development effort. I was a big help in understanding how to interface with customers and managers and understand how to measure the progress of a project.

I was also given a copy of Software Requirements which gave me a new perspective on gathering requirements and mapping features to coding efforts. At this time I was also introduced to Rational's RequisitePro product which implemented a good deal of the concepts behind the book.

Phase Five: The Reluctant Agilist
By this time I had been leading software development projects for a few years with a good degree of success. I will admit I thought I had it all pretty under control and then a project that went bad started me rethinking how I developed software. Methods that had been tried and true for so long had failed and I was looking for some new ideas. At a new company I was re-introduced to the Scrum process for Agile development. I had heard of this before but to be honest I had dismissed it as the inmates running the asylum. Some of the engineering practices were appealing but overall I was fairly skeptical.

We did a pretty good job of adopting Scrum in all the wrong ways so I turned to Ken Schwaber's two definitive books on the topic: Agile Project Management with Scrum and The Enterprise and Scrum. To be honest I did not come away with much. Not that these are not good books but I tend to learn backwards in that I sometimes need the mechanics of something before I can relate it to the underlying concept. I then downloaded Henrik Kniberg's Scrum and XP From the Trenches and this book helped tie the concepts and mechanics together for me.

Phase Six: Agile Developer
On my next project I took all the things I had learned from our previous rough adoption of Scrum and applied it to our approach. I was lucky in that the management of my new client was very Agile friendly. I now really saw Scrum working and I started to concentrate on how to write my software in a more Agile way.

I attend a local Agile user group and won Practices of an Agile Developer. It was great in two ways because it not introduced some new concepts to me, it reaffirmed some of the lessons I had learned of the past few projects. It was a very easy to read book that provided a lot of information. At the next meeting I won the Art of Agile Development, which built upon everything I had just learned. Both these books made me want to learn Test Driven Development (TDD) better so I then grabbed Test Driven Development in Microsoft .NET.

I recently went back and reread Agile Principles, Patterns, and Practices in C# because when I was first given the book I was still not convinced about Agile and I really only skimmed the material. Going over it now had a much greater impact and there is so much great content that can be applied even outside of Agile that I suggest it to any developer regardless of their approach.

Phase Seven: The Empty Vessel
As I write this I have to say I am a little ashamed at how at some of these levels I thought I really knew everything I needed to know. It has made me really open myself up to learning as much as I can and figuring out the best way to apply that knowledge in my day to day activities. It was humbling to look at the publication dates on some of the books and think, "This has been around for awhile and I am just now learning it!"

There were more books along the way but I wanted to point out the ones that really pushed me to the next level of my development career and I hope to be constantly adding to this list for as long as I write software.

Thought Leadership is Good for Business

I have been lucky to work for some great consulting companies over the years who recognize the importance of their consultants actively participating in thought leadership and IT community activities. I was a technical trainer for a large part of my career and really enjoyed teaching. When I went into consulting it was great to practice what I had preached for so long but I began to miss being in front of a class. When .NET first appeared on the horizon, I along with several of my colleagues jumped on it and before long we were asked to start presenting what we had done at various technical organization in my area. At my very first presentation an attendee later contacted my company to bring us in to help them with their .NET adoption. The value was immediately obvious.

Since then I have strived to be as active a I can in local, regional, and national technology organizations as a participant, speaker, and organizer and I have seen first hand how this has helped my respective companies. Here are a few of the ways these activities have helped with our business:

  • Attracting New Employees: I've often had people come up and ask me about working with some cool technology. I always make it a point to only present on technology I have actually worked with and I've been lucky to see a wide range of solutions. When other developers hear about the projects I have worked on they too get excited and interested in being involved.
  • Advertising Your Solutions: Sometimes your company may have expertise in a certain technology and it is not widely known in your area. Presenting for multiple organizations helps get the word out that you have value to offer in a certain space.
  • Positioning Yourself as an Expert: It is easy to look like an expert for 60 minutes when you have plenty of time up front to plan, but when you really know the material it is obvious to your attendees. This does well to market your own abilities and thereby your company's abilities. While there may be other people with the same skill set in a certain technology, effectively being able to communicate and explain it is just as valuable.
  • Improving Employee's Communication Skills: Some developers are great at developing, but not so great at communicating. As a consultant, communication is a skill that is almost as valuable as your coding skills. Companies that encourage their employees to present are helping them grow these skills also.
  • Differentiates You from Your Competitors: There may be many companies that offer the same services are you do, but being seen as a thought leader in a certain space can really set you apart from your competition.

As you can see, there are some very real benefits to participating in IT communities as a Thought Leader. Companies who encourage the employees to pursue these activities and invest in them can see some very tangible gains. Even attending and supporting local IT groups can help with your business so get out there and be active!