|
_beauw_ wrote: Even logging these failures in a production environment can impact other critical systems.
..logging doesn't require much resources (a small ringbuffer?), and should not influence the working of dependent systems. Having a global error handler that logs anything that's not expected helps a lot when maintaining the application.
I are Troll
|
|
|
|
|
|
_beauw_ wrote: Logging is I/O, which is a failure-prone and time-consuming category of operation.Consider what happens if I attempt to log inside of a deeply nested loop;
I wouldn't expect a lot of unexpected exceptions in a deeply-nested loop.
_beauw_ wrote: There are .NET applications that control, or at least influence, real-time machinery.
.NET isn't recommended for time-critical operations, but how many exceptions could the app raise per 50ms?
_beauw_ wrote: There are .NET programs that guide stock traders in real-time. Entering into an I/O routine is not always an acceptable response to failure in such environments
I'm not talking about logging those exceptions that you handle locally, but those that you didn't expect and that don't get handled. There shouldn't be too many of those, and you wouldn't want to swallow those. Wouldn't want to ignore an divide by zero and price those stocks at "no worth"
I are Troll
|
|
|
|
|
try{} catch{} blocks should be use only when you need it. Else there will be a performance issue. It is not recommended to write try catch block for the whole code of any method. Where you expect to be a codeflaw, where exception may come just put your try catch there. Don't try to use generic exception in all the case. If you know some specific exception that may come, only catch those explicitly.
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
What you don't see, can't hurt you... It'll only hurt the guy who has to fix it.
|
|
|
|
|
Kevin Drzycimski wrote: they are world market leader
Whatever sells!
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Sounds familar
Perhaps you should add at least some tracing to your methods like this one
Then your code would be transparent to exceptions but you can still see what exceptions did flow through your code without becoming much slower.
public void Demo_Show_Leaving_Trace_With_Exception()
{
TracerConfig.Reset("console");
SomeMethod();
}
void SomeMethod()
{
using (Tracer t = new Tracer(myType, "SomeMethod"))
{
SomeOtherMethod();
}
}
private void SomeOtherMethod()
{
using (Tracer t = new Tracer(myType, "SomeOtherMethod"))
{
FaultyMethod();
}
}
private void FaultyMethod()
{
throw new NotImplementedException("Hi this a fault");
}
The output would look the like this:
18:57:46.665 03064/05180 <{{ > ApiChange.IntegrationTests.Diagnostics.TracingTests.SomeMethod
18:57:46.668 03064/05180 <{{ > ApiChange.IntegrationTests.Diagnostics.TracingTests.SomeOtherMethod
18:57:46.670 03064/05180 < }}< ApiChange.IntegrationTests.Diagnostics.TracingTests.SomeOtherMethod Exception thrown: System.NotImplementedException: Hi this a fault
at ApiChange.IntegrationTests.Diagnostics.TracingTests.FaultyMethod()
at ApiChange.IntegrationTests.Diagnostics.TracingTests.SomeOtherMethod()
at ApiChange.IntegrationTests.Diagnostics.TracingTests.SomeMethod()
at ApiChange.IntegrationTests.Diagnostics.TracingTests.Demo_Show_Leaving_Trace_With_Exception()
18:57:46.670 03064/05180 < }}< ApiChange.IntegrationTests.Diagnostics.TracingTests.SomeOtherMethod Duration 2ms
18:57:46.689 03064/05180 < }}< ApiChange.IntegrationTests.Diagnostics.TracingTests.SomeMethod Duration 24ms
That is a great time saver to find out where some exception did come from without the need to type try/catch(Exception ex) { LogException(ex);throw; } in many methods to find out where some exception did go through.
Yours,
Alois Kraus
|
|
|
|
|
Try/Swallow is an affective form of birth control.
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
They've implemented the most efficient source of Mystery Errors ever devised.
Before .NET 4.0,
object Universe = NULL;
|
|
|
|
|
I usually tend to point out the method in the madness, but this one takes the "stupid by design" label:
CF_HTML Example[^]
Version:0.9
StartHTML:71
EndHTML:170
StartFragment:140
EndFragment:160
StartSelection:140
EndSelection:160
<!DOCTYPE>
<HTML>
<HEAD>
<TITLE>The HTML Clipboard</TITLE>
<BASE HREF="http://sample/specs">
</HEAD>
<BODY>
<!--StartFragment -->
<P>The Fragment</P>
<!--EndFragment -->
</BODY>
</HTML>
Yes, the offsets are "Byte count since the start of the clipboard". Which includes the text representation of the byte counts...
A KB article shows that you can use leading zeroes, otherwise you'd have to iterate until you got it right. Still, a format purely designed by a "we sould make it simple" receiver. Never mind the caller.
Agh! Reality! My Archnemesis![^]
| FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server.
modified on Thursday, July 8, 2010 9:50 AM
|
|
|
|
|
Half a day to find the sp causing the problem... another half to fix it and send emails out about it.
The first problem is that the original programmer (not here) said that the problem didn't happen.
This was "a while back" and eventually the users found a way prove that the problem does exist.
So I find the offending sp and it is: almost 200 lines long, creats a temp table as it's first action, contains two cursors, and the cursor for each fetch had an "IF NOT EXISTS(...".
Correct me if I'm wrong: using the EXISTS is a big no-no, right? Shouldn't you just do an extra left join (if necessary) and use that field instead of the EXISTS?
In fairness to the original coder, I am not sure how this could have been done without a cursor.
(I know it can... I'm just saying that generally if I stare at something with a cursor I quickly see how to do it without one - but that didn't happen this time)
Seven hours I spent on this today, plus having our contractor in my cube for about half a day, plus the meeting with my boss + her boss, plus what I spent on this last week.
Ironically, the original programmer was "literally correct" the problem (as stated by the user) was not a bug, though the application *was* certainly wrong.
[sigh] Since I'm mostly getting this off my chest I put it in coding horrors instead of the db forum.
|
|
|
|
|
ChrisC(@ncmail) wrote: Correct me if I'm wrong: using the EXISTS is a big no-no, right? Shouldn't you just do an extra left join (if necessary) and use that field instead of the EXISTS
You're wrong. try it.
|
|
|
|
|
|
Thanks!
http://drsql.spaces.live.com/blog/cns!80677FB08B3162E4!766.entry[^]
My tendency is to use a join, so I found this comment especially useful:
[quote]
So in conclusion, the point of this post is to avoid using joins to try to compare two sets, since this is not its function. In the end the join method doesn't seem clear as to what you are asking. I only touched on performance, but the join will often peform worse than the using in or exists, simply because the work involved to do the join is greater.
[/quote]
[sigh] live and learn
|
|
|
|
|
ChrisC(@ncmail) wrote: will often peform worse
Test it.
ChrisC(@ncmail) wrote: the work involved to do the join is greater
Though that work may be beneficial in some cases.
|
|
|
|
|
Here's another good reason not to use reserved names.
I'm working on a LINQ project with a series of tables that manage user roles. As a result, I have table names like Systems, Roles and Users.
My trouble started when I would add the objects to the Designer, hit Save and then suddenly Visual Studio would say things like
System.Data.Linq.Mapping.DatabaseAttribute is not defined
or
System.Nullable is not defined
In short, stopping me dead in my tracks. Now that I look back, I don't know why I didn't see the reason earlier.
When using the Object Relational Designer, Visual Studio wants to be smart and changes any words that are plural to singular so they make more sense when dealing with data.
That way, your code looks like
<br />
oUser = New User<br />
oUser.UserName = "John"<br />
instead of
<br />
oUser = New Users<br />
This is really nice because it does make the code a little more legible except in this situation:
Plural (singular)
Users (User)
Roles (Role)
UserRoles (UserRole)
Systems (System)
See the gotcha? Visual Studio translated the "Systems" table into a "System" object which immediately negated all of the main namespaces in the project.
The renaming feature for the objects in LINQ-to-SQL is great - but be warned, when you start getting errors like this, take a look at your source tables.
|
|
|
|
|
This reminds me of, "automagically", in the Buzzwords Hall of Shame, and makes me wish you didn't like the feature; because auto-complete is good, but auto-editorialize is nonsense and dangerous, as you just illustrated. Programming != Word Processing.
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
Had a similar problem few months ago. I had "Language" table in database basically storing all languages, that were used for multi-language stuff.
Then when database schema was finished, I began working on data access layer and DataSet designer failed miserably on that "Language" table. I don't recall what the problem was exactly, but the "Language" name was a no-no. Cheers
modified 19-Nov-18 21:01pm.
|
|
|
|
|
|
I may be wrong but I think there is an option to turn this "pluralization" behaviour off.
|
|
|
|
|
I think it should be an option to turn the feature on.
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
_beauw_ wrote: but it is not the place of the Object/Relational Designer to enforce this.
That's why you can disable it: Model IDE->Properties->Pluralize New Objects
Please note that this is a pure religious issue: In my case, all my tables are singular names(Login, Person, Role, etc). So I would have had a table named "System" and without the pluralization on, I would have had to map them differently to avoid this collision. You can map the tables any way you like in EF4.
Fact is, you'll always run the risk of name collisions with any code generation.
Before .NET 4.0,
object Universe = NULL;
|
|
|
|
|
I once had this bad experience too, and at that time we noticed that having database tables with Portuguese names would solve the problem (although we might have had problems with pluralization/singularization...)
|
|
|
|
|
Hi, this is my post! :S
function GoPage(accion)
{
if(accion == "G")
window.location.href = 'resultadointerfaz.asp?vyear='+ document.getElementById('Select2').value+'&vmes='+document.getElementById('Select1').value+'&tipo='+document.getElementById('tipo').value+'&consultar=G';
else
window.location.href = 'resultadointerfaz.asp?vyear='+ document.getElementById('Select2').value+'&vmes='+document.getElementById('Select1').value+'&tipo='+document.getElementById('tipo').value+'&consultar=C';
}
What do you think. I think that the else is not necesary!
bye!
|
|
|
|
|
there is a 1-letter difference near the end!
|
|
|
|