I don't always test ...

 

That pretty much sums up the current Obamacare debacle. As a programmer for a mission-critical web-based EHR, and one in charge of deploying updates to production, I feel a bit of sympathy for the actual programmers who worked on this monstrosity. And monstrosity is the perfect description. At 500 *million* lines of code, there is no possible way this could have been released without problems. 500 *million* lines of code says that this was not only poorly built but that it was poorly designed, poorly managed, and poorly tested. It's just not possible. Yet it happened anyway.

However, in this case, the sheer ineptitude on display is astounding. This would certainly be one contract job I'd omit from my resume if I were one of the programmers!

What a perfect metaphor for our government in general.

 

 

Borepatch sums up the issues with the "surge" very well. Highly recommend reading this post and his blog in general

Tie Me BASIC Down, Sport

Roberta X posted a snippet of BASIC code that implemented part of Rolf Harris's "Tie Me Kangaroo Down, Sport" routine:
10 TIE ME KANGAROO DOWN
20 MATE
30 GOTO 10
40 END
The comments are absolutely worth reading and resulted in a few design modifications - highly recommended! And, if you want to see Rolf perform the song, here's a very entertaining version:



And, from the comments, come the lyrics (though the lyrics have several verses not in the above video):
SPOKEN: There's an old Australian stockman lying, dying. He gets himself up
onto one elbow and 'e turns to his mates, who are all gathered around and 'e says:

Watch me wallabies feed, mate
Watch me wallabies feed,
They're a dangerous breed, mate
So watch me wallabies feed
Altogether now!

CHORUS:
Tie me kangaroo down, sport
Tie me kangaroo down
Tie me kangaroo down, sport
Tie me kangaroo down

Keep me cockatoo cool, Curl,
Keep me cockatoo cool
Ah, don't go acting the fool, Curl
Just keep me cockatoo cool
Altogether now!

(CHORUS)

'n' take me koala back, Jack
Take me koala back
He lives somewhere out on the track, Mac
So take me koala back
Altogether now!

(CHORUS)

Let me abos go loose, Lew
Let me abos go loose
They're of no further use, Lew
So let me abos go loose
Altogether now!

(CHORUS)

And mind me platypus duck, Bill
Mind me platypus duck
Ah, don't let 'im go running amok, Bill
Just mind me platypus duck
Altogether now!

(CHORUS)

Play your didgeridoo, Blue
Play your didgeridoo
Ah, like, keep playin' 'til I shoot thru, Blue
Play your didgeridoo
Altogether now!

(CHORUS)

Tan me hide when I'm dead, Fred
Tan me hide when I'm dead
So we tanned his hide when he died, Clyde
And that's it hangin' on the shed!!
Altogether now!

ROLF HARRIS, 1963

per bRUCE
crankyoldmanwithgun@yahoo.com

Sums It Up



Yep - that about sums up my weekend and the foreseeable future! Work is kicking my ass but at least it's still paying the bills too!

Duff's Beer?

#### SOLUTION ####

Ended up doing this which is a less efficient but more readable version of David's code. As a result, I have memoralized him in the actual software. Actual code below:

//This portion, while functional, earned a "meh" from David N. in #GBC due to possibly unneeded IF checks
newCRTDetail.MaximumCopayTier = (data.Length > 17) ? Formatting.ToNullableInt(data[17]) : null;
newCRTDetail.CopayTier = (data.Length > 16) ? Formatting.ToNullableInt(data[16]) : null;
newCRTDetail.DaysSupplyPerCopay = (data.Length > 15) ? Formatting.ToNullableInt(data[15]) : null;
newCRTDetail.MaximumCopay = (data.Length > 14) ? Formatting.ToNullableDouble(data[14]) : null;
newCRTDetail.MinimumCopay = (data.Length > 13) ? Formatting.ToNullableDouble(data[13]) : null;
newCRTDetail.FirstCopayTerm = (data.Length > 12) ? data[12] : String.Empty;
newCRTDetail.PercentCopayRate = (data.Length > 11) ? Formatting.ToNullableDouble(data[11]) : null;
newCRTDetail.FlatCopayAmount = (data.Length > 10) ? Formatting.ToNullableDouble(data[10]) : null;

#### ORIGINAL POST ####

So - I have an issue and I'm stumped. I hate using GOTO statements and can't believe C# actually requires them sometimes.

Problem: I have a string array named data. It can have up to 18 elements [0] - [17] and the elements 0 - 9 will always be there. Each element, if it exists, gets assigned to a different property. This is one way to do it:

newCRTDetail.PropA = data[2];
newCRTDetail.PropB = data[3];
newCRTDetail.PropC = data[5];
newCRTDetail.PropD = data[6];
newCRTDetail.PropE = data[7];
newCRTDetail.PropF = data[8];
newCRTDetail.PropG = data[9];

switch (data.Length) //not all values are required and optional values at the end may be omitted
{
  case 17:
    newCRTDetail.PropO = Formatting.ToNullableInt(data[17]);
    goto case 16;
  case 16:
    newCRTDetail.PropN = Formatting.ToNullableInt(data[16]);
    goto case 15;
  case 15:
    newCRTDetail.PropM = Formatting.ToNullableInt(data[15]);
    goto case 14;
  case 14:
    newCRTDetail.PropL = Formatting.ToNullableDouble(data[14]);
    goto case 13;
  case 13:
    newCRTDetail.PropK = Formatting.ToNullableDouble(data[13]);
    goto case 12;
  case 12:
    newCRTDetail.PropJ = data[12];
    goto case 11;
  case 11:
    newCRTDetail.PropI = Formatting.ToNullableDouble(data[11]);
    goto case 10;
  case 10:
    newCRTDetail.PropH = Formatting.ToNullableDouble(data[10]);
    break;
}

 

Another way would be:

if (data.length == 17)
    newCRTDetail.PropO = Formatting.ToNullableInt(data[17]);

if (data.length >= 16)
    newCRTDetail.PropN = Formatting.ToNullableInt(data[16]);

...

if (data.length >= 10)
    newCRTDetail.PropH = Formatting.ToNullableDouble(data[10]);

 

Now, I may just be having a brain fart here, but is there a better way than either of those? A switch statement that allowed fall-through would be much shorter and easier to read (IMHO).

 

Update - another option:

if (data.length >= 10){
    newCRTDetail.PropH = Formatting.ToNullableDouble(data[10]);
    if (data.length >= 11){
        newCRTDetail.PropI = Formatting.ToNullableDouble(data[11]);
        if (data.length >= 12){
            newCRTDetail.PropJ = data[12];
        }
    }
}



Update 2 - Thanks David for helping me get past a brain fart.

Update 3 - possibly even better (a bit more overhead since every 'if' is checked but definitely easier to read)

newCRTDetail.MaximumCopayTier = (data.Length > 17) ? Formatting.ToNullableInt(data[17]) : null;
newCRTDetail.CopayTier = (data.Length > 16) ? Formatting.ToNullableInt(data[16]) : null;
newCRTDetail.DaysSupplyPerCopay = (data.Length > 15) ? Formatting.ToNullableInt(data[15]) : null;
newCRTDetail.MaximumCopay = (data.Length > 14) ? Formatting.ToNullableDouble(data[14]) : null;
newCRTDetail.MinimumCopay = (data.Length > 13) ? Formatting.ToNullableDouble(data[13]) : null;
newCRTDetail.FirstCopayTerm = (data.Length > 12) ? data[12] : String.Empty;
newCRTDetail.PercentCopayRate = (data.Length > 11) ? Formatting.ToNullableDouble(data[11]) : null;
newCRTDetail.FlatCopayAmount = (data.Length > 10) ? Formatting.ToNullableDouble(data[10]) : null;