About three weeks ago, I asked my readers and some people in the Norwegian developer community about what books they have in their bookshelf. The response was good, and I ended up with many good book recommendations.

Today I placed a new order on Amazon, and spent 200$ to upgrade my bookshelf. If you read further, you’ll see which books I ordered.

Software Craftsmanship: The New Imperative
Pete McBreen

“This book is the foundation of the Craftsmanship movement that seem to get momentum these days (and that is a good thing). “Software craftsmanship” sounds nice and has a positive ring to it, so it does not seem to be hard to endorse. But for Pete McBreen software craftsmanship is more than just taking your job serious. It’s a way to organize teams, a way to run projects, a way to run the whole industry, a way to organize learning, and a new way to look at developers. I really like many of his ideas, and I hope people like the Craftsmanship movement not just because it sounds nice, but because they know what this book is about. Read it and see what you think of “Software engineering” when you’re done.” – Tore Vestues

Working Effectively with Legacy Code
Michael C. Feathers

“Don’t be scared away just because the title has the word “legacy” in it. This book is not about VB6 or Fortran. Not at all! It’s probably the best book I’ve read about writing automated tests. It is about how to work with code that is not tested (which is Feathers definition of legacy code). And it is about testing in general. If you want to write tests for code that is not previously tested (or written in a way that makes it testable), this book is for you.” – Tore Vestues

Test Driven Development: By Example
Kent Beck
Kent Beck is the man behind design patterns and TDD. Do I need to say more? If you don’t know his work, have a look at his presentation from RailsConf 08.

Extreme Programming Explained: Embrace Change
Kenth Beck

“Extreme programming is beautiful. Not only because it uses the well known practices of TDD, CI, Pair programming and so on. Xp is beautiful because it understands that practices do not stand on its own. You need a mindset. The mindset is expressed through the Xp Values, and throughout the entire book. Xp is close to a philosophy. Read the book and I’m sure you will see software development in a slightly different way.” – Tore Vestues

Agile Software Development
Alistair Cockburn
Twitter sphere is amazing. I got this recommendation from my online friend Liam.

Here is a review from Amazon:

“Every fifteen years or so, a great book pops up that describes what projects are really like. There was Brooks, then DeMarco and Lister, and now there’s Cockburn.

Why is there such a gap between these great books? Possibly because the message they contain isn’t the easy-to-digest dictate: “run your project this way and everything will be fine.” Instead these books all focus on the fundamentals of projects: people and the way they work together. These books treat people as people, and not replaceable parts in a process. The books accept people’s foibles and inconsistencies, and work out how to work with them, rather than how to try to stamp them out. The books ask: how can we help these funky people work better together to produce great software?

Agile Software Development has some great answers, which makes it a significant book. It deals with the issue that programming is essentially communicating. It looks at the success factors of individuals, and how to help align the project with these. It discusses practical ways to reduce the latency of communication (do you know how much each extra minute taken finding things out costs on a 12 person project? How do you line your walls with information radiators?) The book mines the metaphor of development as a cooperative team game, and looks at development organizations as a community, where good citizenship pays.” – Dave Thomas

I want to thank all of you how responded to my post, and my twittering. If you wondering; the total cost of the books was 160$, and 40$ in shipment L

Thursday, May 28, 2009 11:50:18 AM (W. Europe Standard Time, UTC+01:00) 
  Permalink  |  Comments [4]  |  View blog reactions  | 

My employer, Capgemini, just released a Norwegian technology blog. We have been working on this project for a while and have finally released it! Puh!

My first post on this blog was about technical debt. I was so inspired by Ward Cunningham’s metaphor that I just had to write about it. Anyway, the content of the blog is in Norwegian. If you are a non-Norwegian reader, it’s probably not in your area of interest.

Feel free to visit our blog and follow us on twitter.

Wednesday, May 13, 2009 2:53:49 PM (W. Europe Standard Time, UTC+01:00) 
  Permalink  |  Comments [0]  |  View blog reactions  | 

If you are a software developer and consider yourself as a professional, you should watch this presentation. Robert C. Martin aka UncleBob has been a programmer for 40 years, written tons of articles and some really good books. He has worked very hard to promote professionalism and craftsmanship to software developers. In this keynote you’ll see him talk about that. Watch and learn!

Thanks to UncleBob for giving us such a great presentation. And thanks to Fredrik for pointing out this video for me.

Tuesday, May 12, 2009 9:29:38 PM (W. Europe Standard Time, UTC+01:00) 
  Permalink  |  Comments [0]  |  View blog reactions  | 

Every now and then I get the question about what books I recommend on the topic of programming and software development. As I try to practice the DRY (Don‘t repeat yourself) principle while writing code, I‘ll also intend to do it in real life. And by answering this question in form of a blog post, I‘ll be able to redirect future questioners here.

IMG_5895 

I’ve assembled a list of books that I’ve read or that’s in my books-to-read queue.

The list

The list is sorted by my favorite books.

Clean Code
Robert C. Martin, also known as Uncle Bob
I finished reading this book a week ago and I have only one thing to say, it’s a masterpiece. If you are a professional programmer, you should read this book. I learned many, many neat tricks reading this book. Uncle Bob have 40 years of experience as a programmer, and he worked very hard not to become a business wonk, and this made him sharp like a knife. Read this book, it will give you a clear perspective on how to write quality code. Expect to read lots of code samples, and work hard to grasp the content. I’m going to convince every programmer I work with to read this book!

The Pragmatic Programmer
Andy Hunt and Dave Thomas
Hunt and Thomas are great storytellers and you’ll be blown away with their wisdom – it seems like they have been programmers forever! I like this book because it‘s hands-on and lots of the advice you get by reading it, you can put into practice in your daily job. The book tells you everything you need to know in order to become a good programmer.

They also push hard that programming is not only science, but a craft, and you need to practice it a lot in order to become a master - hence the slogan “From journeyman to master”. The book will provide you with tons of practical tips and the first one is “Care about your craft”. If I ever get responsible for a team of developers - hey, who the heck would put me in charge? :p, I’ll give this book to every one of them and then send them home and ask them not to come back before they have completed the book!

Design Patterns: Elements of Reusable Obect-Oriented Software
Eric Gamma, Richard Helm. Raplh Johnson, John M. Vlissides AKA. The Gang of Four
The first book ever to write about design patterns, it was released back in 1994 and it documented 23 patterns. I have to admit that I had to read this book several times to grasp most of the ideas, but it was worthwhile.

This book is not for beginners, but for developers with experience from OO (Object Oriented) languages and design. You probably find people argue that this book is not applicable today because the patterns were discovered in the time of C++, which don‘t contain modern language features like Generics and Events like we have in C# today. I disagree with these people because the core underlying principles are just plain old Object Orientation, but I can understand the argument. The samples in this book might not be as relevant for C# as they are for C++, and if you apply some of these patterns in a modern language, you obviously need to think about the features you have available in the language, and use them. There is a reason that we have the event language feature in C# today – so it’s easier to implement the observer pattern! If you learn and understand the observer, you‘ll also learn that loosely coupled code is harder to read and debug. The book is a good reference and contains the most general patterns you need to know about, but remember that even though you use a language with built-in language feature for some of these patterns, you should know about the pros and cons in order to make good design decisions! This is a good educational book.

Domain-Driven Design: Tackling Complexity in the Heart of Software
Eric Evans
I think this one is about to become one of the most important books out there on the topic of OO design and modeling. It‘s been a while since Evans published this book, but it seems to get more and more attention nowadays, and more and more people I talk to practice DDD (Domain Driven Design). I think the most important thing Evans teaches us is what he calls the ubiquitous language. The books also teach good modeling practices, and documents lots of useful patterns. This book made me revisit Object Orientation. You should read it, if you are experienced with OO design and programming.

Head First: Design Patterns
Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy Sierra
This is the design patterns ABC-book. The authors have a great talent in communicating complex ideas in a way that‘s easy for the readers to understand. The book contains some of the same patterns as the GoF-book and the code samples are mostly in Java as well. Highly recommended for beginners on the topic of design patterns!

Windows Presentation Foundation Unleashed
Adam Nathan
The only book I‘ve read about Windows Presentation Foundation, and It gives a solid introduction to the technology. I admit that I haven’t read the book from chapter to chapter, but use it frequently as a reference when I need to learn new neat features about WPF. The code samples in the book even have color highlighting! This book should be in every WPF/Silverlight developer’s bookshelf.

The best Software Writing
Joel Spolsky
Mr. Spolsky has assembled a very entertaining book of essays on the topic of software engineering. The essays I remember are Paul Graham’s “Great Hackers” and Eric Lippert’s “How many Microsoft Employees Does It Take to Change a Lightbulb?”.

Agile Software Development, Principles, Patterns, and Practices
Robert C. Martin
I’m hooked on Uncle Bob, he is the Master Chief of programmers, and an awesome writer. This is a book I’ll read very soon.

Patterns of Enterprise Application Architecture
Martin Fowler
This book is yet another book that’s on my books-to-read queue. Fowler is a notorious craftsman in the art of software engineering, and I’m looking forward to take a snapshot of his brain!

Code Complete: A Practical Handbook of Software Construction
Steve McConnel
Have not had the chance to read this book yet, but I will sometimes soon. The word on the street says that this book is even better than Pragmatic Programmer – now we have to see about that!

Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
Jimmy Nilsson
I haven’t had the opportunity to read this book yet, but people that have read it says it’s a more hands-on and practical book than Events book.

 

This is my list, for now, but I’m continuously seeking more knowledge in order to become a master in the craftsmanship of software development. While assembling the list I just realized that I don’t have a book about Test Driven Development – I should do something about that.

It would be interesting to hear what you and other fellow developers are reading, and what you have in your bookshelf – so therefore I‘ll start yet another meme and I invite you and the following people to answer:

  • Jonas Follesø – Silverlight guru, vivid speaker, long time partner in crime and friend!
  • Tore Vestues – wise guy and friend. I think of him as one of the most skilled craftsmen I personally know (It seems like Tore already had a book list, I’ve updated the link)
  • Anders Norås – Admirable and skilled software craftsman
  • Einar Ingebrigtsen – The Norwegian Scott Hanselman!
  • Mark Nijhof – Seriously skilled software craftsman and a community hero
  • Håvard Stranden – Fellow member of NNUG in Trondheim, active blogger and speaker
  • Børge Hansen – Active blogger and architect working for Microsoft Norway
  • Sondre Bjellås – Friend, thinker, mr. Robotics and the Norwegian Geek of the Year 2008
  • Fredik Kalseth – Highly active blogger about .NET, design patterns, testing etc. and a skilled software craftsman
  • Lars Wilhelmsen – Highly active in the Microsoft community and the new master chief of the Norwegian .NET User Group. Lars has now responded to this post. Click the link to watch his bookshelf 
  • Joar Øyen – Friend, MVP and master chief of NNUG Trondheim
  • Pål Fossmo – Friend, MVP, good speaker and a skilled software craftsman. Pål has responded to this post 
  • Kjetil Klaussen – Friend, good speaker and a skilled software craftsman
  • Johannes Brodwall – Norwegian agile guru!
Tuesday, May 05, 2009 7:58:33 PM (W. Europe Standard Time, UTC+01:00) 
  Permalink  |  Comments [13]  |  View blog reactions  | 

Tomorrow I’m going to give a talk at Smidig utvikling Trondheim 2009, which is a seminar about agile. I’m really looking forward to this seminar because of good content and good speakers. There are some big names keynote speakers as well.

I’m not going to spoil too much of my talk, but I can say I’m going to talk about how teams developing software can be able to work in parallel if they apply loose coupling.

Sunday, May 03, 2009 3:56:55 PM (W. Europe Standard Time, UTC+01:00) 
  Permalink  |  Comments [0]  |  View blog reactions  | 

In this post I will tell you a story about how I used TDD (Test Driven Development) to learn new a new API, and how I successfully managed to accomplish my task before expected, and delivered 100% working code (no defects), even though I did something I’ve never done before – interested? I thought so ;)

In the project I’m currently working on, I was given the task to implement a web service that integrated with a directory service using the LDAP protocol. This was something I’ve never done so far in my career, so I thought it as a fun challenge. The task was simple; I had to implement CRUD (create, read and delete) behaviors to manipulate entries in the directory. My main concern and the obvious show stopper were to figure out how to integrate with the directory service using the LDAP protocol.

As always, before I jump into conclusions, I sat down and started to think about how to solve this task. I had a gut feeling that told me I’ve read about this somewhere, about what’s the best way to learn new API’s. And after while it suddenly came to my mind! – It’s called learning tests.

“Jim Newkirk reported on a project in which Learning Tests were routinely written. When new releases of the package arrived, first the tests were run (and fixed, if necessary.) If the tests didn’t run, there was no sense running the application because it certainly wouldn’t run. Once the tests ran, the application ran every time.” – Kent Beck, Test-Driven development by example

Since I can’t reveal more about my work, I’m going to use another example in this story. I decided it would be fun to learn how to integrate with Twitter using their API’s and C#. Since integrating with Twitter is completely new for me, the situation will be analogues to the one I had solving the LDAP integration task for the customer.

Again, before jumping into conclusion, I started out doing some research, and ended up on Twitter’s APIWiki. The WIKI contained lots of good information and after a few minutes I learned that their API’s is built upon the HTTP protocol and that its REST based. In the WIKI they had listed up 3rd party libraries for several different platforms, and I found a few for .NET, and decided to use an Open Source library called Twitterizer. My rationale for using a library was if the library is good, it would be easier for me to produce working code, and I’ll probably do it faster than using the built-in HTTP libraries in the .NET framework.

If you going to create a Twitter client or another type of application that integrates with Twitter, you probably have to figure out how to;

  • Authenticate and logon to Twitter
  • Update status
  • Get status from friends
  • Get list of followers

Learn to use the library

If you are used to TDD, you start out writing tests before any production code. You are probably also familiar with Uncle Bob’s Three Laws of TDD;

  1. You are not allowed to write any production code unless it is to make a failing unit test pass.
  2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
  3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

When writing code, I like to work like this, so I started out writing failing tests to document what I had to learn in order to integrate with Twitter. The first, and the obvious test, was to figure out how to authenticate with Twitter. I also added three more failing tests; update status, get friends status and get followers. Here is what I ended up with;

   1: [Test]
   2: public void Authenticate()
   3: {
   4: }
   5:  
   6: [Test]
   7: public void Get_status_from_friends()
   8: {
   9: }
  10:  
  11: [Test]
  12: public void Get_followers()
  13: {
  14: }
  15:  
  16: [Test]
  17: public void Update_status()
  18: {
  19: }

I know, I broke Uncle Bob’s law 2 by writing four tests before any production code, but I’m pragmatic, my goal was to solve my task, not follow the laws like a slave. The positive outcome from breaking law was that I now had decomposed the Twitter integration task, into four more fine granulated tasks. I considered this my to-do list.

The next obvious step was to learn the Twitterizer API, which I did by using the Object Browser in Visual Studio. After fiddling around for a while, I was ready to start solving the first task; how to authenticate a user in order to logon to Twitter. I tested this by login to Twitter, and call the API for receiving status from friends. If the test received status from friends, I could assume the login was successful. After this test passed, the rest was a walk in the park, and here is what I ended up with;

   1: [Test]
   2: public void Authenticate()
   3: {
   4:     Scenario.New("Logon Twitter", scenario =>
   5:     {
   6:         Twitter twitterClient = null;
   7:  
   8:         scenario.Given("user is not logged on");
   9:         
  10:         scenario.When("the user logs on", () =>
  11:             twitterClient = new Twitter(username, password));
  12:  
  13:         scenario.Then("it should be possible to call API", () =>
  14:             twitterClient.Status.FriendsTimeline());
  15:  
  16:     }).Execute();
  17: }
  18:  
  19: [Test]
  20: public void Get_status_from_friends()
  21: {
  22:     Scenario.New("Get status from friends", scenario =>
  23:     {
  24:         TwitterStatusCollection friendsStatus = null;
  25:  
  26:         scenario.Given("the user is logged on", () =>
  27:             twitter = new Twitter(username, password));
  28:  
  29:         scenario.When("friends status is requested", () =>
  30:             friendsStatus = twitter.Status.FriendsTimeline());
  31:  
  32:         scenario.Then("friends status should be received", () =>
  33:             friendsStatus.Count.ShouldNotEqual(0));
  34:  
  35:     }).Execute();
  36: }
  37:  
  38: [Test]
  39: public void Get_followers()
  40: {
  41:     Scenario.New("Get users' followers", scenario =>
  42:     {
  43:         TwitterUserCollection followers = null;
  44:  
  45:         scenario.Given("the user is logged on", () =>
  46:             twitter = new Twitter(username, password));
  47:  
  48:         scenario.When("followers is requested", () =>
  49:             followers = twitter.User.Followers());
  50:  
  51:         scenario.Then("followers information should be received", () =>
  52:             followers.Count.ShouldNotEqual(0));
  53:  
  54:     }).Execute();
  55: }
  56:  
  57: [Test]
  58: public void Update_status()
  59: {
  60:     Scenario.New("Update user status", scenario =>
  61:     {
  62:         scenario.Given("the user is logged on", () =>
  63:             twitter = new Twitter(username, password));
  64:  
  65:         scenario.When("status is updated", () =>
  66:             twitter.Status.Update("hello world..."));
  67:  
  68:         scenario.Then("status should be updated", () =>
  69:             twitter.Status.Show(username).Status.Text.ShouldEqual("hello world..."));
  70:  
  71:     }).Execute();
  72: }

Notice that I’ve used a C# DSL (Domain Specific Language) for describing the tests as scenarios. These scenario driven tests is a well known test pattern called AAA (Arrange, Act, and Assert). I’ve developed the C# DSL and open sourced it – feel free to use it.

The workflow

The workflow is simple. Start out by writing failing tests to document what you need do in order to solve your task. When I started, I had one task, integrate with Twitter, after writing the tests I had decomposed it into four minor tasks. This is a famous problem solving technique called Divide and Conquer. You break down a large, complex problem into smaller, solvable problems. When this is done, you start working on the tests and get them to pass, one by one.

Conclusion

Using TDD to learn new API’s is something everyone should do. If you think about it, it’s exactly what you are doing when you are writing production code and using 3rd party libraries today. You write some code, you compile it, and then run it. If it doesn’t work, you spend some time debugging. And you do this incrementally until you’ve solved the task. If you do it the TDD way, you save yourself from lots of debugging time and you end up documenting how to use the 3rd party library.

There are some other advantages as well. When you hand over the code over to other developers, they can use your learning tests to figure out the same thing you had to figure out, but they can do it by reading your code. Besides that, you also document how a 3rd party library is supposed to work. If they change their API’s or introduce a bug in the next release, your tests will fail, and you can trap this.

Uncle Bob have some good arguments as well;

“If you want to know how to call a certain API, there is a test that does it. If you want to know how to create a certain object, there is a test that does it. Anything you want to know about the existing system, there is a test that demonstrates it. The tests are like little design documents, little coding examples, that describe how the system works and how to use it.” – Uncle Bob

“Have you ever integrated a third party library into your project? You got a big manual full of nice documentation. At the end there was a thin appendix of examples. Which of the two did you read? The examples of course! That's what the unit tests are! They are the most useful part of the documentation. They are the living examples of how to use the code. They are design documents that are hideously detailed, utterly unambiguous, so formal that they execute, and they cannot get out of sync with the production code.” – Uncle Bob

So the next time you have to learn a new API, do it by exercising TDD.

Download the source code

Saturday, May 02, 2009 2:23:16 PM (W. Europe Standard Time, UTC+01:00) 
  Permalink  |  Comments [13]  |  View blog reactions  |