Archive for June, 2006

CSS Margin/Border Ordering

So help me God I hope I never forget this again, but no doubt its gone out of my head by monday.  This is one of the things that I have to look up every six months or so when I need to muck around with CSS.

The order of the margin property works like this (copied straight from w3schools):

h1 {margin: 10px}
all four margins will be 10px

h1 {margin: 10px 2%}
top and bottom margin will be 10px, left and right margin will be 2% of the total width of the document.

h1 {margin: 10px 2% -10px}
top margin will be 10px, left and right margin will be 2% of the total width of the document, bottom margin will be -10px

h1 {margin: 10px 2% -10px auto}
top margin will be 10px, right margin will be 2% of the total width of the document, bottom margin  will be -10px, left margin will be set by the browser

The Switch

I’ve switched. Two weeks ago I bought a Macbook Pro, and I’ve got a few thoughts on it so far.

When I’d decided to make the purchase, I looked for every avenue to soften the blow a little. To that end, I got hold of a Powerbook G4 and found a store that would take a trade in. When I called to find out what price I could get the size of the screen was discussed. “Its a 17 inch” I told them. Of course when I got the box out to package it up I realised that it was only a 15 inch model! The screen was so much bigger than my 14.1 inch ThinkPad that I thought I had a 17 inch.

Anyway, I was slightly wary that the new MacBook would sacrifice the portability of my ThinkPad. I haven’t travelled any further than the couch with the MacBook so thus far it hasn’t been a problem, but the real test will be when I start carrying it to and from work everyday.

Onto the configuration. I got the 2ghz model with the 15.4 inch non-glossy widescreen and 80gb hard disk. Memory was upgraded from 512mb to 2gb.
My impressions:

  • It’s very fast – having used an aging Powerbook G4, I’m impressed with the MacBook Pro’s speed.
  • Love the widescreen – in the windows world I used to have everything maximised, but that doesn’t really make sense with a widescreen — there’s almost too much screen real estate, but that’s a pleasant problem to have.
  • OS X seems very intuitive – generally things have just worked how I’d expected. “Switching to the Mac: The Missing Manual” has been an invaluable book for all the little things that I couldn’t figure out.
  • The maximum screen angle is too little – at its fully extended maximum the screen angle is about 120 degrees, much less than the ThinkPad, and too little by about 30 degrees.

So far I’m very happy with the purchase, but I’ve hardly started the heavy lifting. I’ll have more thoughts to add in a month or two I reckon. Some features I’m really looking forward to using are the virtualisation for the couple of Windows programs I rely on, and BootCamp for work usage.

Premature Wrapping Drives Me Crazy

Looks like there could be evidence that premature wrapping may make your code harder to read: How Long Is Too Long

I can’t stand reading Java/C# code wrapped at column 80.  There are just way too many method calls and parameter lists split over multiple lines.  It interrupts my flow and dramatically impacts my productivity when reading other peoples code.

One of the beautiful things about leading teams is in a case like this you can enforce your preference :)

Great Factory Definition

Was reading “Refactoring To Patterns” and came across a great definition for the often misused term “Factory”.

A class that implements one or more Creation Methods is a Factory.

This leads to needing a few more definitions:

  • Creation Method – any method (static or non-static) that creates an instance of an object.
  • Factory Method – non-static method that returns a base class/interface type for the purposes of facilitating polymorphism.  Implemented by class and one or more subclasses.  Factory Method is NOT a Factory however.
  • Abstract Factory – interface for creating related or dependent objects without specifying their concrete classes.  Designed to be substitutable at run-time.  Abstract Factories are Factories.

Confluence Search Plugin For Firefox

There are probably one hundred of these out there already, but I spent five minutes creating a Confluence search plugin for Firefox today. Dump the files from the zip in the FIREFOX_HOME/searchplugins directory.

Found out while creating that Firefox does some weird XML parsing though.