Skip navigation.

Tweak to CalculateFixture

Tweak to CalculateFixture

I've become fond of FitLibrary's CalculateFixture. The second table below is an example:

create clinic with 7 stalls
which are sand stalls? 4, 6
which are bull stalls? 1

...

When there's no room for an animal in a normal stall, put it in a sand stall, or in a bull stall as last resort.

how stalls are assigned
special stall? stalls in use stall assigned
no 2, 3, 5, 7 4
no 2, 3, 4, 5, 6, 7 1

The columns to the left of the blank column are inputvalues. Those to the right are expected results. The blankcolumn is a nice visual separator.

Each line of a tableshould be easy to understand. Sometimes that meansannotation. I've hacked my copy of CalculateFixture to allow notesafter yet another blank column. Like this:

create clinic with 7 stalls
which are sand stalls? 4, 6
which are bull stalls? 1

...

When there's no room for an animal in a normal stall, put it in a sand stall, or in a bull stall as last resort.

how stalls are assigned
special stall? stalls in use stall assigned notes
no 2, 3, 5, 7 4 Only sand stalls are free, so use one.
no 2, 3, 4, 5, 6, 7 1 No place to go but bull stall

That's easily done in the 9Feb2005 version. In bind:

for (int i = 0; heads != null; i++, heads = heads.more) {    String name = heads.text();    try {	if (name.equals("")) {+           if (pastDoubleColumn) break;//          if (argCount > -1)//              throw new FitFailureException("Two empty columns");            argCount = i;            targets = new MethodTarget[rowLength-i-1];      

And remove an error check in doRow:

if (row.parts.size() != argCount+methods+1) {    exception(row.parts,"Row should be "+(argCount+methods+1)+" cells wide");    return;}      

I'd like to see this change become part of FitLibrary. It cannot break existing tables (because of the error check). The error check would no longer catch mistakes in the table, but I can't see such a mistake lasting past the first time someone tried to make the test pass. It would be easy enough to change the error check to take blank columns into account, but I doubt I'd bother.