28 agosto 2009

My Own Code Snippet Formatter

Some weeks ago when I needed to publish code snippets here for the first time, I looked for plug-ins for Windows Live Writer and found two good alternatives, from which I decided to use the simpler one.

After that, I started to build my own code snippet formatter. Only for C# snippets, and using JavaScript, that is far from what I'm used to write.

After some weeks working on it in my spare time, it's finally usable.

It is available here.

But, if you want a true syntax highlight tool, try this one.

Enjoy!

23 agosto 2009

How to define the priority of a bug

Some time ago a tester told me we didn't have a formal criteria to define the priority of a bug, and that the few criteria he know were not easy to use. After some thoughts, we decided to work together to define a criteria that would be good for us.

The result was a compact definition for five priority levels for bug fixes:

  • Minimal: A bug is said to be of minimal priority when its occurrence:
    • Do not cause any damage to the stored data;
    • Do not interrupt the usage of the software;
    • Is hard to be observed* and does not bother the user.
  • Low: A bug is said to be of low priority when its occurrence:
    • Do not cause any damage to the stored data;
    • Do not interrupt the usage of the software;
    • Is easy to be observed but does not bother the user.
  • Normal: A bug is said to be of normal priority when its occurrence:
    • Do not cause any damage to the stored data;
    • Do not interrupt the usage of the software;
    • Is easy to be observed and bothers the user.
  • High: A bug is said to be of high priority when its occurrence:
    • Causes some damage to the stored data or interrupts the usage of the software;
    • Is hard to be observed.
  • Maximal: A bug is said to be of maximal priority when its occurrence:
    • Causes some damage to the stored data or interrupts the usage of the software;
    • Is easy to be observed.

* A bug is said to be of hard observation when it only occurs in extraordinary use cases, it means, in situations that are rarely provoked by the user.

15 agosto 2009

Parsing a Delphi DFM File

Some time ago a friend asked me to help him to parse a DFM file into .NET objects. We tried to find something in the web that does the job but no success, so I accepted the challenge and wrote the parser he needed.

If for some reason you need a DFM parser, or just for curiosity, you can download it from here.

Here is an example of how to use it:

class Program { 
    static void Main(string[] args) { 
        var fileName = @"c:\Unit1.dfm"; 
        var dfmParser = new DfmParser(fileName); 
        dfmParser.ReadFile(); 
        foreach (var node in dfmParser.Nodes) { 
            if (node.PropertyType == "string") { 
                node.PropertyValue = "'Hello World!';"; 
            } 
        } 
        dfmParser.SaveFile(); 
    } 
}

The example above loads this file:

object Form1: TForm1
  Left = 0
  Top = 0
  object Label1: TLabel
    Left = 8
    Top = 40
    Caption = 'Label1';
  end
  object Label2: TLabel
    Left = 48
    Top = 40
    Caption = 'Label1';
  end
end

And rewrites like this:

object Form1: TForm1
  Left = 0
  Top = 0
  object Label1: TLabel
    Left = 8
    Top = 40
    Caption = 'Hello World!';
  end
  object Label2: TLabel
    Left = 48
    Top = 40
    Caption = 'Hello World!';
  end
end

If you find some use for this, enjoy :)