- 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
"What's our Vector, Victor?"
Admin
<font size="3">First! WTF!</font>
Admin
Brillant!
I need to brush up on this amazing soluition!
Admin
At least the Order data isn't stored in a String with '|' characters between the data.
Nobody would ever be dumb enough to do that.
...
I wish I was joking.
Admin
Would they have had utility functions that make life easier when dealing with this function?
Admin
I am so dis-Oriented by this vects-ing code <grin>
Admin
I like this part. True, False, Null, FileNotFound strikes again.
Admin
Pepper makes this code taste like burning.
Admin
Unless I missed something, it's rather
Admin
Looks like someone spent too much time using LISP, or Perl, or worse... APL
Admin
Back in my day, we'd have "variant records" in Pascal. Why does this "VOP" remind me of it?
Oh yeah, sucks just as bad. Worse, actually - With variant records, each field would have an actual name....
Admin
That is awesome.
<FONT size=2>object DoEverythingConceivable(string whatToDo, object whatToDoItWith)
</FONT>Admin
Jeez, it's about time you posted tdwtf. It's 4:30! You're normally here at 3PM on the dot!
Admin
So basically, we eschew all sense of strongly typed objects or even run-time binding, such as referencing an object by property name, and end up with Vector Pepper.
At least they didn't hardcode constants. I suppose that you'd have to pass the entire object into a function to determine what field it should be, such as:
poNumber = orderVector[determine_PO_Index(orderVector)];
Any this is my favorite part:
Which date? The current date? The last saved date?
Admin
Yes! Finally, void* is back!
Admin
This design is on life support. No, actually, it's in the OR and its guts are falling out all over the place. Quick, stuff everything back inside with a discreet:
class Order extends Vector;
And pretend that this implementation doesn't exist and doesn't matter.
Admin
<font><font size="2">DoEverythingConceivable("go to hell", handbasket);</font></font>
Admin
also, re: tdwtf
Jesus christ. These are the same people who return to you a mysterious void* as return data from a method. What does it contain? NOBODY KNOWS!
I mean, cmon, even C had struct!
Admin
Well, at least they use Vector. Most "clever" people use hashtables to implement "flexible" objects, but using Vectors instead adds some, well, inflexibility.
Admin
If it's Java, yes; if it's C++ (which I assume given Alex's example) it's all overloaded into normal array & equality syntax. Ah, operator overloading, a bottomless fountain of deadly wtfs. =D
Admin
Yes. It is not strongly typed but, at least, it is rigidly obtuse!
Admin
There's book out there that advocates this very practice:
http://www.amazon.com/gp/product/1893115917/sr=8-1/qid=1143667746/ref=sr_1_1/103-7532034-0366206?%5Fencoding=UTF8
Admin
The developer in me says "you write it, you debug it".
The tester in me says "you write it, you test it".
We have heard of black box testing - this looks like black box code.
- SPT
Admin
Except C++ does have a "Vector" or a "String" (it has "std::string" and "std:vector<Order>".)
Admin
Funny, the code that I was working on 5 minutes ago looks kind of like that, but in Lisp.
Little bits like "(setf result (seventh (first obj)))" make maintenance fun by turning it into a scavenger hunt!
Admin
I don't think that would ever return.
Admin
Crap, the forum software lost half my post. The book I linked to above reads like a self-help book, advocating the entire time how great this method is, how it's so wonderful the author discovered it, and how it will change your life. And then the example code requires you to download their binary-only libraries, which if you use in any project you must pay a license fee for.
Admin
Actually, in Java you need to cast everything coming out of a Vector (since Vectors store Objects). So really, it is something like:
Admin
Well, it seems nothing can keep the clever guys from using Javadoc comments and Java classnames in C++ program. Why not?
Admin
I think this is the preferred way of programming in PHP 3.
Admin
No. poNumber could as well be declared as Object; equals(Object obj) is a method of Object.
So, technically speaking, no casting required here.
Admin
Or Euphoria, which had 4 data types.... Integer, atom (double), sequence (un-typed, size-changeable constant access time list) or object (sequence or atom)
Any structs or classes you wanted to make were formed out of sequences with constants for the indexes. (using routine ids, aka function pointers)
It isn't a bad language for small programs (especially when learning) but I wouldn't have used it for anything larger.
Admin
So ... what shall we vectorise today - the order's number or its ID? :-P
And, assuming that there's a relational DB behind, it look very much like the order has no foreign key for the customer. So one can connect any order to any customer. Right!?
Yeeeeeeeeeeeeey big fuuuuuuuuuuuuuuuuuuun!
Alright, I'll cross my fingers, hoping that the forum SW lets this very extremely complicated thing pass properly ... uuuuuh ...
Admin
VB 6.0 and earlier used to have (something like) this, it was called "Variant" datatype. Highly prone to runtime errors, and often a PITA to debug. The .NET platform did away with it for good reason....
So the question from those of us not up-to-date on VOP development; is this WTF a crappy implementation of VOP, or is VOP a big WTF to begin with?
-Me
Admin
Alright, the smilies, it's apparently no good idea just to type them. Too simple. But otherwise it actually worked as intended!
Admin
You can never spend too much time using Lisp!
(Just don't use it for contract work)
Admin
llllol
Admin
Casting is required. Hard-coding "shipped" in the equals() method creates a new String object on the fly. Though orderVector.get(4) may well return a String object who's value may be "shipped", it will not be the same String object as the one created on the fly. As such, the Object equals(Object) call will fail. In other words:
orderVector.get(4).equals("shipped") --> will return false 100% of the time.
((String)orderVector.get(4)).equals("shipped") --> will return false ONLY if the value in the String returned from the vector equals the value of the String "shipped".
Admin
Well you're almost right, but the first cast is unneeded (polymorphism takes care of it). So it simplifies down to this:
Admin
But can it return a vector of vectors of vectors?
--Rank
Admin
Umm... no it won't.
Admin
The use of Java class names would be rather odd, but the Javadoc comments wouldn't be so unusual. The 'doxygen' tool -- one of the most widely used open source tools for in-line source documentation -- supports Javadoc-style comments for C++ and many other languages.
P.S. My first post, and I agree that the real WTF is the forum software. No preview? And how would I go about inserting a hyperlink?
Admin
Nope, first cast is needed. The orderVector.get(4) call returns an Object, NOT a String. Polymorphism doesn't apply in this case. Java doesn't know it's a String until it is casted. Even if that object is technically a String, not casting it will force Java to call Object's equals() method, not String's equals() method.
Admin
What's this I keep hearing about about polymorphism and virtual functions?
Admin
Nope, it's not.
Try this if you don't believe me:
public class WtfClass {
public static void main(String[] args)
{
Object obj = new String("wtf");
String str = new String("wtf");
if (obj == str)
System.out.println("They are the same object!");
else if (obj.equals(str))
System.out.println("They dot-equal each other!");
else
System.out.println("No relation!");
}
}
You'll get "They dot-equal each other!" printed out.
Admin
Not until the vector of vectors has 18 vectors in it. You'll also get a vector of vectors of vectors of vectors if you have more than 18 vectors of vectors of vectors. Truly, 18 is a magical number.
Admin
Sigh. My edit-time expired .0 seconds after posting that. It's in reference to the vector of vector of vectors post above...
Admin
WTF!! um ok.... since when ? Polymorphism always applies. try this.
public class test {
public static void main(String[] args) { java.util.Vector v = new java.util.Vector(); v.add( "wtf");
if( v.get(0).equals( "wtf") ) { System.out.println("yeah for polymorphism!"); } } }
Admin
This code was obviously written by a VOP neophyte. Anybody with any practical VOP experience knows that the proper way to perform this operation would be:
Admin
Order Vector, Error Vector
I'm a Vector, He's a Vector
Wouldn't you like to be a Vector, too?