|
From my point of view string.Empty conveys the intention that the string is not to be null and have no characters.
Seeing a magic value like "", and let's face it - it IS a magic value albeit a simple one, always makes me question the code: "Is that supposed to be like that, or was there some value forgotten in debugging?"
I have yet to encounter having to use an empty string as a case in a switch, but now that I know I will try to avoid that, or use a const value.
|
|
|
|
|
sibling123 wrote: From my point of view string.Empty conveys the intention that the string is not to be null and have no characters. So do two quotes.
sibling123 wrote: Seeing a magic value like "", Two quotes are no magic value, but a global constant expression.
sibling123 wrote: I will try to avoid that, or use a const value. Duh. SA1122 is simply nonsense.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
but I just devised a cunning C macro. I may not be the first to devise this, but I'm likely the only one this decade.
Many-a-day in years past I bemoaned that the argv array includes the name of the running executable and the resultant off-by-one confusion it caused me.
So I was over-joyed to see that C# does away with that nonsense.
Then today I was dabbling in some minor C code and so my depression returned.
It occurred to me that all I wanted was something like the SHIFT command (DOS), so after a few minutes' thought, I wrote:
# define SHIFT (++argv,--argc)
I wrote it that way so it can be used in either of the following ways:
SHIFT ;
if ( argc > 0 ) { ... }
while ( SHIFT > 0 ) { ... }
switch ( SHIFT )
{
case 0 : { ... ; break ; }
case 1 : { ... ; break ; }
case 2 : { ... ; break ; }
...
default : { ... ; break ; }
}
|
|
|
|
|
I don't use C (or C++) much, though.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
|
Is this for some place where you can't use getopt? (like not supported by the compiler, or want to keep the binary size small?)
|
|
|
|
|
No, but I expect it can be used with it if you want, but that looks dreadful.
|
|
|
|
|
That was exactly my thought when I looked at getopt, but its somehow become the established standard for command-line processing on Unix-like systems.
But then, that's elegant compared to the dog's do-do that is autoconf and the m4 macro-processor.
Shudders.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Just found this:
private void App_Exit(object sender, ExitEventArgs e)
{
ConnectionManager.IConnectionManager.Shutdown()
Stopwatch sw = new Stopwatch();
sw.Start();
while (sw.Elapsed < TimeSpan.FromMilliseconds(4000))
{
}
sw.Stop();
}
Guess the dev didn't know about
System.Threading.Thread.Sleep(4000);
If it's not broken, fix it until it is
modified 13-May-16 14:04pm.
|
|
|
|
|
But with "Sleep" you get no Attention the Task Manager ...
modified 19-Jan-21 21:04pm.
|
|
|
|
|
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Shouldn't burden of waiting for the disconnect to happen be placed on the Shutdown method? At most the caller should specify the timeout:
ConnectionManager.IConnectionManager.Shutdown(4000)
|
|
|
|
|
I found almost this exact code in the splashscreen of an app I inherited responsibility for....
"The app takes too long to start" was the complaint from the customer. In fact the splashscreen sat there burning up CPU cycles as fast as possible performing "sw.Elapsed.TotalMilliseconds < 10000". Then once the 10 seconds had elapsed it closed the splashscreen and *then* started all the application init tasks (DB connection, load config etc...)
I replaced the stopwatch with:
- a background thread to perform the app init (which normally took about 7 seconds)
- a thead.sleep to "pad" the splashscreen's lifespan up to 10 seconds
Apparently a 10-second splashscreen was desired, but cramming the app init into that 10 seconds cured the customer's "slow app" nicely.
|
|
|
|
|
I always thought the purpose of the splashscreen was to distract the user from how long the app took to get initialised. Back in the day when I did such things, my strategy was for the mainline of the app to throw out a splashscreen, do the grunt work of initialisation then kill the splashscreen.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Intent and reality intersect far too rarely.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Just come across this one, apparantly copied/pasted direct from access....
SELECT stuff
FROM somewhere
WHERE (((aa.type)='word'));
does access always just bung brackets everywhere?
|
|
|
|
|
In my experience, no... that looks more like a human construct.
Probably started out with more in the 'where' clause, had issues, paired it down... added a few brackets to segment it... but never cleaned it up.
|
|
|
|
|
oh well, it gave me a good WTF moment and a laugh...
|
|
|
|
|
|
Yes.
The queries generated by the QBE-editor are sometimes a source of great wonder (and confusion).
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes and No actually ...
... AFAIK Access versions prior to 2007 did do the crazy brackets thing.
But 2007 onwards did not.
I have a client (government department) stuck on Access 2003. Another client has Access 2007.
I noticed the difference in the brackets thing between those two versions.
Unless there is some setting somewhere I don't know about (I'm not an Access dev y'know).
|
|
|
|
|
would you admit to being an access dev?
|
|
|
|
|
I have admitted this in the past, but then I always say that it's not the tool that is used that's the problem, it is the tool that uses it.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Sure - at my age, I'm immune to peer pressure
I have been doing small contracts for various units of a State Government for about 5 years.
I charge them more than I do my regular clients. Nearly everyone employed full-time at this Dept is a lawyer or para-legal of some sort. They are cool with very high hourly rates.
And I definitely tell them "I am an Access developer". I would say I spend about 4 weeks a year being (posing as?) an Access Dev.
Officially, any custom-software they want must be built by the State Govt IT Dept (average delivery schedule: 5 - 10 years).
But they can get stuff done in Access, because according to MS, it's not "dev" software.
Often I work on Access DB's that were originally built by "actual" Access Dev's. I have seen their web-sites, and chatted by phone with one of them. So they are not "posers" like me.
The design and code of those DB's are ... interesting.
My work is easier in those cases, because I am constantly telling the users: "I can make this stuff a LOT easier for you". "No, you don't need to keep doing that, we can get Access to do it for you".
What happened, after the first job I did for a unit of this Dept, is that my users boasted about "their" Access guy around the water cooler, I got called in by another unit, etc.
Not a full time living there, but good pin-money.
I learned to program in BASIC on a Tandy TRS-80 in the late 70's while I was working as a Diesel mechanic in an iron-ore mine.
In the more than 30 years since then I have been paid to code in COBOL, RPG, Visual Basic, VB.Net, C#. And the SQL - don't forget the SQL. In all of those languages and environments SQL is the most useful tool you can have. Even in Access.
Back to the original question: When that stupid Query Builder tool in Access gives me the tom-tits, I just switch over to SQL View - suddenly everything is sweetness and light!
(once I've deleted all the brackets of course)
|
|
|
|
|
Are you sure you can exclude ((SQL Management) Studio) as the (source of (those brackets ()))))? I think the query designer there sometimes produces them too.
|
|
|
|