Tuples Part 8: Finishing up

There are only a few missing features from our tuple implementation.  Mainly FxCop compliance, debugging support and test case code.  The actual functional work is complete.  The one issue with FxCop compliance is the chosen names.  Namely using A,B etc.  FxCop, rightly, believes names should have more value.  Accordingly, calling the generic argument corresponding to…

2

Tuples Part 7: Mutable Tuples

Part 6 left us with comparable tuples.  At this point, the Tuple class is functionally complete.  There will be a little more done with the debugability and overall fit into larger projects.  But otherwise it is sound.  Now the focus shifts to generating mutable tuples.  Immutability is nice for threading, memoization, etc …  However it’s…

1

Tuples Part 6: Comparing

Part 5 produced equality tests for Tuples.  This section will add comparison support through the IComparable<T> interface.  Implementing comparable is very similar to adding equality support.  Once again there is a generic class available to make all of the comparison decisions for us; Comparer<T>.  The implementation will compare objects in a left to right fashion. …

3

Tuples Part 5: Equality

Part 4 left us with a reusable, abstract and inference friendly Tuple class.  The next step is to be able to test for Tuple equality.  For the Tuple implementation, two tuples will be defined as equal if all of their members are equal.  Seems fairly straight forward.  The trick is in the implementation.  In addition…

2

Tuples Part 4: Interface

Now we have a decent tuple generation script which produces a very usable set of tuple classes.  After awhile I ended up getting stuck because the tuples are not flexible enough.  It’s not possible to use a 2 pair tuple where a 1 pair is expected even though it meets the requirements.  Process(Tuple.Create(“foo”)); Process(Tuple.Create(“foo”, 42));…

1

Tuples Part 3: Type Inference Friendly Constructor

Last time we were left with a constructor that required us to explicitly specify generic parameters.  This is not always easy or possible.  We’ll now alter the script to generate a constructor which utilizes type inference to create a Tuple.  In addition, all tuples will use the same overloaded method making the creation uniform.  The…

1

Tuples Part 2: Basic Structure

Part 1 of the series outlined the basic structure of the tuple.  This entry will produce a PowerShell script that will generate N tuple classes containing 1-N name value pairs.  The first step is to get a few script variables defined.  All of the names used in the tuples will be lower and upper case…

3

Tuples Part 1

A tuple in computer science can be described as a set of name/value pairs.  In some cases it can be described as simply a set of values that are accessible via an index [1].  Previously I discussed how to create a Tuple inside of PowerShell.  This series will focus on the use of Tuples in…

6