magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

Posts from the ‘Uncategorized’ category

It just threw up this playlist for me on the iPhone – it seems my own personal DJ has finally arrived:

  • Beast Of Burden – Rolling Stones
  • Idioteque – Radiohead (live)
  • Born Under A Bad Sign – Jimi Hendrix
  • I Got Mine – The Black Keys
  • It’s Hard To Be a Saint In the City – Bruce Springsteen & The E Street Band
  • The E Street Shuffle – Bruce Springsteen & The E Street Band
  • Who’s Gonna Save My Soul – Gnarls Barkley
  • Play With Fire – Rolling Stones
  • I Taught Myself How To Grow Old – Ryan Adams
  • House Of Cards – Radiohead
  • Delirious Love – Neil Diamond
  • Old Enough – The Raconteurs
  • You Don’t Know What Love Is – The White Stripes
  • Shake Appeal – The Stooges
  • Shattered – The Rolling Stones
  • Oh Yoko – John Lennon
  • True Love Way – Kings Of Leon
  • Hear My Train A Comin’ (Acoustic) – Jimi Hendrix
  • Tell Me Why – Neil Young
  • Sprit In The Night – Bruce Springsteen & The E Street Band
  • Psychotic Girl – The Black Keys
  • Suprise – Gnarls Barkley
  • New York Serenade – Bruce Springsteen & The E Street Band
  • All I Need – Radiohead
  • Rest My Chemistry – Interpol

Hairball example I’ve been working on a tool called Hairball to track setter and constructor injection, and use of singletons in Java code. Right now, the tool is capable of creating dot diagrams (for use with GraphViz) and graphml diagrams (for display in yEd).

My initial motivation for hairball was as a tool to help me understand potential problems in my code bases – spot god classes, code that is hard to test, odd dependencies. The tool purposely doesn’t make any judgments about code bases – it just gives you the diagrams. What you do with them is up to you.

The first version doesn’t contain support for tracking of singleton dependencies, and the setter and constructor injection should very much be considered a first stab – so I could do with some beta testers. I’m looking to track down false positives and negatives, as well as get some general feedback. Is Hairball it easy to use? Does it misdetect dependencies? Can you read the diagrams? Does it blow up when trying to run on your mammoth code base (I’ve done nothing to tune performance)?

Future Features

I have a few more features I’d like to add, including:

  • Singleton detection
  • Displaying inheritance
  • Support spotting attribute injection from frameworks like Picocontainer or Guice
  • Overlaying other metrics (e.g. colour based on Emma output, make nodes taller based on number of instructions in the class)

The feedback I get will very much determine what gets added next.

Hairball is available now for download.

Update: There is a workaround for this problem, which allows you to sign-up for a prepaid account with AT&T which sidesteps the need for a Social Security Number. The Unofficial Apple Weblog has the full details.

I’m working in the US at the moment, and decided to pick up an iPhone. I’m here long enough to justify it (well, justifying a $600 phone is pretty damn hard). No problems in getting one – the SF Apple Store had plenty.

The problem is that as part of the signup for AT&T, I need not only a credit card with US billing address, but also social security number. I have neither. The shop assistant knew I was from the UK but mentioned nothing about this.

So now I had an iPhone that is a very pretty brick. I guess it’ll be going back in the morning…

I upgraded to the latest and greatest version of WordPress at the weekend, but forgot to reconstitute my .htaccess file, so everything apart from the index page was 404ing. Normal service should now be resumed, but please let me know if you spot anything odd.

It’s that time again – after the success of March, what better than an April meet-up?

No fixed topic (as usual) so just a general chat about Web 2.0 technologies in the relaxed atmosphere of a Pub in central London next door to where Sweeny Todd used to butcher people.

Demos are welcome – so bring along your latest gadget/tool/service or whatever, although don’t expect any Wifi!

As usual, signup on Upcoming, and stay tuned to the calendar or this blog for updates.

I’ll be presenting on database refactoring and specifically dbdeploy at this year’s XTech conference. XTech 2007 runs from the 15th to the 18th of May in Paris, and my presentation will be first thing on the morning of the 17th.

See you there…

Image from Flickr user Findo, licenced under the creative commons. Original URL: http://www.flickr.com/photos/finden/311114656/One of the struggles people can have when they first start pairing, is understanding when it is time to drive, and when it is time to watch. Developing a good tempo to the act of pairing – and understanding when the change over should occur – can make it seem like a much more fluid activity. When it is working well, outsiders will see the keyboard moving backwards and forwards between the pairs (albeit perhaps slightly slower than a game of table tennis!).

If one pair member hogs the keyboard too much, the other member can feel that they are not properly involved with development. Depending on your development tools and build times, you may need to identify different points at which to pass control. The important thing is to ensure that both members of the pair get to feel equally involved in the development. Set yourselves a target for the maximum duration for each member to have control of the keyboard – ten minutes seems a good target to aim for, but a shorter duration may work better for you.

Example – Test, Implement, Refactor, Switch

When using Test Driven Development, a good way to develop this tempo is to use the acts of writing a test and making it pass to define when to change over. I’ve seen success in having the person A write the test, then have person B get the test to pass and refactor, then write the next test before passing the keyboard back to person A.

Extreme Example – Chess Clocks

Sourced from flickr user SooYoung, under creative commons. Original URL: http://www.flickr.com/photos/sooyoung-family/376679716/This example was related to me by a colleague. The team in question had chess clocks at each pairing station. The idea was that each member of the pair got to drive for four hours of the eight hour day. To keep track, at each switchover they’d click the chess clocks to start the other persons timer. If at the end of the day if you’d used up all your time, you had to watch. Very quickly each pair worked out a dynamic in which the time became equally distributed – I’d certainly of liked some video footage though!

I’ve long been a fan of Amazon’s emerging webservices such as S3 or the mechanical turk – without doubt they are doing some of the most interesting things with web services anywhere on the Internet.

The mechanical turk is bridge between people who want work done, and people who want to do work. It handles payments, verification, matching qualifications etc. One of the first examples of it’s use was the art project to have drawings of 10,000 sheep done by people all over the world. Now Amazon have used the turk to help search for missing Microsoft Employee Jim Gray.

The turk is distributing satellite imagery of the area in which Jim’s boat went missing – and anyone with an Amazon account can help them out. I’m sure you can find worse things to do with ten spare minutes during your lunch hour.

List below, not neccesarily in any order, are the main reasons given for the lack of activity around both this blog and London 2.0:

Conferences

With xtech, OSCon, Agile 2007 and XP 2007 I’ve been busy preparing submissions, and I’ll start hearing back from them soon. Rather than continue with my Lego XP Game dog and pony show, instead I’ve submitted presentations on dbdeploy, Buildix, and will hopefully be helping out on a workshop with some colleagues. More information when I get the rejection letters.

Christmas

Well, it was nice – as was the many mammoth Medieval Total War 2 and World Of Warcraft sessions.

Work

I spent a lot of time writing proposals (which I enjoyed) meeting new clients, and playing with Python & Django. I’m getting really impressed with both Django (and the very good Django book) and the mature tool set for python development as a whole. More soon perhaps

Apathy

Yeah, well..I had stuff on, you know? And series two of deadwood to watch

Expect a bit more traffic here, and a London 2.0 meeting for the end of feb

Selenium is a very good in-browser testing tool. It has bindings for many different languages (including Java, Python, Perl, C! and PHP). With it you can create a suite of tests which can run tests in multiple browsers (including IE, Opera, Firefox and Safari).

The ability to run tests inside a browser is a huge boon to those of us who have to worry about cross-browser compatible websites. By having an automated test suite (and having it run regularly, perhaps using Continuous Integration) you can automatically run a set of tests repeatedly on a number of platforms, on a number of browsers, whenever code changes. Whilst this doesn’t do away with the need for normal exploratory testing, nor is it always possible (or sensible) to automate all tests, this can dramatically reduce the QA time required prior to a go live.

Selenium is a very good tool, designed to be much simpler to use than similar tools (such as Mercury’s products). It is a very good tool that you probably don’t need all that much.

Selenium Slowdown

Selenium’s strength – that it tests web applications in the browser – is also it’s weakness. Testing in browsers is slow. Not only do you have the overhead of starting and marshaling an external process (the browser) but the fact that the tests have be rendered on screen means that a sizable Selenium test suite can take an awfully long time to run.

There are techniques which can be used to handle long running tests suites (more later perhaps) but I suspect for most of you, you don’t need to worry about them

Testing the DOM

Think about what it is you want to test in your web application. You need to simulate some user activity (clicking a link, entering text) and test that some result is displayed to the user. Selenium is as good as most things out there at doing that – but as we’ve already said, it’s slow. What is the alternative?

Selenium Overview

Figure 1: An overview of a browser driver

Well what is it we are really testing here? Let’s start with the user input. For the most part (I’m excluding AJAX interaction here – more later), when a user interacts with a web page, they end up creating a HTTP request to the server. Your server acts on that request, and returns some HTML, which the browser converts into a Document Object Model, and which in turn gets rendered to the user.

So when we want to check what is displayed to the user, what is it we are actually doing? Our testing tools don’t look at the screen rendering – all they need to do is carry out assertions on the DOM itself.

So to test most web applications, we need to create a HTTP request, and perform assertions on the DOM. And Selenium certainly isn’t the fastest way of doing that.

Faking the browser

The reason that Selenium is slow, is the browser. We are using Selenium to drive the browser, which in turn submits a request for us. The browser then handles the response, creates (or manipulates) the DOM, and renders the response. Why not simply remove the browser altogether?

Tools like HTTPUnit (for Java) or Twill (for Python) let you do just that. With them, you can create a request, submit it directly to the server, handle the response and interrogate the DOM. HTTPUnit and Twill are effectively emulating the browser’s ability to create a DOM from a server response.

An overview of browser emulation testing

Figure 2: An overview of a browser-emulation testing

Test suites using browser emulation tools like this will be an order of magnitude faster than similar Selenium test suites.

No place for Selenium?

There is certainly a place for in-browser testing. In our overview of browser testing above, we implied that the DOM for any given page is created entirely as a result of a response from the server, but the world isn’t that simple.

Using Javascript, web developers have for a long time been able to manipulate the DOM by executing on the client side with no interaction with the server. Selenium (and similar tools) are still very useful for testing these kinds of situations – however for most of us there will be much less need for these (slower) tests.

Conclusion

The tools available for browser testing have come on leaps and bounds in recent years. There is a place for browser drivers (like Selenium or Sahi) and for suites based on browser emulation techniques (such as HTTPUnit or Twill). Knowing which to use and when can result in significant time savings when running your test suites.