- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Okay, but what if they're using Banker's Boolean for the variable?
Nonetheless, this practice is not recommended, as it can make your processor neurotic. "Is the Organization active? Then go do --wait, is it still active? Right, so do --is it active now?" Run that a couple hundred times, and your computer will start developing ticks, like opening and closing the CD drive spontaneously.
--Rank
--Rank
--Rank
Admin
5) He was not paid by the line.
Admin
<FONT face="Times New Roman" color=#000000 size=3>I disassembled the object class to see if this might shed some light on the topic. Imagine my surprise when i found this...</FONT>
public class object
{
...
private static int wtf = 0;
public static explicit operator bool(object o)
{
if (wtf++ < 2)
return false;
wtf = 0;
return true;
}
...
}
Admin
Is that a global regular oxprossion krinter?
:D
Admin
Real coders use grep to grok.
Admin
Touché.
In my defence, I'd put that down as one of the side-effects I've been suffering from being stuck on windows machines (because I don't actually own them).
Admin
That was my first thought when I saw this. According to the submitter, the author of the code was not a stupid person, and the code was not auto-generated, so this seems likely...
I once worked with an ocd-sufferer on a asp site. Seeing a comment starting with only one single quote (the comment character in vb) drove him absolutely crazy, so he went through the code on a regular basis to replace every ' in a comment with '' (two single quotes).
I know a few people with ocd so I had some sympathy for the guy. Still, I always changed the comments back on any file I was working with just to fuck with him.
Admin
I remember having a hardware which had (due to an incompatibility of operating system and processor step) the habit of occasionally miscalculating results of multiplications. As the error could appear only every 10ms, we simply multiplied everything thrice and took the result which appeared two times...
I still love this solution even though with more experience now, I'm sure, that another solution could have been found :-)
Admin
the if implies a comparison...
I suppose it might be a > 0 comparison-but for a bool it likely is an == true.
Admin
Valentine Michael Smith, actually. Reading that as we speak.
Admin
Admin
I am not sure about this code being able to handle concurrency or race conditions. Consider - it must pass the same test three times in order to execute the desired instruction - BUT if any of the tests fail, it does not wait and retry. The next data item is processed, thus missing the target item.
Ugly for certain.
Admin
you ever play with the netscape html editor ..
ahh, <big><big><big>Lovely</big></big></big>
Admin
So our future is to essentially become AI surgeon-therapists?
Admin
you fucking what?
Admin
Firstly, go get a book on the .NET Framework. Read it and understand it.
Secondly, realise that this is more likely than not version 1.1 and not version 2.0
Thirdly, the performance hit is there because of
1. Boxing and unboxing
2. Casting
#1 happens with the loop
#2 happens with the bool casting
In particular, boxing and unboxing is a rather expensive operation. Hence generics in .NET 2.0.
So to answer such an ignoramus as you, there is a material difference both in pattern designing as well as performance when you use a DataView to get 50 records from 50,000 as opposed to looping the entire 50,000 records and applying the cast.
You obviously have either weak knowledge of the .NET fundamentals or you are just trolling.
Admin
And obviously, you have not even bothered to look under the hood.
Besides, the issues mentioned, there is quickly algorithms under the hood to do the row filtering. Go get yourself Lutz's .NET Reflector and look at the code.
It amazes me that you have not talked about any piece of .NET code to support your arguments, merely specious generalisations which would lead one to belief you are not even a .NET programmer
Admin
Many thanks for pointing this out :-) I'll try to remember that next time I play with C#.
Admin
Who says it's a boolean? I bet it's an enum.
Admin
The trick is to get the linker to put makeAbsolutelySure (or is it makeAbsolutelyCertain?) right before the stack space. With any luck, when the stack overflows, it will overwrite the right instructions, causing makeAbsolutelySure to return 0...
Admin
Now now.... not everyone gets the chance to play and get paid good money at the same time. The devil is usually in the details and it certainly doesn't hurt to know them. <GRIN>
Admin
Yeah, side effects ...
Like in C:
if (i++ = 3){
if (i++ = 3) {
if (i++ = 3) {
printf ("Ha Ha!\n");
}
}
}
Admin
Too much code snipped from the original to show what is going on "under the hood". You are right tho, there is NO need for a loop here to get at 50 required records when there could be 50,000. This is where data access logic should of been written to look for the is_active field IN the query. Obviously, it wasn't. For a better assessment of the situation, you would need to really look at the business rules, perhaps they would yield a more robust picture of expected returned data based on criteria other than the is_active field... Perhaps instead of 50,000 records it was only 10. Looking for a couple records with is_active is a moot point. On the other hand, in my experience is_current and is_active have always been a small selection of records, sometimes small enough to impart <.5% filter selectivity, thereby even making an index on something with such a poor cardinality (field-wise) perhaps a good choice. In this situation, you would be a fool not to include this in your data access logic.
Still no need for a DataView in the part of the app we are currently discussing. Then again, there was no need to use DataSets either except that it was easy to implement. I still stand by DataReaders, as this is what both DataViews/DataSets utilize under the hood, yet without all the overhead, that is, UNLESS you need most of it, in which case, it is no longer overhead.
Then again, I've been living in a world of delphi win32 as of late, so maybe my C# is gettin rusty. :D
Admin
Please stop it! You clearly don't realise how utterly dorky you read. It's bordering on physical pain.
Sincerely,
Love and kisses,
Mr James T Peterson III MBA TCS LMN LPL
---------------
Sincerely,
Love and kisses,
Mr James T Peterson III MBA TCS LMN LPL
Admin
Typical when nothing insightful to add, you try to muddle the issue and obfuscate.
1. With what was presented in the code, it is by far preferable to use DataViews as opposed to the DataTable and the looping.
2. With boxing and unboxing occuring during the loop (with the use of the Enumerator), there is a penalty to pay when looping through 50,000 DataRows in the DataRowCollection to get at 50.
Therefore, ipso facto, DataViews are the right way to go here. Of course, if we want to talk of design patterns, and software architecture, we can do completely without anything from the System.Data namespace and use our own Domain objects. However, the code is NOT there for this, so such statements can only come when you have got nothing insightful or good to add.
Because, the records are being passed as DataRows, we can but assume there is a need to hold the data in-memory. DataViews are the preferred way to handle the manner in which the rows required are discovered. Your assertion against DataViews is specious and lack clear understanding. As you say, stick to Delphi if your C# is rusty, and it looks like your C# is indeed rusty,
Admin
Wasn't this already done in The Search for the Holy Grail?
"Three shall be the number...
Admin
Ouch! Misquoting it is one thing, and removing any hint of a rhyme scheme is another, but did you have to totally destroy the meter, too? I think you owe Charles an apology.
“Just the place for a Snark!” the Bellman cried,
As he landed his crew with care;
Supporting each man on the top of the tide
By a finger entwined in his hair.
“Just the place for a Snark! I have said it twice:
That alone should encourage the crew.
Just the place for a Snark! I have said it thrice:
What I tell you three times is true.”
Admin
I find it quaint and utterly charming. Keep it up, Gene. Nolite te bastardes carborundorum.
Cheers,
Dave Conrad
Admin
That's actually an excerpt the Book of Armaments (chapter 2 verses 9-21)
Admin
I'm almost curtain that the actual bug is in the code generator that generated this code.
Apparently there are always 3 checks that should be done. Either the generator can't handle just one check configured in some configuration file or even worse, it iterates through the config items, but the index is not set to get the right value.
Lesson is: take building a code generator as serious as the application it's generating code for.
Admin
heh, never would want to believe such a cock-smoking jizz-gobbler could be right, but sometimes they are.
Man, ur co-workers must love ya! :D
PS: Somebody get this poor soul some friends!
Admin
This doesn't make sense. He's attempting to read the value, not write it. You don't get a race condition from read accesses.
Admin
"This doesn't make sense. He's attempting to read the value, not write it. You don't get a race condition from read accesses."
You might if someone else writes to it while you're trying to read from it. Google "word tearing" for just one example of how this can happen.
An absurd, but likely to work most of the time, method for avoiding word tearing might be to read three times and reject the outlier. That would still be a WTF though.
Admin
I am going to post this three times just to make sure it gets posted.
Admin
I am going to post this three times just to make sure it gets posted.
Admin
I am going to post this three times just to make sure it gets posted.