codeRambler Ramblings on code, the web, and technology

When is a task considered to be Done?
Tuesday July 31st 2007, 9:57 am
Filed under: Agile, Javascript, Web development

In recent Agile projects I have been involved with, we often talk about the word “Done”. Specifically we are talking about when a task/story that you are working on is finished.

I heard someone in my team say that “it isn’t Done until it’s in the green column” – referring to the colour-coded columns we move story/task card through as we take them from the “holding pen” through “development” (red), “ui review” (black), “customer preview” (orange) and “qa” (blue) to “done” (green).

So when is something considered to be Done? Is it Done when you have finished writing the code? When you have finished testing the code? What has to happen to a story/task before it is allowed to make the green column and be called Done?

My definition of Done:

  • All code has been developed using Pair Programming or Peer Review
  • The acceptance criteria for the story/task have all been met to the customer’s satisfaction
  • Unit tests have been written that test the code and document it’s functionality
  • Supporting acceptance tests that support the acceptance criteria
  • The code is checked in to the build server – and all the tests continue to pass
  • Any QA issues are resolved (which may necessitate returning the story/task to development again)

Of course each story/task will have a different path to Done, and some will take a shorter route than others – but the definition criteria above should remain constant for all. If you make sure your stories/tasks follow this prescribed course to Done, you will have less “returns” later on and produce better quality code from day one.

You will! Try it and see.



It doesn’t smell right!
Thursday July 05th 2007, 2:38 pm
Filed under: Agile, Javascript, Web development

How often do you refactor your code so that it works better or is easier to understand? Hopefully this is a constant process where you are refining and adapting on a regular basis (note that this is not quite the same as just rewriting code for the sake of it). Recognising that a section of code “smells” and needs to be refactored is not a particularly straight-forward task, some of the signs I use to spot “smelly” code include:

  • repeated blocks of the same code in different areas of the code base
  • huge long “if...else if” blocks
  • variable names that have no meaning or description of their contents
  • function names that are not descriptive of their purpose
  • code that doesn’t have supporting unit tests

Of course there will be different “smells” for different programming environments, I’m a Javascript developer and my “nose” is focussed on how my javascript code performs within web applications.

Have you sniffed your code recently to check that it doesn’t smell?



Make your PNGs 32-bit
Wednesday June 13th 2007, 11:58 am
Filed under: CSS, Web development

You should always ensure any alpha transparent PNGs are 32-bit to ensure that they always display the same colour across all browsers. Recently, Firefox and IE displayed a particular 24-bit alpha transparent PNG differently. Changing the PNG to 32-bit fixed this and both browsers rendered the PNG the same.

I have also experienced this with Safari 2 on MacOSX – again, switching to 32-bit PNG fixed the problem.



How do I use alpha transparent PNGs across all browsers?
Saturday May 05th 2007, 10:40 am
Filed under: CSS, Web development

Many web developers have shunned the PNG image format in the past. For some this has been because of a perceived lack of support for alpha transparency (described formally as alpha compositing) in Internet Explorer. Here are some directions on how you can use alpha transparency successfully across all browsers – and specifically IE 6 for Windows.

The examples below rely on the following CSS code (described below):

<style type="text/css">
  #demo1 {
    width: 250px;
    height: 100px;
    background: url(images/logo.png) transparent 0 0 no-repeat;
  }
</style>
<!––[if lt IE 7]>
<style type="text/css">
  #demo1 {
    background-image: none;
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader
        (enabled=true,sizingMethod=scale,src=/images/logo.png);
  }
</style>
<![endif]––>

The first block of CSS sets a background image on an element with the id “demo1″ (typically a div, span or img) for all browsers. This works fine for everything else, but doesn’t work with IE prior to version 7.

The second block targets just these “broken” browsers through use of a conditional comment. This second block uses the filter property to set up a proper alpha transparent version of the png. Read more about this here at the MSDN site.

In the following example the CSS above would show the logo.png with alpha transparency as the background to a div:

<div id="demo1"></div>

This next example shows that you can display a png with alpha transparency by targetting a transparent image:

<img src="transparent.gif" id="demo1" alt=""/>

There are plenty of variations of this technique. All the examples above are considered “standards friendly”. This final example shows the same CSS simplified (but not passing validation):

<style type="text/css">
  #demo1 {
    width: 250px;
    height: 100px;
    background: url(images/logo.png) transparent 0 0 no-repeat;
    _background-image: none;
    _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader
        (enabled=true,sizingMethod=scale,src=/images/logo.png);
  }
</style>

If you are putting the CSS above into an external stylesheet, then be aware that the path to the logo.png when used as the background image is relative to the CSS file, but the path to logo.png when used in the filter is relative to the enclosing HTML file. This can cause some confusion.

On a related note… you should always ensure your alpha transparent PNGs are 32-bit to ensure that they always display the same colour across all browsers (specifically Firefox and IE displayed a 24-bit alpha transparent PNG differently using the technique described here – changing it to 32-bit confirmed this was the case).