|
CDP1802 wrote: you could compile different versions with different references and conditional compilation
Yeah, that way madness lies.
|
|
|
|
|
Sometimes you don't get much of a choice. I can remember that the different versions of XNA were not very compatible. At least I managed to keep the version specific things in a baseclass with graphics functions. Containment is everything, or encapsulation in this case.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
You could keep concrete typename for particular installation in a config file (settings table or whatever) and instatiate via Activator class.
Then it is only matter of keeping straight who uses what and adjusting the config.
|
|
|
|
|
Just found this gem hiding in a project I've just inherited. Fortunately it doesn't appear to be used.
public class AlphabetPositionMap
{
private static Dictionary<char, int> alphabet = new Dictionary<char, int>();
static AlphabetPositionMap()
{
alphabet.Add('A', 1);
alphabet.Add('B', 2);
alphabet.Add('C', 3);
alphabet.Add('D', 4);
alphabet.Add('E', 5);
alphabet.Add('F', 6);
alphabet.Add('G', 7);
alphabet.Add('H', 8);
alphabet.Add('I', 9);
alphabet.Add('J', 10);
alphabet.Add('K', 11);
alphabet.Add('L', 12);
alphabet.Add('M', 13);
alphabet.Add('N', 14);
alphabet.Add('O', 15);
alphabet.Add('P', 16);
alphabet.Add('Q', 17);
alphabet.Add('R', 18);
alphabet.Add('S', 19);
alphabet.Add('T', 20);
alphabet.Add('U', 21);
alphabet.Add('V', 22);
alphabet.Add('W', 23);
alphabet.Add('X', 24);
alphabet.Add('Y', 25);
alphabet.Add('Z', 26);
}
public static int Position(char letter)
{
return alphabet[letter];
}
}
Prizes awarded to anyone who can find a more pointless use of a lookup table.
|
|
|
|
|
Depending on what is done with the dictionary, it might sometimes make sense. I have already been confronted with such things in the past, where such a silly-looking lookup table was the best way to fit a general syntax implementation for an automatic language parser.
Otherwise, inline a return (letter-64) ...
|
|
|
|
|
how about :
public class NumberMap
{
private static Dictionary<char, int> number = new Dictionary<char, int>();
static NumberMap()
{
number.Add('1', 1);
number.Add('2', 2);
number.Add('3', 3);
number.Add('4', 4);
number.Add('5', 5);
number.Add('6', 6);
number.Add('7', 7);
number.Add('8', 8);
number.Add('9', 9);
number.Add('0', 0);
}
}
modified 17-Apr-15 6:46am.
|
|
|
|
|
Well done. You get all the bonus points.
|
|
|
|
|
Even more bonus points for a pointless lookup table for not being able to actually do a lookup
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
It's all in the wrist baby
|
|
|
|
|
I've noticed that you do not cover lowercase numbers.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
There is a seperate uppercase number lookup table for that !
|
|
|
|
|
I was thinking more of something like "1".tolower might work.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
So, the location of "a" is at "IndexOutOfRangeException"?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
yes, we need to add 'a' to 'z' in as well. I'll assign it out to one of my team to fix immediately.
|
|
|
|
|
Rotted Frog wrote: Prizes awarded to anyone who can find a more pointless use of a lookup table.
Does this count?
Converting dates to the Roman equivalent[^]
The database is no longer available (thankfully, it was 75MB!) and sadly, nobody got the joke...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
That was written just before you stopped drinking? Yes?
veni bibi saltavi
|
|
|
|
|
It was written as a follow up to Converting numbers to the word equivalent. [^] since we were getting a lot of "Roman numbers" homework in QA back then.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
So you'd moved off the booze by then; onto the class 'A' drugs.
veni bibi saltavi
|
|
|
|
|
Class A++ I suspect...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Doing crack, heroin and meths is a stage people go through. Just don't do VB!
veni bibi saltavi
|
|
|
|
|
That did have a point. It was actually quite a funny point.
|
|
|
|
|
And it gets better... Just noticed the next class on from that one:
public class ZeroBasedAlphabetPositionMap
{
private static Dictionary<char, int> alphabet = new Dictionary<char, int>();
static ZeroBasedAlphabetPositionMap()
{
alphabet.Add('A', 0);
alphabet.Add('B', 1);
alphabet.Add('C', 2);
alphabet.Add('D', 3);
alphabet.Add('E', 4);
alphabet.Add('F', 5);
alphabet.Add('G', 6);
alphabet.Add('H', 7);
alphabet.Add('I', 8);
alphabet.Add('J', 9);
alphabet.Add('K', 10);
alphabet.Add('L', 11);
alphabet.Add('M', 12);
alphabet.Add('N', 13);
alphabet.Add('O', 14);
alphabet.Add('P', 15);
alphabet.Add('Q', 16);
alphabet.Add('R', 17);
alphabet.Add('S', 18);
alphabet.Add('T', 19);
alphabet.Add('U', 20);
alphabet.Add('V', 21);
alphabet.Add('W', 22);
alphabet.Add('X', 23);
alphabet.Add('Y', 24);
alphabet.Add('Z', 25);
}
public static int Position(char letter)
{
return alphabet[letter];
}
}
|
|
|
|
|
You should not pay developers by LOC
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Nice find and thanks for sharing! I feel better now!
"Go forth into the source" - Neal Morse
|
|
|
|
|
How about adding another lookup that gets the uppercase equivalent of a lowercase letter?
|
|
|
|
|