7/26/2005 08:37:00 PM|W|P|Jay Flowers|W|P|

I picked this up from Peli today.

Le trop est l'ennemi du bien

or

Too much is the enemy of enough

 

I love it!

 

|W|P|112242826076716820|W|P|A Wonderful Quote|W|P|7/26/2005 08:30:00 PM|W|P|Jay Flowers|W|P|Brian Marick has an interesting write up on the reasons to use Fit.  It looks like this was brought on by the release of the new fit book: Fit for Developing Software.  This tool one of the best ways to cause a natural move to agile in a project.|W|P|112242781178131261|W|P|Fit Book|W|P|7/26/2005 08:11:00 PM|W|P|Jay Flowers|W|P|I have noticed that most of the people and organizations that preach the virtues of Continuous Integration (CI) also preach the virtues of a good ticket system (Jira is a good example).  What I find interesting is that no one, to my knowledge, has integrated a ticket system with CI.  If you have a ticket system that records all your requirements as well as your bugs doesn’t that describe all the work to be done to your code?  Lets say it does. Could the CI server integrate with the ticket system similarly to the source control system?  Well of course it could, but what does that buy you?  So lets say that a developer must submit a ticket and code to the build.  There would be an association between the code submited to the source control repo and the ticket used to task the developer.  This association would be used to aquire information on this ticket in the build script and include it in the build log/report.  Besides displaying what ticket was completed with that build the build script can update information in the ticket.  It could change the assignee, add a note, change the status, or any number of things.  At my work we have the build script move the ticket(s), in PVCS Tracker, to the test team and add a note with information on what build the ticket was sucessfully built in.  On the MbUnit project we are in the process of integrating Jira in the same fashion.  It seems to me that the ablility of a build script to associate a ticket with a change and manipulate that ticket is a very powerful thing.  I find it interesting that I can not find this is kind of thing going on else where.|W|P|112242669939324534|W|P|Ticket Systems and CI|W|P|7/19/2005 07:34:00 PM|W|P|Jay Flowers|W|P|

I have been trying to push for FitNesse to be adopted one of the projects I am helping. We have an aggressive schedule that does not allow for the time that the Test team is asking for. I have suggested FitNesse as means to reduce the total time to complete the same if not more testing. In an effort to help the developers on this project who will use FitNesse and in trying to show an example to the Test lead I have created a test fixture that should be able to test any data structure. [[Breathe]] You can test a data structure in one or more table. I sugggest at least two: one for specifying the data structe and housing assembly, the second for testing the data structure.

Posted by Picasa

The AsseblyLocation and the type of the class to be tested, SubjectType, are specified. The next table will use the class specified in the previous table (i.e. SimpleDataStructure will be tested). This table shows test procedures for testing SimpleDataStructure

The Name column specifies the name of the property in the SimpleDataStructure that wil be tested on this row. The ValueType column specifies the type of the value that will passed to the property. The SetValue column specifies the value to be passed to the property. The ExceptionThrown column specifies to expect an Exception. Notice the question mark. The GetValue column specifies the value that should be in the property. The ExceptionType column specifies the type of Exception thrown, if none enter null. I have included the code for the fixture TestSimpleDataStructure. You can use it as is to test any data structure, well almost. The method CastBoxedValue should be beefed up a bit. It can only handle string and integer right now (if someone knows a better way than a select case statement tell me how). Enjoy :)

Imports fit

Imports System.Reflection

 

Public Class TestSimpleDataStructure

    Inherits ColumnFixture

 

    Private _AssemblyLocation As String

    Private _SubjectType As String

 

    Private _Name As String

    Private _ValueType As String = "string"

    Private _SetValue As String

    Private _ExceptionThrown As Boolean = False

    Private _ExceptionType As String

 

    Public Property AssemblyLocation() As String

        Get

            Return _AssemblyLocation

        End Get

        Set(ByVal Value As String)

            _AssemblyLocation = Value

            If Not Me.SubjectType Is Nothing Then

                Me.CreateSubject()

            End If

        End Set

    End Property

 

    Public Property SubjectType() As String

        Get

            Return _SubjectType

        End Get

        Set(ByVal Value As String)

            _SubjectType = Value

            If Not Me.AssemblyLocation Is Nothing Then

                Me.CreateSubject()

            End If

        End Set

    End Property

 

    Private Sub CreateSubject()

        AddHandler AppDomain.CurrentDomain.AssemblyResolve, New ResolveEventHandler(AddressOf Me.assemblyResolve)

        Me.Subject = Activator.CreateInstanceFrom(Me.AssemblyLocation, Me.SubjectType).Unwrap

        RemoveHandler AppDomain.CurrentDomain.AssemblyResolve, New ResolveEventHandler(AddressOf Me.assemblyResolve)

    End Sub

 

    Private Property Subject() As Object

        Get

            Return Me.Recall(Me.GetType.Name)

        End Get

        Set(ByVal Value As Object)

            Me.Save(Me.GetType.Name, Value)

        End Set

    End Property

 

    Public Property ValueType() As String

        Get

            Return _ValueType

        End Get

        Set(ByVal Value As String)

            _ValueType = Value

        End Set

    End Property

 

    Public Property Name() As String

        Get

            Return _Name

        End Get

        Set(ByVal Value As String)

            _Name = Value

        End Set

    End Property

 

    Public Property SetValue() As String

        Get

            Return _SetValue

        End Get

        Set(ByVal Value As String)

            _SetValue = Value

            Try

                Dim params As Object() = New Object(0) {Me.CastBoxedValue(Value, Me.ValueType)}

                Me.Subject.GetType.GetProperty(Me.Name).GetSetMethod.Invoke(Me.Subject, params)

            Catch ex As Exception

                Me.ExceptionThrown = True

                Me.ExceptionType = ex.GetType.Name

            End Try

        End Set

    End Property

 

    Public Property ExceptionThrown() As Boolean

        Get

            Return _ExceptionThrown

        End Get

        Set(ByVal Value As Boolean)

            _ExceptionThrown = Value

        End Set

    End Property

 

    Public ReadOnly Property GetValue() As String

        Get

            Return Me.Subject.GetType.GetProperty(Me.Name).GetGetMethod.Invoke(Me.Subject, Nothing).ToString

        End Get

    End Property

 

    Public Property ExceptionType() As String

        Get

            Return _ExceptionType

        End Get

        Set(ByVal Value As String)

            _ExceptionType = Value

        End Set

    End Property

 

    Public Overrides Sub Reset()

        With Me

            ._ExceptionThrown = False

            ._ExceptionType = Nothing

            ._Name = Nothing

            ._SetValue = Nothing

            ._ValueType = "string"

            ._AssemblyLocation = Nothing

            ._SubjectType = Nothing

        End With

    End Sub

 

    Private Function CastBoxedValue(ByVal StringValue As String, ByVal NewType As String) As Object

        Select Case True

            Case NewType.ToLower = "integer"

                Return Integer.Parse(StringValue)

            Case NewType.ToLower = "string"

                Return StringValue

        End Select

    End Function

 

    Private Function assemblyResolve(ByVal sender As Object, ByVal args As ResolveEventArgs) As [Assembly]

        Dim chArray1 As Char() = New Char() {","c}

        Dim text1 As String = args.Name.Split(chArray1)(0)

        Dim text3 As String

        For Each text3 In IO.Path.GetDirectoryName(Me.AssemblyLocation)

            Dim text4 As String = IO.Path.Combine(text3, String.Format("{0}.dll", text1))

            If IO.File.Exists(text4) Then

                Return [Assembly].LoadFrom(text4)

            End If

            text4 = IO.Path.Combine(text3, String.Format("{0}.exe", text1))

            If IO.File.Exists(text4) Then

                Return [Assembly].LoadFrom(text4)

            End If

        Next

        Return Nothing

    End Function

 

End Class

|W|P|112182100366212840|W|P|A Push for FitNesse|W|P|7/19/2005 07:20:00 PM|W|P|Jay Flowers|W|P|I am trying to start a reuse process at my work. I recognize there are different level of reuse.
  • Copy and Paste
  • Class
  • Library
  • Project
  • Pattern
  • Design
  • Architecture
The tool Koders seems to help a good deal with the first four. The last five seem to need a formal process to achieve. At the moment a board of 4 to 8 people meeting once a month to review submissions to the reuse repo seems to be the answer. If that is the course of action I need: A web site to publish the reusable artifacts to. Criteria to judge a submission by. Requirements a submission must meet. And all the things I have not thought of yet. :)|W|P|112181962641986941|W|P|Reuse|W|P|7/19/2005 07:16:00 PM|W|P|Jay Flowers|W|P|I have published my first professional article.

Unit Testing in .NET Projects by Jay Flowers and Andrew Stopford -- Now is a pretty exciting time for unit testing in .NET. Tremendous progress is being made on several fronts: IDE integration, process integration, and new test fixtures. Jay Flowers and Andrew Stopford explain how to use Visual Studio's new integrated unit testing, as well as the NUnit and MbUnit testing frameworks.

|W|P|112181878710669218|W|P|First Article|W|P|7/02/2005 08:44:00 AM|W|P|Jay Flowers|W|P|

There are many occasions where a Hashtable just doesn’t cut it.  You need an object to hold pairs of objects.  You need to be able to retrieve either of the members of the pair with the other member of the pair.  HashTable just won’t cut it.  You can access one member of the pair, the value, with the other member of the pair, the key.  You may not access the key with the value.  Many times that is exactly what I need.  So I got tiered of iterating through the keys looking for the one I needed.  I made a new class implementing the IDictionary interface called Map, as well as creating the class MapBase.  The following example with use MapBase to illustrate.

Lets say that we have a list of Names and IDs.  We would like to be able to use either the name of the id to retrieve the other.

public class NameIdMap : MapBase

{

    public int this[string Name]

    {

        get

        {

            return (int) this.MappedTable[Name];

        }

        set

        {

            this.MappedTable[Name] = value;

        }

    }

 

    public string this[int ID]

    {

        get

        {

            return (string) this.MappedTable[ID];

        }

        set

        {

            this.MappedTable[ID] = value;

        }

    }

 

    public void Add(string Name, int ID)

    {

        this.MappedTable.Add(Name, ID);

    }

 

    public bool Contains(string Name)

    {

        return this.MappedTable.Contains(Name);

    }

 

    public bool Contains(int ID)

    {

        return this.MappedTable.Contains(ID);

    }

 

    public void Remove(string Name)

    {

        this.MappedTable.Remove(Name);

    }

 

    public void Remove(int ID)

    {

        this.MappedTable.Remove(ID);

    }

}

The class NameIdMap will allow this.  50 braindead lines of code and you have type safe access to your map.  If didn’t want type safe access you could have used a Map.

public class JustUseAMap

{

    public void Example()

    {

        Map NamesAndIDs = new Map();

 

        NamesAndIDs.Add("Jay", 1);

        NamesAndIDs.Add("Andy", 2);

 

        if (!NamesAndIDs.Contains("Jay"))

            throw new Exception();

 

        Console.WriteLine("Jay's id is {0}", NamesAndIDs["Jay"]);

    }

}

If this is something that could improve your day it’s part of the ASOGS project.

|W|P|112031187648843619|W|P|Equal Access HashTable or a Map|W|P|7/19/2005 11:03:00 AM|W|P|Anonymous RossM|W|P|Nice, but I'm not sure I like your name (may I suggest Bijection?).

In C++/STL world, a map has pretty much the same functionality as a hashtable, but with a 'hidden' (often RB-tree) implementation. Also, mathematically, a 'map' implies something else.