Kent Beck on incremental degradation (“defactoring”) as a design tool

Thanks to @AdamWhittingham for pointing out a great post from Kent Beck in which he suggests an “if you can’t make it better, make it worse” approach to incremental development. This is a habit that has been a part of my development process for a long while, and I have needed to explain it to mildly puzzled colleagues several times.

An analogy I have often used is that of Origami, the Japanese art of paper folding. The end results can be intricate and beautiful, but the individual steps often seem to go back on themselves, folding and unfolding, pulling and pushing the same section until it ends up in the precisely correct configuration. Just as folding and unfolding a piece of paper leaves a crease which affects how the paper folds in future, factoring code one way then defactoring it to another leaves memory and improved understanding in the team which affects how the code might be changed in the future.

Don’t be afraid to inline and unroll, what you learn may surprise you.

TDD: Driving from the assertion up

I’m doing quite a lot of agile and TDD mentoring at the moment, so such things are always floating near the top of my mind.

A recent article from Mark Needham presents an interesting view on how to construct code within tests, and the impact that might have on how tests drive design of code.

REST and versioning, a more concrete example.

There’s an interesting discussion going on at The Wisdom of Ganesh in which Ganesh Prasad and “Integral ):( Reporting” (presumably the “JJ Dubray” mentioned in the article) are trying to work out some issues around versioning, REST and SOAP. This post is also referenced and commented on at infoQ.

In the 14th comment to the original article, JJ calls for a real-world example – this is a good idea which should help ground the discussion and diffuse the temptation to communicate in abstract principles. In the spirit of this request, I will describe an example based on problems I faced in a previous job.

The first version of the system we were working on consisted of a server component, coded in Java, which provided remote services to several client systems. Each of the client systems was a Java web application, responsible for providing customer-specific web pages and navigation using the services and content provided by the central server. For some customers there would be just one instance of the web client, for others with greater load there would be several.

The server system was responsible for managing products for sale, including descriptions in multiple languages, format and compatibility meta-data, thumbnail images in several sizes, prices in multiple currencies. As well as access to individual items and collections, a search facility provided a way to discover or look up products. The server also managed customer details and purchase histories, and handled both delivery of content and general messaging (by email and SMS) during the purchase process. The client systems were responsible for display and navigation of a product catalogue, customer branding, “shopping cart”, login/logout, and everything else a user experiences.

The API between client and server included ways to list products by category, fetch details of specific products, search using a variety of criteria, make and cancel purchases, fetch and update user data and so on.

I suggest this should be a reasonable system on which to base a discussion – it embodies similar concepts to many other systems, and is neither trivial nor impossible to build. Interestingly, both SOAP and REST versions of the interface between the clients and the server were implemented at different points in the life of the product.

So, on to versioning. It seems to me that there are several kinds of changes which might require versioning. I will list a few here, but I welcome suggestions for others I might have missed.

  • The first deployment of the system worked with only a single currency. The move to multiple currencies was a potentially major change in the interaction between client and server, even though each client works only in a single currency.
  • The customer for one client implementation required the provision of extra services, specific to their market, which were not required by (and should not be available to) other clients.
  • The initial version of the search facility returned data for all matches, with paging through the results implemented entirely on the client. When there was a lot of data in the catalogue this became an unacceptable performance bottleneck, especially as results beyond the first few pages were hardly ever viewed. An alternative approach was suggested where a client would request a specified page (of a specified page size) from the search results. This required changes in both the search request and search results.
  • A new source of products introduced the idea of collections. Items in a collection could be purchased individually or as a bundle. Viewing a collection while browsing, searching, or in a user’s purchase history, should allow a user to “drill in” to the collection to view the items within it. Items located while searching should indicate how to purchase the collection, as well as how to purchase the individual item.

Is this a useful amount of detail for a scenario? I have my own experiences of working with this system and the choices we made, but I’d love to read any suggestions for how you might handle any of the transitions above in a live system with multiple client systems deployed, many of which can not be changed easily or often, and a server full of historical purchase data. Procedural remoting approaches (SOAP, XML-RPC and Java RMI etc.) and resource-based approaches (REST) are all welcome.

Distributed Source Control as a tool for Set-Based Design

I’m currently spending a fair amount of time on evaluating distributed version control systems (DVCS) such as git, bazaar and mercurial. Some things which were easy using a centralized version control system such as subversion or cvs seem more complicated, but I am now starting to find ways of using DVCS to do things which the old systems simply could not manage.

It took me a whole evening of fiddling, but I have now set up git to allow me to make chanches to a local version of one of my web sites and commit changes as I feel like it, then when I am happy, send the changes to the live web site with a single git push. This has been working well for a few days, so I plan to roll out a similar structure to the rest of my web sites soon.

Another interesting use for DVCS was pointed out by Francisco Trindade. Distributed version control can help to enable “set based design“. This is a technique where a team samples a wide range of possibilities to converge on a “sweet spot” where market need, business value and manufacturing efficiency are balanced.

What Is a Service?

Sometimes in software development it seems that everything is turning into a “service”. For diagram-loving architects, decribing everything in terms of services is a great way to avoid getting involved in fiddly implementation detail.

The trouble with this approach is that hiding everything behind services can lead to thoroughly de-optimised systems. Greater hardware needs, greater software licence costs, duplication of development and maintenance effort, higher data-transfer and bandwidth requirements, etc. …

Phillip Calçado “Shoes” has a good example of some of these problems at What Is a Service?

YAGNI: Some thoughts

YAGNI – it’s a neat term for a valuable technique. Ignoring an unknown future to concentrate on a known present. That does not mean that it’s application is obvious, though. I often find myself in “discussions” with architects and designers who recoil at the idea of building something specific to one customer or situation, when it is “obvious” that a general solution will be better.

Mark Needham has written some of his thoughts on this topic.

YAGNI: Some thoughts at Mark Needham

Color Scheme Designer

From time to time I find myself forced to design a web site without being able to hand the task to a proper graphic designer. I find that I can just about produce workable layouts, but colour baffles me.

I’m always on the lookout for useful tools to help the design-challenged, and this one looks particularly cool, as it includes a way of checking how your chosen colours might look to users with different types of colour-blindness.

[ws] Color Scheme Designer.

How to Kick Ass at anything

Kathy Sierra is always worth paying attention to. This 30-minute audio is Kathy doing her inspiring, thought-provoking, energising thing at an O’Reilly conference.

Kathy Sierra on How to Kick Ass | IT Conversations

A structured way to work with user stories

For someone steeped in the traditional idea of requirements and features, working with agile user stories is often hard to handle. I have invested a lot of time over recent months attempting to build a good understanding of what a user story is, and how it differs from a feature, a change or a requirement. Marc McNeill has an interesting article (with slides!) about how he deals with this kind of issue in product workshops.

What is the story? | dancingmango

Testing Will Challenge Your Conventions

I’d not seen this, and if you haven’t either then it’s well worth a read. Tim Ottinger gives a detailed list of the ways that Test-Driven Development (TDD) changes code.

Testing Will Challenge Your Conventions

Adopting Simple Design

A summary of some mailing list discussions about adopting and implementing incremental design.

InfoQ: Adopting Simple Design