- 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
Yes, we definitely need yet another spreadsheet application instead of modifying one of the already existing ones!!
FIRST!!!!!!!!!!!!!1111111111111^^^^^
Admin
Since what most user want to use is Excel, why not making a better one for your company?
Second?
Admin
Turd
Admin
That seems an offense
Admin
I'm not too familiar with VB, which I presume this is, but I would have thought that:
RecordFound = DataFacade.GetRecordCount(ItemGuid)
was valid. Not good, I never said good, but valid. Because of the way that all versions of Basic hold your hand, it would let you put an integer value in to a Boolean - so any record count other than zero would be true.
Admin
Trigger...interface...reflection....guh?
Are these special Microsoft things, or do I just not know how to program after all?
Admin
Trigger is a database thing, trigger an action when an update/delete/insert happens on a particular table. Interfaces found in C++, Java, C#, VB.NET etc. Reflection is Microsoft (.NET) specific I believe.
Admin
If you don't know what reflection is you must be a real geek, never to have seen your own reflection in a mirror..
it's either that or you're a vampire.. take your pick :P
Admin
C++ also allows you to put an int into a bool without a cast (it will be true if and only if the int was nonzero). The C99 _Bool also behaves that way. This is hardly just VB "holding your hand". Not all the world is Java.
Admin
PHP and Ruby also have reflection FYI
Admin
Reflection isn't Microsoft specific, though it is used quite a bit in .NET http://en.wikipedia.org/wiki/Reflection_(computer_science)
Admin
That's nothing compared to loosly typed langugaes where you could return a boolean, an int, an Integer object. or a FileNotFound
Admin
TRWTF is that even in single-threaded .NET program, that's not guaranteed to be a no-op. Doing that could have the side-effect of deleting your entire filesystem, for all you know.
So who knows, maybe ActiveRowIndex is a property with a huge side-effect, and the original poster actually knew that it did something. More likely he's an idiot though.
Admin
(Of course, sensible C++ would use either templating or a non-pure virtual function here. Not that that's relevant.)
Is this a case of Microsoft misappropriating a perfectly legitimate and widely used term, as per usual, or is it a case of various posters getting thoroughly confused, as per usual?
Or me being hopelessly wrong, as per ...
Addendum (2008-07-04 09:16): And I'm none too convinced by this BeforeDelete implements BeforeDelete stuff, either.
Actually, there does seem to be an element of relection here, albeit one to do with the database and not the class. I suppose the question being asked is meant to be "does this database/record support delete?" rather than "does this view support delete?" ... which is confusing and dumb.
Particularly since the actual question being asked (once the bugs noted in the OP are sorted out) is "Does this record exist in the database?"
Well, the whole thing is a singularly pointless exercise, but it's not a real WTF. It's simply fixed. Go into vi and type 20dd:wq!
Then put a proper BeforeDelete method into the relevant classes.
Admin
... and Smalltalk, Java, the list goes on...
Admin
Security check by a function that returns a boolean beforehand instead of throwing an exception when illegally trying to perform the action?!? So the check has to be done in the working method again - and should react there by throwing the exception. So why do it twice?
Admin
Reflection allows you inspect metadata and invoke functions upon a particular object (or even create an instance of that object) without having the object definition at compile-time. It's tightly integrated into the .NET (as the base object has .GetType() which can then move onto reflectiony things like .GetType().GetProperties() etc).
It's useful when creating dynamic systems or dynamic UI components (that magically work out what an object contains and creates the appropriate columns in a grid for example).
It's also used to evilly look at internal types and invoke them inside an assembly and used for other seriously evil, evil hacks.
To me this example sounds like a hacky use of it as well.
Admin
Java has reflection too: http://java.sun.com/docs/books/tutorial/reflect/index.html ; as does Smalltalk.
@real_aardvark: It's a bit more than that. With reflection, you can modify the program's behaviour at runtime - it can compile and add new code to itself as it's running, as long as it knows what to look for. Further, you can tell it what methods to execute via a text file.
Specifically, I made a "bean loader" that could use the standard Java-bean specification (getX() and setX() rather than exposing the variable) to make a loader that would load any compliant classes, even if I'd never seen them before. Of course, it had slight security problems like allowing 'System.exec("calc.exe")', but that's just because I didn't code in a blacklist.
Admin
You could argue that run-time type identification is a sub-set of reflection, but then goto is a subset of while loops, so it's not a very useful lemma.
Admin
Admin
No, while loops are subsets of gotos. Gotos are evil. Therefore, loops are evil. Someone, quick, tell all the managers!
Admin
OP here.
There seem to be a few questions regarding the fact that I mention reflection without having any in the code snippet. The function itself is invoked using reflection, from whatever view is dealing with the record in question.
It works like this: View has a record it wants to delete. View checks database for "actions" to invoke on the record before it's deleted If there are "actions", view uses reflection to instance objects based on name View casts these objects to the appropriate interface View calls the BeforeDelete method on the reflection object
And the whole app is the real WTF. It's pretty much the posterchild to why soft coding is bad.
Admin
The only logical conclusion is that ALL COMPUTERS are evil and we should burn them immediately...
Admin
Why the exclamation mark?
Admin
:wq! -> (try to) _w_rite and _q_uit even if file is not saved !
Admin
Admin
Wow that is.. a special article. Notice how the 'example' section just seems to be an argument between two editors on how to instantiate an object in Actionscript.
Admin
Maybe you stopped the page loading halfway through then. They weren't arguing about it in the Python section...
Admin
Admin
Come on people. Why has no one posted "The Real WTF is Visual Basic" yet?
Admin
My point was: is there a scenario in which wq wouldn't work, but wq! would?
Admin
Admin
Admin
Reflection in .NET can be used to create instances and invoke methods without a static link to the class or even its assembly. It can also be used to inspect and modify private state. One of the most useful features is that it can also be used to read custom attributes (metadata).
Some "RTTI" implementations are also able to do some of these things now, but that's because they've gone outside the initial RTTI scope. "Type information" implies being able to read, not write or execute. It also generally implies getting information for types you're vaguely aware of, whereas a common use of Reflection is to deal with totally unknown types, often to enumerate them and see which ones might be relevant for a particular purpose.
RTTI:Reflection::While:Goto is an extremely bad analogy. Aside from the fact that while uses a conditional jump and goto uses an unconditional one, the jump itself is the primitive that all control structures must be built on. RTTI isn't some primitive or fundamental operation or architecture; it's an implementation of some of what's in the Reflection scope, much like how VBA is a limited implementation of VB, or how XHTML is a limited subset of XML.
Admin
Reinventing the square wheel?
Admin
Unfortunately I'm just the cleanup crew.
Admin
Well, it sounds to me as if you have your work cut out for you. Good luck with that.
JT http://www.Ultimate-Anonymity.com
Admin
Hi Welbog
I wanted to chime in and say that I have yet to see one of these dynamic reflection driven systems that is easier to maintain than a more traditional MVC or base class driven system.
Ultimately, when one of these systems is taken to its logical conclusion, you get a mishmash of logic scattered all over the show and linked together with attributes, factories and the like.
Normally (to me, at least, YMMV), a pure reflection driven app is one of the things that could happen when you put 10 geeks in a room with no experienced leader, and they say to each other: "Hey, wouldn't it be cool if we..." (Insert newest shiny stone idea here)
I spoke to someone recently that called this the Magpie approach to software development, and thought that was a brilliant metaphor.
Admin
Wait, someone found bad VB code? Say it aint so. I wonder how easy the errors would be to correct if you just went and turned Strict on and had the compiler point you to the WTF's in the app.
VB.NET would get so much less flack if the creators would have made ON as the default for Option Strict, or just removed the ability to turn it off in general. We're 6 years into vb.net now, is there really still a need to allow implicit type conversion? Is Microsoft still trying to convert VB6 developers?
Admin
Plz explane how 2 impelment relfexion w'out RTTI az pirmitvz.
(The while/goto comment was a throwaway, btw. Not intended to be taken seriously; more a comment on how the OP is absolutely not something that can be described as reflection -- as pointed out by the OP'er him/herself, above.)
You're going to mention slots at some point here, aren't you? Well, sorry, as far as I'm concerned, slots are a sort of "mixout" mechanism that just enable you to do RTTI on a named-method, type-agnostic basis. It's basically RTTI with the inheritance tree abstracted out.
Admin
To be fair, I've never even heard of the SecurityManager. I'm a second-year CS student with only a few years of experience, so this isn't exactly unexpected. As the thing was a throw-away toy, I didn't bother making it secure / pleasant to use / capable of handling malformed files, etc. It was a proof-of-concept that showed I could load pretty well any noncyclical structure in about 100 lines of code.
Admin
Lets mention that you can only use it in grids where the GUID is placed specifically in that column!
Well, you should thank that at least they are trying to have some arquitecture in their systems. Imagine this kind of stuff copy pasted around all the app.
Admin
Okay, maybe I'm missing something, but...
What is this function supposed to be returning if TypeOf controller is not SpecificController?
Admin
No one is pointing out the "If RecordFound = False Then". Which is what a friend of mine uses to call "boolean panic".
TRWTF is Microsoft
Admin
yes, c++ allows you to convert an int to bool without a cast. And granted, it will work until the day that (value % std::numeric_limits<bool>::max == 0). When that happens you scratch your head and try to understand why the computer isn't working correctly.
Admin
As WTF'y as that looks - it's an equality check in VB
Admin
You mean it couldn't be written as "If Not/! RecordFound Then"??? Ifs in VB do not evaluate a boolean but a comparission??
Admin
Hmmm.
This makes baby Jesus cry.
And me seriously consider giving up programming.
Perhaps I'm a bit behind the curve here but isn't the process of an application actively modifying code during execution a serious liability in debugging?
Jeez. And I thought the angst over excessive pointer manipulation in C applications was a pain.
Admin
Admin
Drink plenty of beer?
Give me a hint man, I'm drowning here.