April 28, 2008

Caption Contest

IMG00120.jpg

I saw this icon on my plane flight back from Tampa.   I’m curious what the designer intended it to mean.   I came up with the following ideas:

  • Men and Women should put the number 0 on a pedestal.
  • Do not have sexual intercourse on this plane, or you will have blank-faced babies with stubby arms and one leg.
  • When you’re staring down the barrel of a gun, it doesn’t matter whether you’re a man or a woman.

Any others?

April 18, 2008

Chance of life developing in the universe

Regarding this story - Is there anybody out there?

  1. First, the Drake Equation called, they want their calculations back.
  2. Second, 1979 called, they want their song lyrics back
  3. Third, the journalistic standards on this article are mind-numbingly bad…. A 0.01% chance that life develops????
    1. That’s per-planet. Think about that for a moment. How many stars are there in the Milky Way galaxy alone?
      1. Between 200 and 400 billion.
        1. How many of these are similar to our Sun?
          1. Unclear, but not higher than 15%
    2. So (and this goes back to the Drake Equation) - how many of those stars have planets?
      1. Estimates are that 10% of sun-like stars have planets
    3. How many of those stars have planets in the habitable range
      1. Unknown, but at least a few we’ve found so far appear to be in the potentially habitable range - Let’s say 1%, based on the fact that 3 out of the 287 we’ve found seem to be close to livable.

Given all of these facts and estimates. How many Sun-like stars in the Milky Way?… Assuming 300 billion stars total, that’s 45 billion Sun-like stars. How many of these have planets?… About 10%, or 4.5 Billion. How many of those have planets in the habitable range? 1%, or 45 Million.

Yes folks, based on our latest understanding of the Milky Way galaxy, there are 45 million planets out there capable of supporting life.

Now, according to the initial article, only 0.01% of those will have intelligent life and civilization… That would mean there are “only” 4500 civilizations in the Milky Way galaxy.

April 15, 2008

Selenium RC Cookbook, Part 1

(This cookbook assumes you know the basics about how to get started with Selenium RC. These examples are also in Java, but should be pretty much consistent for any language)

Finding text in a certain place on the page:

Use XPath, treating the HTML of your page as well-formed XML.

browser.getText("//div[@id='content']/table/*/tr[2]/td[1]")

(In English: at any level of depth, find the div where the id=”content”. Then find the table element under that, and then give us the text of the first cell of the second row.)

Finding text anywhere on the page

browser.isTextPresent("Your Text Here");

Get the text of a URL link

Assuming you have text like: <a href=”…” > your link text here </a>, you could consider:

browser.getText("//a[@href='...']");

Note the consistency with the other example above - anytime you have an opening and closing <element> </element> tag, you can use getText() and XPath to find it.

Get the href of a URL link

Again, assuming you have text like: <a href=”my_link_here” > your link text here </a>, you could consider:

browser.getAttribute("//a[1]/@href");

which would return: my_link_here

Note the slight differences with getText() above, but the idea is generally the same.

How do I find what’s in my Select menu?

String[] options = browser.getSelectOptions("//form//select");

This would return an array of the option text from the only <select> element inside the only <form> element.

If you had more than one form, or more than one select:

String[] options = browser.getSelectOptions("//form[1]//select[1]");

This would return the options listed in the first select of the first form on the page.

April 11, 2008

Visit the Wayback Machine

From April, 2006 - Cedric Beust explains “Why Ruby on Rails won’t become mainstream

Personally, I think he turned out dead wrong on this.  If the AARP is building a large-scale software project in Ruby-on-Rails, with the ongoing back-and-forth between Django and Rails, and the various efforts to “port” rails to other languages, I think it is hands-down a mainstream contender.

April 10, 2008

BFD!

If Test-First Development (TFD) is a specialized subset of Test-Driven Development (TDD), then surely the equivalent specialized subset of Behavior-Driven Development is Behavior-First Development.

Today I had my first experience in developing BFD.

I know what you’re thinking:  BFD.

But it’s a BFD to me.  Using a rather exotic concoction of DBUnit, HSQLDB, Selenium, Cargo and EasyB, I was able to write a story  to describe some new functionality for a web application, and run that story as a test (via EasyB/Groovy), before I wrote any of the code to implement the functionality.

Other ingredients in this concoction:  Tomcat, Ant, Junit, Struts2, Spring, Cobertura and four or five different logging frameworks.

Observations:

  •  It is difficult to see what is going on when your story fails - the story failure is often fairly far away from the  code failure.
  • DBUnit throws multiple exceptions as part of normal operating procedure.  That is a crime against humanity.

Latest Cool Tool

I’m sure everyone else in the world found and mastered  XPath Checker long ago, but for those of you who haven’t, it is a fantastic Add-on for Firefox that lets you practice XPath expressions on real, live web pages.

Why would you want to do that? 

If you want to write Functional webapp tests via Selenium, a good, solid working knowledge of XPath is essentially mandatory for all but the most trivial of tests.

What about Selenium IDE? 

The Selenium IDE is incredibly helpful for navigating your pages, but it is not help at all with testing the content on those pages.

In other words, if you want to register a new user, add four things to your cart, visit your recommendations page and then check out, Selenium IDE will properly structure your clicks and everything else.

But if you want to find out if your checkout page lists your four items, and you need to be specific about where on the page  those items show up, you have to use XPath with Selenium to get to the correct table, div, what-have-you.

Enter XPath Checker.  During your Selenium IDE-driven  recording session, control-click on the page, and experiment with the correct XPath query to get to the cell/row/etc you want to see.

April 4, 2008

Recent Impressions

Hudson

Good Continuous Integration tool. Nice charts, easy to use, fairly flexible out of the box.   A _lot_ less setup work than CruiseControl.  And the plugin system is well done, and pretty nifty.

Struts2

An incoherent mess.  Documentation is spotty, uses a lot of contrived toy examples that blow up on anything more complex than hello world.  Documentation is also simply wrong in some cases (for example, the ‘var’ attribute on the iterator tag is not valid according to the TLD).  Namespaces are nice in theory, but frustrating in practice.   I can’t get the wildcard action management to work reliably, although this may just be pilot error.

Good things: 

The integration with Spring is nice, and I haven’t seen a web framework yet that is more friendly to unit testing.  When it works properly, the wildcarding is very nice.   The Action.execute() model is useful, and easy in concept.