Feb 25 2005

Dual heading redux

admin @ 1:11 pm

A belated addendum to my last post.

We swapped around some hardware in the office last weekend. I ended up with the 19″ monitor on my desk… imagine my surprise when I plugged it into the iBook and it came up at 1600×1200.. still with full colour depth. Very nice.

Tags: 

Feb 18 2005

Dual head iBook

admin @ 10:07 pm

I found the most awesome tweak to my iBook today… and a big WTF for Apple.

I hooked up an external monitor to my iBook today… and verified what the manual said: it only mirrors the laptop display and the standard maximum 1024×768 resolution. Bother… I had visions of dual head displays… especially after seeing what Keynote can do with the projector and laptop screen.

Not to be deterred, I went online to see what I could find. It turned out to be a quick and productive search.

A simple download/install of Screen Spanning Doctor gave me exactly what I was after. Not only do I now have my desktop spread across two screens, but the 17″ external monitor is now running at 1280×1024.

So.. the WTF… if the video system on the iBook is cabable of driving two monitors, one at 1280×1024, and the other at 1024×768, both with millions of colours…. why isn’t that supported out of the box?

I’m revelling in geeky happiness.

Now I can’t wait for my next presentation!

Dave

Tags: No Tags

Feb 16 2005

iBook

admin @ 12:51 pm

I picked up my new iBook… still in the shipping box… monday afternoon. However, being Valentine’s Day, it didn’t get opened until Tuesday morning.

Booting and running through the setup was painless and fast.. it took a few minutes to migrate my stuff from the iMac.. but wow.. i was able to pick up right where I left off the day before. Sweet!

Once I had asured myself that all was well, we opened it up to add the 1G ram stick that I had gotten with it. It flys along nicely now… with a 1.33 GHz G4 and 1.25Gb of ram. Whew! Throw in the 60Gb drive, and the superdrive and it’s both the most powerful computer I’ve used as well as the lightest.

I’ll be picking up an Apple keyboard next week for use at my desk and the search will continue for a mouse/trackball that looks good next to the iBook. I love the look of the Apple mouse, but I want 3 buttons and a wheel… and I’m a big fan of Logitech’s Thumbball.

If anyone has suggestions in that regard, let me know.

Tags: 

Feb 10 2005

Private is Private

admin @ 10:23 am

When refactoring some code recently, my pair and I came across yet another reason why state based testing is bad.. and even more.. why testing using access to private state is incredibly bad.

We were doing some serious refactoring…. tackling a class that had become a catch-all… thousands of lines and several dozen methods… and splitting it up into multiple classes, each with a single responsibility.

We did this by creating new classes and moving groups of methods and associated instance variables to the new class, and leaving delegating methods in the original class. These we will clean up on the next pass.

We did this for one responsibility and suddenly tests that had been written long ago started to fail. This perplexed us since the original methods remainded in place in the original class, simply delegating to the real methods in the new class.

A quick exploration of the failing test revealed what was happening. The test in question was using reflection to get access to private fields in the class being tested. This went both ways… private fields were being set with fake values for purposes of the test, and assertions were being made on the values of private fields.

This is evidence of a serious misunderstanding of how you should be writing tests: they should be based on behaviour and function.. not state. An object’s state is simply an implementation detail, and should not be exposed to, or relied upon by, other objects. Guess what.. that means no getters & setters, either. But that’s a discussion for another time.

The problem that we ran into with accessing private fields in a test is that it makes the tests brittle, throwing a monkey wrench into the process of refactoring. When we were refactoring we made a change that did not effect the behaviour. That should NOT cause tests to break. But it did.

Why? Because those tests were accessing a private field of the class via reflection.. and we had moved that field to a new class.

Example:

Let’s start with the example from the first paper in the references section below:

class FieldTest {
  public String publicString = "Foobar";
  private String privateString = "Hello, World!";
}

We’ll pull in the test from that article as well (even if it is contrived):

...

FieldTest f = new FieldTest();
String s = (String)PrivateAccessor.getPrivateField(f, "privateString");
assertEquals("Hello, World!", s);

Now, say we add some behaviour that uses the private field:

public String makeHeader() {
  return "<h1>" + privateString + "</h1>";
}

so now we see some behaviour that doesn’t belong in the class (just go with me on this).. creating the header.. so we can extract that and the variable that only it uses to a new class:

class HeaderCreator {
  private String privateString = "Hello, World!";
  public String makeHeader() {
    return "<h1>" + privateString + "</h1>";
  }
}


class FieldTest {
  public String publicString = "Foobar";
  public String makeHeader() {
    return new HeaderCreator().makeHeader();
  }
}

Now the test that relies on accessing privateField will fail since we’ve, quite legitimately, moved it.

So, it’s a bad idea to write tests based on the state of an object, especially when that state is only available in private fields. That being said, don’t do it..and if you are.. stop doing it… and fix where you did do it.

References

  1. Subverting Java Access Protection for Unit Testing by Ross Burton (NOTE: this article presents what NOT to do)
  2. State vs Interaction Based Testing by Nat Pryce
  3. Mocks Aren’t Stubs by Martin Fowler
Tags: 

Feb 09 2005

Mac Attack

admin @ 7:15 pm

I’m coming out of the closet… I’m buying my first Macintosh… a shiny new, well loaded iBook 14″ (1.25G/60G).

I’ve been a Mac-user-wannabe since late 1983 :) when I saw the first announcements & reviews of the first Mac. Remember the Mac commercial from the ‘84 Superbowl? That’s how I’m feeling… after years of oppresion from Windows, then Linux, then more Windows. Finally freedom is in sight!

I’ve been using Nancy’s iMac for a few days and love it… (400 MHz G3)… i’m ready to take the plunge… and since I have to return my ThoughtWorks issued WinXP laptop and replace it… why not do so in style…. everything I do these days is platform agnostic: Java, Ruby, Smalltalk, documents, presentations, …) so there’s no real need to be Windows compatible.

I have one lined up and waiting for me at an area Apple reseller (Apple.. we need retail stores in Canada!!) . It’ll have to wait until Monday :( I’m in Detroit at the moment.. and don;t get home until late Friday night.. and they’re not open on Saturday.. and no one’s going to be in town to make an exception for me… so Monday it is.

Tags: 

Feb 05 2005

School Parking

admin @ 7:08 pm

OK.. here’s a WTF moment for you all.

This has to do with what must be the absolutely most stupid traffic management that I’ve ever seen.

The driveway for this school is one way, going in to the right of the school, across the front, and out on the left. There are angle parking spots along the section across the fron of the school… additionally there is room for at least two lanes of traffic.

So, we were there to pick up Thomas (Nancy’s son) last week.
Ok .. it’s a school.. so there are buses. Additionally people pick up their kids. People (mostly teachers apparently.. but that’s another rant) park in the angle spaces… still plenty of room for busses to line up in front of the school for loading.. and room for parents to drive along as well.

Now, someone in their great wisdom decided that the busses should angle park in front of the school. This allows more buses to park. Great.. easier/quicker to load.

But this has a couple interesting side effects. First buses form a queue… they have to leave in order. Worse, though, is the fact that when the buses are angle parked.. they don’t leave enough room behind them for even a single row of traffic.. so parents are effectivly blocked.

A bit more thought would seem to be required.

Tags: 

Feb 01 2005

Independant Again

admin @ 2:06 pm

It’s official. My 2 week notice is given, I’m no longer with ThoughtWorks as of Feb 11. Due to changes in my personal life that make me not want to travel as much as was required, and a very compelling offer, I’ve decided to hang out my own shingle once again.

For the foreseeable future I’ll be consulting to DiamlerChrysler in the Detroit area as architect and OO/process coach/mentor/guru, spliting my time between onsite & home.

ThoughtWorks is a great company, full of great people, and I’ve enjoyed working with/for them. The situation just stopped working for where my personal life is going.

Tags: