|
err2go = " sErrDescr = ""Error "" & Err.Number & "" '"" & Err.Description & ""'"" & vbCrLf &_
"" occurred in " & fileName & " " & gErlRoutine & """ & _" & vbCrLf & _
" IIf(Erl <> 0, "" at line "" & cstr(Erl) & ""."", ""."")"
Print #fOut, err2go
This was a project that needed error handlers everywhere[1]. Using structured comments the source was preprocessed to automatically insert error handlers. Run time errors produced full stack traces with none of the bother of having to code an actual error handler manually. Sweet!
[1] Really. Trust me.
They will never have seen anything like us them there. - M. Spirito
|
|
|
|
|
switch (e.KeyCode)
{
case Keys.D1:
if (keyIsDown[Keys.D1]) return;
try
{
keyIsDown[Keys.D1] = true;
}
catch { }
break;
}
This is a question in StackOverFlow[^]
|
|
|
|
|
Meysam Tolouee wrote: This is a question in StackOverFlow[^]
Without answer
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Why are you bothering us with it?
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
The code makes perfect sense in its context. Were you looking at it through beer goggles?
"Seize the day" - Horace
"It's not what he doesn't know that scares me; it's what he knows for sure that just ain't so!" - Will Rogers, said by him about Herbert Hoover
|
|
|
|
|
I just came up with these two methods:
public static bool Implements(this Type t, Type interfaceType)
{
return t.GetInterfaces().Contains(interfaceType);
}
public static bool Implements<TInterface>(this Type t)
{
return t.Implements(typeof(TInterface));
}
They simply check if the Type t implements a specific interface.
I don't know of anything like this in the framework (I haven't checked).
What do you get when you cross a joke with a rhetorical question?
|
|
|
|
|
How about something like:
interfaceType.IsAssignableFrom ( t ) ;
(Untested, but I use IsAssignableFrom in similar cases.)
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
I was going to suggest the same.
Basically, instead of writing someType.implements(interface) you write interface.IsAssignableFrom(someType) .
For some reason, when I encountered this method the first time, I thought that an "Implements" method would make more sense, even if they are basically the same.
|
|
|
|
|
Is it normally the case that you have a Type that you need to check vs. an actual instance?
For an instance there's:
if (foo is ISomething)
|
|
|
|
|
Reflecting over the types in an assembly, for instance (i.e. a basic plugin system).
What do you get when you cross a joke with a rhetorical question?
|
|
|
|
|
I guess since they're one-liners they weren't thought necessary. I don't think they exist in the framework so if they make things clearer then yes, they count as useful
|
|
|
|
|
One of the products we are presenting at a trade show tomorrow is around 30 dashboards in swf format with the data URL baked in. (a limitation of the designer) The URLs point to one of our web servers where the logic and raw XML data files reside. I found out this morning that we will not have internet access for the presentation. No connection to the webserver, and the dashboards fail with a nice XML data error. Big Fail!
I told the designer that she was going to have to recompile each one (10 minutes each) for the show and she broke down in tears. Then I remembered a little file named hosts. Ten minutes later, and the problem was solved. Ain't loopback a wonderful thing?
"Go forth into the source" - Neal Morse
|
|
|
|
|
Good thinking, and nice of you to be kind to the designer.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
If you're always thinking outside the box, chances are you're in the wrong box.
|
|
|
|
|
|
Alive or dead?
Did you look?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Can i quote you in my skype please ?
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
It's nice when developers know more than just how to copy and paste and tweak code. It's nice when they actually know how the computer works.
Nice quick thinking.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Application startup creates a
SqlConnection for each database it uses, and opens it, and this is then passed as a parameter from one module to the next for the lifetime of the application....to save the time opening and closing the connection.
|
|
|
|
|
See, I told you already. With smart programmers like this, we don't need connection pooling.
|
|
|
|
|
This is actually valid in certain, rather unusual circumstances (e.g. a networked database running an old engine or configured such that it doesn't pool connections from different processes). But it's almost guaranteed that the coder just didn't know what he was doing ...
|
|
|
|
|
..actually connection pooling is enabled and on (because we are using the ADO.NET client for SQL Server it is on by default and set to a pool size of 100 conenctions). The code is just not using it.
|
|
|
|
|
Duncan Edwards Jones wrote: Conscious perma-coupling for the lifetime Maybe an author of the idea couldn't find a proper woman, and wanted to make it up by designing a "couply" system... Maybe he should break up with Anna.avi and get merried.
|
|
|
|
|
A RichTextBox has an Rtf property, and a SelectedRtf property.
Even when all text is selected, their values differ.
Just try:
string rtf1 = richTextBox1.Rtf;
richTextBox1.SelectAll();
string rtf2 = richTextBox1.SelectedRtf;
System.Diagnostics.Debug.Assert(rtf1 == rtf2);
|
|
|
|
|