|
I once wrote some code that checked for a condition that was impossible (just to be funny) and added an error message that went something like this:
"It seems that an impossible condition has been perceived to have occurred while processing your data. If you are receiving this error, then please do nothing, as you you obviously do not exist. Authorities have been notified of your non-conformity."
So far, I'm not aware that anyone else has seen it...
|
|
|
|
|
few functional language compiler (i know) have this ability to track the side effects and wont compile unless there is a fall back handler.
|
|
|
|
|
Programmer sure seems to heve a high opinion of themselves. After all, it's not like they disabled that execute button until the user had loaded an XSD and selected at least one file. And to top it off, they tried to cover up their shortcomings by insulting the user. Stupid programmer.
Programmer: -1
User: 0
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
A good point. Such easily pre-checkable conditions can be coded around, in a UI at least, so that the user can't make that stupid mistake.
|
|
|
|
|
Be careful with assumptions about what the user can and cannot do through the UI, especially if you work on the web.
The QA team at my company has specific instructions to enable all disabled buttons and controls using various means (on the web, it's pretty easy: Inspect Element. For Windows applications, a special app is needed). The main reason is to secure the app against users being malicious rather than stupid, though.
|
|
|
|
|
If the user bypasses having things disabled or manually submits invalid data, then a terse error message is fair enough. That's not normal usage, that's abuse, and the code should protect itself against such things. The example in the OP appears to be for something that can happen in normal usage when it shouldn't be able to, though.
|
|
|
|
|
Yes you can do that, but it will result in the 'stupid user' complaining about the execute button not being active. At least the way it's handled here offers the opportunity to explain why this won't work, and what is expected. Granted, it could be expressed ... differently
|
|
|
|
|
I just use a message box that says "Too late for sorry, earthling!" It should NEVER be seen by anyone but me, and so far <crossing wings> I have yet to hear about it
|
|
|
|
|
emajyn wrote: I have yet to hear about it
Perhaps because such a message screams to the user that you don't want to hear about it if it ever does happen.
At least add a unique guru meditation number or something to the message. That'll turn it into a whimisical way to deliver an obscure error. Might someday keep your management from loosing face to some customer with clout who happens to get that message.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
Yes, I too once coded an error message under a condition that at that point I assumed was a foregone conclusion. It said sth along the lines of. "you should never see this error message. If you do, please contact <my name>"
Of course, that impossible condition did hit eventually, and I got a call from our customer.. Thankfully the software was still under testing at that point so it wasn't some clueless user, but a rather exhilarated tester...
|
|
|
|
|
precisely <chuckle> - but people who use software that6 still contains that as an error message know me well enough that calling me is the first thing they would do anyway
|
|
|
|
|
Agreed. Keep thinking your user is "stupid" and pretty soon you won't have any.
/ravi
|
|
|
|
|
What's the name of the validator app?
|
|
|
|
|
I called it "Rude XSD validator".
It was something I threw together in a hurry. The software we develop is serviced/administered by another company. We had a situation in which we needed to know if XML files provided by a third party were in accordance to a given XSD. The administrators were unable to figure it out and asked me to provide them with a tool...
So I quickly threw together a WinForms GUI in which one can load one XSD, easily choose one or more files, and validate them all.
In other words, a few people I knew a little and collaborated with would be my users. We have an informal tone, and nobody complained of anything.
|
|
|
|
|
public void WriteCode(ICodeContext ctx, ICodeFile file)
{
Programmer.BeMeanToUsersAsTheyAreStoopid(ctx, file, MeanLevel.Medium);
}
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image.
Stephen Hawking
|
|
|
|
|
Ha Ha, Our in-house system was developed using Access 97 (Archaic) Every now and again it decides to tell me "Me.Dirty" in a debug message! (Maybe someone is trying to tell me something)
|
|
|
|
|
There is a great tool for working with images called "ImgBurn", it has more coded insults than any other application I've ever used.
It's more condescending than anything, like, hey, I've noticed you're doing it wrong, would you like me to do it right? (Yes, No)
It's also very good at it's job, and has saved me a TON of wasted disc, I highly recommend it.
|
|
|
|
|
I looked those up on Google, and found that those are quotes from movies. They can be turned off in the options dialog. I never noticed them before, and I use ImgBurn quite a bit.
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
We can strip leading and trailing spaces from a string….
int len = strlen((LPSTR)wName);
while( *((LPSTR)wName + len - 1) == ' ')
{
*((LPSTR)wName + len - 1) = '\0';
len = strlen((LPSTR)wName);
}
firstNonSpace=((LPSTR)wName);
while(*firstNonSpace != '\0' && isspace(*firstNonSpace))
{
++firstNonSpace;
}
len = strlen(firstNonSpace)+1;
strcpy((LPSTR)wName, firstNonSpace);
Or just call…
MSDN: “Removes all leading and trailing spaces from a string.”
PathRemoveBlanks(wName);
I need a 32 bit unsigned value just to hold the number of coding WTF I see in a day …
modified 28-Sep-12 10:08am.
|
|
|
|
|
You should probably add your context, as PathRemoveBlanks is a shell utility function, while most people here use dotnet where String.Trim would suffice.
|
|
|
|
|
I'm no good at Big O notation, but that's some kind of amortized N⁵, isn't it?
|
|
|
|
|
1. This code was COPIED to 3 different places - they didn't bother to make a function out of all of it. That is probably the worst error, because now if this 'new' code has bugs, you have to modify three places instead of one.
2. It 'excessively' calculates the length of the string. I think I am being kind here when I say that.
3. 'Familiarity' was my joke - there is already a function in Windows to do this.
I need a 32 bit unsigned value just to hold the number of coding WTF I see in a day …
|
|
|
|
|
Blake Miller wrote: if this 'new' code has bugs, you have to modify three places instead of one.
Or you can create a function with this code and replace the code in the other 3 (and modify just one).
|
|
|
|
|
Blake Miller wrote: 2. It 'excessively' calculates the length of the string.
And just as excessively casts wName to LPSTR.
|
|
|
|
|
Not sure if you are joking, or looking for a serious answer.
The code you posted makes WAY too many passes through the source string. If you're looking for maximum performance, you can get this down to just a single pass thusly:
LPSTR* nxt = wName;
while(*nxt && isspace(*nxt))
nxt++;
if (!*np) {
wName = '\0';
return wName;
}
LPSTR* start = nxt;
LPSTR* last_no_ws = nxt;
while(*nxt) {
if (!isspace(*nxt))
last_no_ws = nxt;
nxt++;
}
int len = (last_no_ws - start) + 1;
memmove(wName, start, len);
wName[len] = '\0';
return wName;
You could even save the 'memove' at the end by just modifying the wName string in place (add null after last_no_ws), then return the reference to 'start'.
|
|
|
|