- 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
I believe the MoveLast / MoveFirst thing was in order to get the right recordcount
Admin
Admin
I used to try self-modifying code in Z80 -- bad idea, although the three bits that affected the rotation instruction were just about manageable.
For "sensible" self-modifying code I think you need something like Lisp macros (or Scheme sanitised macros, which are mildly controversial).
For self-modifying code a la reflection, properly implemented, well ... I think it depends upon the scope.
What I think is a theoretically good model would be some construct that takes an object (or, I suppose, even a class, or for that matter a closed function) and does the necessary transforms for whatever reason appears to be useful within the current scope. And then discards the modifications.
This would imply idempotency; thus the reference to the Lisp family.
For mongrel dynamic languages like Perl, Python, Ruby (and for that matter C# and VB.Net), I'm not convinced that it's a good idea -- at least outside libraries.
The reason? 95% of the idiots using reflection in these languages are not aware of the dangers involved.
Thus the J2** Enterprisey WTFs that appear all over the place.
Admin
Admin
I was wrong. Using a spling in this case would be wrong. Short of an actual code exorcism ("Begone, foul VB!"), I would definitely prefer to have vi complain that I can't write the result out.
Of course, using the ColtMagnum editor on the original developer would be even more appropriate:
DYFLPunk?.357
Admin
That's what I wanted to hear ;) I was expecting To end the sentence! as an answer to my first question though :)
I must confess that I'm feeling a little embarrassed with my childish pedantic posts. Thank heavens for an internet in which you don't have to reveal your true identity.
Admin
If you never reveal your identity, then how will you get your money from the nice Nigerian prince?
Admin
However, I think you're still completely missing the point.
Admin
I am too lazy to back this up by looking at the article's history. But not too lazy to post about this on DailyWTF.
Oh, and what is up with "a trigger-like system" in the OP? Isn't this called the observer pattern?
Admin
I'm pretty sure the poster said extremely clearly that GetRecordCount RETURNS a boolean, not that it gets automatically cast to one. There is nothing ambiguous about that.
Admin
You expect people to have books on design patterns? Like the one by the gang of four?
Admin
Reflection more or less == java introspection
Admin
Every application must execute a subset of its repretoire for each input it encounters, but if the input data is not trusted, then the repretoire must be. Otherwise you have written an obscure, opaque, untested interpreter.
-Harrow.
Admin
"So if a record is deleted from any view, data about this deletion is passed to an object invoked via reflection."
It's BeforeDelete that gets called via reflection. The post doesn't say that BeforeDelete uses reflection itself.
Neither... unless by "various posters" you mean a set including yourself. :)
Admin
I'm not sure what you wanted to say, but what you did say (read: write) makes no sense. Converting a number to bool does not involve truncation but a test for non-zeroness (<- is that a real noun??). Even if it was a truncating conversion, it would be something more like std::numeric_limits<bool>::max() + 1. Note the function call parentheses as well, kludgy as they might be they are required here.
Admin
Nope. That would all be very logical, but vi (vim at least) is not that logical. The exclamation mark in :wq! instructs vim to force the write, not the quit. The quit is thus also more likely to succeed, but this is merely a side effect. So :wq! is actually like :w!, followed by :q on success.
:w!q would be a more logical mnemonic for this command - but to vim, this one actually means "force write to a file named q"...
Admin
Behold: (linebreaks added for clarity)
Admin
IIRC (I'm an intern that maintains the worlds biggest WTF VBA database), if you don't do that, you'll get a "No current record" error the second you try to dereference the var.
And, due to the semantics of VBA/VB6 (they're actually the same, only one is more gimped), you have to dereference to check null, unless it's a number variant which will say not null even if it is, but you have to know which it is before you can check either way. Or something like that. I remember that some variants which have no value will pass the isnull() and freak out about whatever VB's equivalent to dereferencing a null pointer if you check for isnumber() after the isnull(). Ugh, VBA. Shoot me. What I wouldn't give to be allowed to either have pointer level access, or a full blown, garbage collected, object oriented language. VB[A | 6] is the worst of both worlds.
Luckily, they didn't bother to actually document DAO before killing it. Well, they did some documentation, but a good portion of it is outright incorrect. Moving to ADO, which is prototyped nearly the same, but the order of formal arguments are in a different order. So close to compatible that it tempts you to do a Find/Replace on a 250K SLOC beast.
Admin
And, due to the semantics of VBA/VB6 (they're actually the same, only one is more gimped), you have to dereference to check null, unless it's a number variant which will say not null even if it is, but you have to know which it is before you can check either way. Or something like that. I remember that some variants which have no value will pass the isnull() and freak out about whatever VB's equivalent to dereferencing a null pointer if you check for isnumber() after the isnull(). Ugh, VBA. Shoot me. What I wouldn't give to be allowed to either have pointer level access, or a full blown, garbage collected, object oriented language. VB[A | 6] is the worst of both worlds.
Luckily, they didn't bother to actually document DAO before killing it. Well, they did some documentation, but a good portion of it is outright incorrect. Moving to ADO, which is prototyped nearly the same, but the order of formal arguments are in a different order. So close to compatible that it tempts you to do a Find/Replace on a 250K SLOC beast.
Admin
I want to know why the hell Microsoft does this so often!?
They create a replacement that is almost, but not quite, a replacement.
It's like they employ someone whose job is to screw with people.
Admin
And seemingly the forerunner of SkyNet.
This is almost as crazy as storing individual customer data on individual Excel spreadsheets. All 3+ million of them.
I was a contractor there. Browsed the network. Saw a gazillion servers named "Excel001" - "Excelxxx". Thought "WTF?". Logged onto one of them by random. Took 1 hour or so for the directory listing to show up.
But it's a close, close, second.
...
Well on second thought I guess it would be useful if you developed a framework or skeleton and then plugged in components. But it would only be at design time. For an application to do so at runtime and possibly without specific user direction seems iffy.
Admin
Admin
This actually sounds a lot like other projects that use reflection successfully. Struts is the first that comes to mind. This app uses a database instead of xml and uses it for dynamic rather than fixed configurations but it looks similar to me.
Am I missing something?
Admin
Admin
The real WTF is using VB instead of C#.
Admin
Admin
Yes, dynamic code is insanely hard to debug--the debugger has nothing to look at, and so you can't see what's going through your program's head. I've only used dynamically generated code within .net, and that was for a script interpreter. It's particularly bad when you try to invoke the method and it throws an InvalidProgramException, you have no way of inspecting the code at all. At least when it's a "valid" program .net can save it and I can use a decompiler to read it; invalid code would throw the decompiler for a loop.
But in the end, sometimes (like when writing a script interpreter) there is no way to do what you want without using dynamic code. In my case, it was because C# doesn't allow me to pass addresses into Method.Invoke, and I had to do special handling for events emitted from my scripts that had to be done via CIL. But if there's another way, you should really consider using it.
Admin
Dunno: looks to me as if ActiveRowIndex = ActiveRowIndex will throw an exception for invalid ActiveRowIndex, which you will get when the ActiveRowIndex is not valid, for example after deleting a row.
And the "throw" only happens when there is a different kind of exception (record not found).
Apart from that it's a function prototype for you to fix up if you need to add permissions to rows: at present it always returns true.
Admin
TRWTF is that "classes are called". Usually methods are called on instances of the classes (objects) or at worst static methods of some classes are called, but called classes? WTF!
Admin
Trigger - It's the bit you pull on the gun Interface - It's where you point the gun Reflection - It's what you did to this code to decide to make you point the gun interface.
Admin
JD: yes, you can just write "If Not RecordFound Then". On the other hand, as you can compare two values with just one equals sign, you can also ask a question with just one question mark...
Addendum (2008-07-07 07:12): p.s should also say that I love the idea of a "boolean panic" "Magpie Paradigm" and "boolean panic", two top phrases brought to you by friends of people who comment on TDWTF. We should be honoured ;^)
Admin
Isn't the biggest WTF the "not invented here"-syndrome? Why do people find it more fun to do it there own way instaid of using something that is available. In this case "data binding".
Admin
Thanks for explaining the WTFs - it helps for the aspiring WTF'ers :)
Admin
Admin
A couple more WTFs in that code:
As a side note, 95% of the time I put the positive condition first in an if/else block. However, there is the occasional case where the false condition is only one or two lines and the true condition is 15 or 20. In that case, I'll go ahead and reverse it, because I think it makes the code more readable.
Admin
Oh, no, we hadn't had we (see the conversation about 5 comments up, then slap yourself in the forehead...)
Admin
Admin
This is as innocuous as it gets with reflection. It's simply looking at the object to determine if it implements a given interface, no worse than querying IUnknown. This is exactly the kind of stuff it was meant for 90% of the time.
Admin
I'm late, but I can't believe no one missed that GUIDs are being stored in strings here, I mean come on.
Admin
Admin
echo aaa > aaa.txt chmod 444 aaa.txt vi aaa.txt :dd :wq :wq!
Admin
Hahaha... Sorry about the multiple marks... is kind of a local costume. (As for using a sigle equals sign for comparision, I have nothing against it.)
Admin
+1
Admin
This. Option Strict being Off is the WTF.
Admin
I actually like the DataF-a-c-a-d-e. Super
http://thedailywtf.com/Articles/Are-You-Cool,-Man-and-More.aspx
Admin
Yep, because they're completely different.
Oh, wait...
Admin
Too bad it doesn't work, just try this simple ass code:
Module Module1
End Module
Admin
and this one from c# to VB is even better!
class myType { public int x, y, z; public mySubType s; }
Admin
and this one from c# to VB is even better!
class myType { public int x, y, z; public mySubType s; }
Admin
Although compiler/interpreter might optimize it away, comparing a boolean to a static value and then testing the result (another boolean) does a few instructions more than just testing the boolean that you already had.
...in retrospect that was pretty useless, guess I'll go back to organizing the sock drawer.