Ivan Marks - the people's champion

is an excellent book from Media Press (isbn 978-0-9567015-9-6). As usual I'm going to quote from a few pages:
Young anglers were encouraged and taught the basic skills by more experienced anglers. The club would fish matches where novice anglers were paired off with the top men. For two hours the older angler sat patiently with his pupil explaining the correct tactics to use.
There are, of course, times of the year when the facility to make maggots sink at a reduced rate of fall is a great advantage, especially in still water.
A 4lb chub will eat a half-pint of casters.
His [Benny Ashurst] maxim was always to keep the fish feeding for as long as you can.
Tanked fish have been fed yellow maggots and given an electric shock every time the made a move to eat one. The same fish were fed white maggots and allowed to take what they liked without interference. Later, when those same fish were fed mixed yellow and whites they wouldn't look at the yellows - and can you blame them? That experiment proves that fish can learn.
The real secret with loose-feeding is regularity.
You must not panic and fool yourself into believing that the more stuff you throw in, the more fish will come out.
I told the Italian team manager that I might have taken the individual honours had I been able to stay catching bleak of around that weight. "No Ivan," said the Italian, "it isn't possible!" He explained that my 1oz bleak was a fat and none too healthy fish, and he was right. It looked spawn-bound. In fact he said it had a worm infection. And he explained that fish in that condition are not fit fish. They don't move to the bait fast enough - even if there are enough of them - to allow true speed fishing. Which helps explain just how deeply the Italians have delved into this type of fishing.
A barbless hook punctures the bait, but fills the hole it makes.
Roach and bream don't grab your bait with their teeth. They simply inhale water into their mouths and this sucking process puts the bait where you want it to go.
The biggest risk of breaking a line comes from shock impact. Sudden shock is to be avoided at all costs.

Fun and learning at Ericsson

I had the pleasure of teaching a TDD C++ course at Ericsson's Jorvas centre in Helsinki this week. As usual I made heavy use of cyber-dojo. Above is a screen shot of the dashboard of one of the practice katas. My evals were 5.8 for the course as a whole and 5.9 for teaching skills (out of 6). Some of the comments were:
  • Very clear.
  • You really got us understanding TDD.
  • Transformation of the mindset became clearly visible during the course.
  • Thanks!
  • Best course I've taken at Ericsson, thank you.
  • The cyberdojo is an excellent environment.
  • Very good hands on training.
  • cyber-dojo extremely nice.
  • It was fun!
  • You really need to try to do TDD in practice to see how beneficial and fun it is.
  • You made it visible in practice.
  • Fun fun fun.

Nicer HTML radio buttons

One of my pet peeves is plain html radio buttons. If I have a set of 5 radio buttons with 5 text labels of differing lengths then I want to be able to click anywhere on the shaded area and not just the text labels.

This is quite easy to achieve. Simply put each <input> into a <div>...
<div class="radio">
  <input type="radio" ... value="Red"/>
    <label>Red</label>
</div>
<div class="radio">
  <input type="radio" ... value="Amber"/>
    <label>Amber</label>
</div>
<div class="radio">
  <input type="radio" ... value="Green"/>
    <label>Green</label>
</div>
...and use a bit of jQuery
var $j = jQuery.noConflict();
$j(document).ready(function() {
  $j('div.Radio').each(function(n,node) {
    $j(node).click(function() {
      $j(this).children(':first').attr('checked', true);
    });
  });
});
Using a <div> changes the layout - so you might want to put each <div> into a table layout.

You can add some CSS to highlight the clickable whitespace...
  .Radio { background-color: Moccasin; }
  .Radio::after { content: "\00a0"; }
If you want to remove the bullet simply add the following
$j(document).ready(function() {
  $j('input[type=radio]').hide();
};
If you want to see an example of this, just try CyberDojo

Complexity and postmodernism - understanding complex systems

is an excellent book by Paul Cilliers (isbn 0-415-15287-9). As usual I'm going to quote from a few pages:
Complex systems operate under conditions far from equilibrium. There has to be a constant flow of energy to maintain the organisation of the system and to ensure its survival.
If resources were limitless, i.e., if growth could take place unrestricted, no meaningful structure would evolve. Boundaries, limits and constraints are preconditions for structure.
The theory of self-organised criticality tells us the following. A self-organising system will try to balance itself and a critical point between rigid order and chaos.
The classic definition of stability states that in a stable system small causes produce small effects.
The classical definition of instability, at least as used by Poincaré, is probabilistic. Unstable events are defined as events that have no observable cause.
The system of language transcends the choices of any individual user, and therefore has stability.
In the last analysis, the two facts are interdependent: the sign is exposed to alteration because it perpetuates itself.
When dealing with complex phenomena, no single method will yield the whole truth.

Bare bones ruby unit testing

This morning I spent a happy hour exploring a little of ruby's Test::Unit::TestCase. I started with this:
require 'test/unit'

class MyTest < Test::Unit::TestCase

  def test_one_plus_one_equals_two
    assert_equal 2, 1+1.1
  end

end
I wanted to see how little I needed to write my own, super-minimal implementation of Test::Unit::TestCase...
require 'test/unit'

class MyTest < MyTestCase

  def test_one_plus_one_equals_two
    assert_equal 2, 1+1.1
  end

end
After 204 traffic lights in cyber-dojo I ended up with this...
require 'assertion_failed_error'

class MyTestCase

  def self.test_names
    public_instance_methods.select{|name| name =~ /^test_/}
  end
  
  def assert_equal( expected, actual )
    message = 
      "#{expected.inspect} expected but was\n" +
      "#{actual.inspect}\n"
    assert_block(message) { expected == actual }
  end

  def assert_block( message )
    if (! yield)
      raise AssertionFailedError.new(message.to_s)
    end
  end

end

at_exit do
  ::ObjectSpace.each_object(Class) do |klass|
    if (klass < MyTestCase)
      klass.test_names.each do |method_name| 
        begin
          klass.new.send method_name
        rescue AssertionFailedError => error
          print "#{klass.name}:#{method_name}:\n" +
                "#{error.message}"
        end
      end
    end
  end
end
class AssertionFailedError < RuntimeError; end
which allowed me write...
require 'my_test_case'

class MyTest < MyTestCase

  def test_one_plus_one_equals_two
    assert_equal 2, 1+1.1
  end

end
and finally, I added this...
class MyTestCase
  ...
  def self.test( name, &block )
    define_method("test_#{name}".to_sym, &block)
  end
  ...
end
which allowed me to rewrite the test as...
require 'my_test_case'

class MyTest < MyTestCase

  test "1+1 == 2" do
    assert_equal 2, 1+1.1
  end

end
Fun :-)