June 2008 Archives

Update: based on the work I detail here I have created my own Javascript tooltip library based on Prototype.

Over a decade ago Borland had an IDE called Intrabuilder, which allowed you to create websites in a Visual Basic like manner using Javascript on the server. After leaving postgrad study I worked at a now defunct dot.com called Electrolley for 9 months using this tool to create an online grocery store. Serverside javascript was an idea well ahead of its time. Indeed, javascript on the client side in 1997 was crap too. Now javascript is cool and moving forward (backwards?). With my new project, I need to return to Javascript and the last couple of days have been a hard reintroduction.

I am using Prototype and Scriptaculous to make my website as easy to use as possible. I also found some random code on the web to do tooltips - it almost worked! Applying tooltips to Scriptaculous Sortable elements leads to many problems, and I have just finished largely rewriting the library.

  • After moving some sortable elements the tooltips of the moved elements would be displayed underneath the unmoved elements. This is because of the way z-index stacking contexts are created in browsers. In moving an element, Scriptacolous clones it and moves the clone, inserting a new element when the element is dropped. This causes the dropped item to be in a different z-index stacking context than the other items. To get around this, the tooltips need to be drawn outside the moved elements context. This can be done by cloning the tooltip and then inserting it into the document at a point outside the sortable elements' container. I have explicitly put in the id's to which the tooltips is being attached, they should probably be passed in (left as an exercise for the reader).

    this._clone = this.tool_tip.cloneNode(true); $("container").insertBefore(this._clone, $("main_content"));

    When the tooltip needs to be hidden, just destroy the clone:

    Element.remove(this._clone); this._clone = null;
  • This also means the tooltip needs to be positioned absolutely, so ensure you are using absolute screen x & y coordinates.
  • Dragging a sortable element over other elements results in a number of mouse events firing as the elements are redrawn. Many of these events are consumed by Scriptaculous and not passed on. Thus, the tooltips hide and show functions may be called in any order, resulting in spurious and permanent copies (since it is cloned) of the tooltip all over the screen. To get around this just ensure there is only ever once tooltip on the screen at a time, so at the top of the show method put

    if (this._clone) { hideTooltip(event) }

It seems simple now I've fixed the problems, but it took a couple of days to remember my old Javascript knowledge.

Reality used to be a friend of mine

| | Comments (0) | TrackBacks (0)
I was reminded recently that sometimes managers can wilfully ignore the reality that they work with humans rather than machines. Some examples from my past workplaces:
  • At a large well-known consultancy a manager used Microsoft Project to estimate the elapsed time of a project at 6 weeks. I thought that was impossible given the estimates for individual tasks in the project (which I had a part in determining). The manager assured me it was all fine because he just put the tasks into Project and that was the date that came out. I asked to see the Project data. It turned out that he had assumed that all people in the project would work on the project for 5 days a week, no holidays or time off. Problem was the project started on the 1st of December! He had ignored Christmas, New Years and all the holiday time that people had already booked. The project was several weeks late according to the original finish date. However, after taking the holidays into account the project was on time, but the client thought we were hopeless anyway because even after pointing out his error the manager had still shown the client his original unrealistic date!
  • At a different firm it was generally accepted that a rota was required to fairly apportion weekend work. The manager would assign each weekend to a team member in turn. So who would do the first weekend, just a few days away? Well, the person who was currently out on holiday for the next couple of weeks of course!
 
And just to show it is not always the managers. I was doing a short, tactical project for a couple of financial markets' traders (consider them very important users). One Monday I deliver the project and they are immediately unhappy - "unworkable and obviously wrong" they say. I return to my desk and work on their fixes. On Tuesday I give them the next version - "what are you thinking, worse than before" they say. I sit down with them and they give me a 10 minute lecture on how they see it working. I leave with a good understanding of what they want.  For Wednesday's version they say, "perfect, why couldn't you do this the first time". Only thing was I just gave them Monday's version again!
 
Of course my lips are sealed on my stupid mistakes.
 

Through another's eyes

| | Comments (0) | TrackBacks (0)
Alpha testing has not gone as well as I hoped. Over the last few weeks I have been adding functionality and I thought the system was quite usable. So as a final step before expanding testing, I sat down with my first alpha tester to watch them use it. I expected them to suggest extra features. I had a long list of extra things I could do, but wasn't sure which were important. The good news was that they only suggested a couple of small things that I already had on my list. The bad news is just watching them use the site made me wince and clearly wasn't the best experience for them either. Over the 10 minutes of the test I quickly filled a couple of pages with issues: what does this mean, what does that do, why is that there, how do I do that?
 
I can heartily recommend watching someone removed from development trying to use your system. After a couple of months I am too close to the program. I no longer see what is displayed, I just know what needs to be done. I also know how to move around the site. Seeing the site through someone else's eyes was illuminating. Watching them have to move the mouse all the way across the screen to do two related actions made me realise I focus exclusively on one bit of functionality at a time. Seeing them wonder if two similar but unfamiliar terms referred to the same concept made me realise I don't read the text. When they suggested that grey buttons made it look like they we deactivated, I remembered that I meant to spend some time on the design instead of just working on functionality. I have decided that I will not add any new functionality for the next couple of weeks, instead I will focus on fixing up what is already there.

Been There, Done That

| | Comments (0) | TrackBacks (0)
I read this blog entry on common distractions that will delay a startup launch date. Sad to say I have previously done all these on previous projects before ultimately abandoning them. Happy to say that so far on my current project I have avoided all of them.

1st Poker Evening

| | Comments (0) | TrackBacks (0)
Yesterday was the first poker game I organised at my place. I have been playing poker for a little over a month now, mainly free online games. I felt it was time to try playing against people. Although I was hoping it would be more of a social event than a full-blooded competition. For many years I was put off playing poker due to the "fresh victims" attitude many experienced players had towards people new to the game. It didn't seem like the learning experience would be much fun. I hoped we would avoid that and think we succeeded.

I sounded out a few friends and invited them around for an afternoon and evening of tournament style play. In the end there were six of us playing - Ann, Ian, Ury, Christian, Cristina, and me. A good number considering the space. Ian and Ury said they had played before, but everyone else claimed to be a beginner. We played two £5 buy-in tournaments with the blinds doubling every half-hour and rebuys allowed for the first hour (although no one used them). I don't remember many of the hands, but will attempt a short description of the evening.

In the first game Christian went out first, almost right on the hour mark, then Ury went, quickly followed by myself. However, Ury was lucky not to be the first out on a few occasions. Ann's patented "fold-raise" tactic put out an unlucky Cristina and bewildered the other players. On three hands when Ann was the big blind she "folded" before being reminded checking was free. Then post flop she would raise or call against Cristina's all-in. All three times she won with river or turn cards. The Cristina event was the last appearance of the "fold-raise", perhaps due to the laughter and friendly taunts that ensued. Still, we all left the night with a new poker trick in our arsenal, though I personally wouldn't have the audacity to attempt it! Ann assures us it was just "ditzy play", but who knows? Ann ended up beating Ian heads-up as he lost 5 showdowns in a row as the rising blinds forced one or both all-in pre-flop.

In the second game Ian was out first - although this was just after a call from his girlfriend inquiring as to his whereabouts. He left soon after. Then Ury and I went out. At this point the game settled down with three roughly equal stacks and few big raises. As the blinds rose Ann tried a few bluffs and got burnt by calls. With a single big blind left she went all-in a couple of times without looking at her cards, busting out Christian in the process. Ann and Cristina went heads-up for the win. Again the rising blinds forced pre-flop all-in play and again, despite starting the heads-up as the small stack, Ann was the lucky winner.

Afterwards Ann described her winning tactics as "staying sober and bamboozling them with ditzy play". Future opponents beware!

Things I learnt from the evening:
  • Watch out for people staying sober!
  • Poker games go longer than expected.
  • Having the blinds rise so high that the game finishes with people being forced to go all-in pre-flop every hand is not a satisfying end. However, I can't see a way of forcing an end otherwise.
  • Don't bluff people who always call.
  • I won't remember specific hands later - I should take notes if they are noteworthy.
  • It is fun to play (as long as there is not too much at risk - at least at my level). I will definitely organise another.

If any of the players remember any other good hands other than the ones I mentioned, feel free to add them in the comments.