magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

Posts from the ‘Uncategorized’ category

Darren Hobbs

This is the primary reason I have mostly lost interest in tools such as Hibernate and Neo. Where the documentation says things like ‘Autogenerate your mapping layer and persist your domain objects’, I see ‘Tightly couple your code to your database’.

Which I don’t think really follows. Firstly, if you’re in the envious position of being able to have complete control over your schema, I don’t see why generating a schema from your domain objects is a problem, as long as your domain objects don’t become polluted by the underlying persistence mechanism. It’s not the tools fault if you end up with this tight coupling – it’s the fault of your architecture.
<!-more->
Lets look at my current project. We’re using JDO for persistence, but that’s a trivial implementational detail. Our domain objects exist in their own layer, and are completely clean POJO’s. All persistence is performed by a repository layer. Currently we’re using our JDO providers mapping tool to create our Object->Schema mapping tool – our mapping tool is also capable of generating a schema based on the mapping file.

Relational databases are hard to change. Especially once they’ve gone live. They very quickly foster an ecosystem of reports and queries, and almost always become an ad-hoc integration point for several applications, making schema changes very difficult.

There will come a time when we’ll lose control over our schema – this may happen after our first release (when we’ll have historical data that will need to be migrated) but in all likelihood we’ll fix our schema once our DBA has given it the all clear. At that point we’ll stop using the domain object to create the schema – it’s a pain, but a necessary evil. But with the right structure of your code and a decent build, I can’t see why your code ends up tightly coupled to your database.

Here is a case in point. We’ve found out that for strategic reasons we need to change over to Hibernate (personally I prefer JDO). The impact on our code? A single new implementation of our primary store (that’s one single class) – the real work is in rolling all the hibernate bindings, and even then it’s a one-time cost.

I received an email a few days ago from a helpful reader informing me that he’d tried to post a comment but failed. Initially I was worried that Perl was mis-firing again, until I noticed the URL he was trying to post to. A while ago I de-cruftified this site’s URLs. By default Movable Type generates simplistic URL’s named using the entry ID (e.g. 000334.html). Not only is this not terribly forward thinking (what if I moved to PHP?) the URLs don’t really match the information’s structure.

What I did back then was first to remove all URL suffixes. Next, I moved the URL’s into a format based on months and dates – for example /2005/04/13 would be used by all posts made in 2005 on the 13th of April. This left me with nice URLs, but I neglected to handle the fact that I had over 200 posts using the old form. These were still generating hits, but were an old version of the page. When I changed the comment posting these pages started mis-firing.

The obvious solution was to set-up Apache redirection rules for all the posts. To make life easier, I added an easily grep-able HTML comment to all the individual post pages. Next, I ran a recusive find over the archive structure, grepping for the comment:


	

find . -type file -not -name "*.html" -print | xargs grep "ENTRY "

The -not negated what followed, excluding all files ending in .html. This wasn’t completely necessary but the HTML comment I put in wasn’t specific enough so I was getting a few false positives from the old HTML pages. After this query, I was left me with several hundred results like this:


	

./2005/04/13/this_is_a_post: ENTRY 000342

I fired up SubEhtaEdit, and a quick regexp later I had the following for each of the 300 or so matches:


	

RedirectMatch permanent 000342.html ./2005/04/13/this_is_a_post

This was then pasted into my .htaccess file, and I could safely delete the old HTML files, safe in the knowledge that any Google hits for the old pages would get redirected to the new, de-crufty URLs.

While I was at it, I knocked up a favicon, some rollovers for the sidebar and entry navigation, and enhanced the side navigation to show the last few recent posts and del.icio.us links.

In my (albeit limited) experience, failures attributed to development processes – be it Agile, XP, DSDM, Waterfall or whatever – fall into two groups. Firstly, that those involved assume the process itself can succeed without making it work – that because there is a process, you don’t have to be organized, disciplined or put the effort in. Secondly, that people abdicate the responsibility of thinking in favor of the process itself – that is to say that they blindly follow a particular process without at any stage engaging their brains. To paraphrase Douglas Bader – “rules are there for the guidance of the wise and the obedience of fools”.
Continue reading…

Well it seems Joshua has finally given in to the hordes of taggers out there and has taken del.icio.us full time. What’s interesting though is how he’s managed this. His post to the mailing list mentions outside investment:

I’ve given a lot of thought to how to make this happen, and ultimately decided that the best way forward is to take on some outside investment.

I’ve taken this step because it lets me continue to grow del.icio.us while keeping it independent.

As yet no mention as to what the source of that investment might be. One of the dangers of outside investment is that the service changes to the extent it is no longer one that the original users care to use. This is certainly a concern I have Bloglines since their acquisition by Ask Jeeves. Whilst I’m in no danger of loosing my bookmarks (Joshua is clear on this – the users own their bookmarks and their tags) what is more important is the metadata. What has emerged has been described as a Folksonomy by many, and is without doubt what makes del.icio.us valuable. The ownership of the emergent network of tags is as yet unclear.

Personally I have no problem with Joshua making steaming piles of cash of del.icio.us, or even the metadata – as long as I still get to use it. Only time will tell.

In my earlier post I mentioned that ShortStats is unable to track failed referrers due to the way it works. ShortStats relies on a single line of PHP being inserted into each page you want to track, which then triggers a PHP script which logs the request in the database. I realised shortly after I posted that an obvious way to track failed referrers would be to put a slightly different PHP fragment into the custom 404 page. This would then log the original request (rather than the request for the 404 page itself) into a new DB table and you’d have yourself a failed referrer. Perhaps I’ve found a little project for myself this weekend…

ShortStat shows a nice breakdown by browser type

ShortStat shows a nice breakdown by browser type

I’ve been unhappy with my host’s choice of statistics software for a while now – Analog displays too much information at the same time as not providing enough information, all in a rather unattractive package. A while ago I came across Shaun Inman’s ShortStat. ShortStat is a PHP program which should work on most PHP-capable hosts, with a lovely UI courtesy of Mr Inman.

ShortStats breakdown by country

Also available is a breakdown by country

The single page statistics view shows pretty much everything I want to see – browser percentages, hit breakdown by country, popular hits, search strings and even OS of the visitor. It works by including a PHP fragment in each page you want to track – this makes it easy to install, but does mean I’ll need to keep using Analog to track failed referrers (which is an effective way of tracking broken links). You also need to setup password protection yourself, although I already use simple a Apache setup so it wasn’t too much of a pain.

Jehiah Czebotar’s PathStats is a ShortStat plugin (although the word plugin is probably not quite correct – the install process involves overwriting many of ShortStat’s files). What it does provide is valuable thought – it shows you which page eash browser visited. This is a great way of seeing not only how users arrived at your page, but shows you where they then go. One of the things I want to provide is pages tailored to those people coming from search engines – showing them related pages, popular pages etc. I want people to find this site via google, then stay for a bit, because when all is
said and done I just want people to like me 🙂

bits-on-wheels-swarm.gif

Bits on Wheels’ 3D Swarm view

It’s only been since I acquired my mac (not to mention my 1M broadband connection) that I’ve really started to use BitTorrent for anything. I was forced into downloading it to grab the Apple training video showing just how to crack out the mac mini. Initially I used the standard BitTorrent client, but recently I came across Bits On Wheels which takes visualization of P2P downloads to a new level. To be honest it doesn’t give you much more than the normal client, but it sure is pretty – the 3D Swarm view can be kind of hypnotic.

Yet again boredom got the better of me, and I’ve spent this last weekend working on a new site design. There are still a couple of minor IE6 problems to sort, but it seems fine on Firefox and Safari. The main change is that I’m now doing much less with the sidebar in an attempt to give a nicer minimal feel. I’m going to continue to work on some pages – I want to tailor the individual post pages to those coming from search engines, and might flesh-out the content there to display information such as recent and popular posts.

Continue reading…

apple-dock.jpeg

Well, right now I’m:

  • Recording the TV via the Elgato EyeTV 410 (which I can tell because there is a little TV picture sitting in the dock showing me the OC, which is cool and distracting when I’m trying to type)
  • Burning a DVD of some old backups (which the helpful Toast dock icon is informing me)
  • BitTorrenting various things (highly legally, honest)

    So, it’s that cool. The only problem now is that I’m not sure I’m cool enough to use it…

So here is the problem – I’m forgetful. This means if I think of something that I should put on my Basecamp to-do lists when I’m not actually at a computer, I have to rememeber it, which I can’t do. Or write it down on a piece of paper, which I’ll loose. Today is a case in point – I know I had three things to add to my list, but I can’t remember what they are. Well, unless Basecamp has a Blackberry front end (and for that matter someone wants to buy me a Blackberry) I guess I’m going to have to solve that little problem by myself…
Continue reading…