|
I had Narnians on my mind.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I have been using the VMWare VIM API for a while now. The main class I have used is VMware.Vim.VimClient . Now I'm trying to use a newer version of the API. Guess what they did?
They renamed VMware.Vim.VimClient to VMware.Vim.VimClientImpl and made a freakin' Interface named VMware.Vim.VimClient !!!!!
I'd call that mofo breaking change. How am I supposed to write code that can use either version of the API without resorting to Reflection?
Tequila, take me away...
modified 22-Apr-15 23:27pm.
|
|
|
|
|
but isn't VMware.Vim.VimClientImpl a VMware.Vim.VimClient ?
So you can use the later and it will work for both?!
|
|
|
|
|
Yes, but how do I know which to instantiate?
|
|
|
|
|
Use the factory pattern to wrap up the details of instantiation.
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.
|
|
|
|
|
Wouldn't that still require using Reflection to determine which version of the API is installed on the system at runtime?
(Not that it matters; I'm not writing it to be flexible.)
|
|
|
|
|
You might have to use reflection. If you want to avoid that, you could compile different versions with different references and conditional compilation. This could get ugly if you can't limit the setups to only two versions or contain all conditional code in the class factory.
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.
|
|
|
|
|
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
|
|
|
|