| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
"What's our Vector, Victor?"
|
|
Brillant!
I need to brush up on this amazing soluition! |
|
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. |
|
Would they have had utility functions that make life easier when dealing with this function?
|
|
I am so dis-Oriented by this vects-ing code <grin>
|
I like this part. True, False, Null, FileNotFound strikes again. |
|
Pepper makes this code taste like burning.
|
Unless I missed something, it's rather poNumber = ((orderVector.get(4).equals("shipped"))?orderVector.get(6):orderVector.get(5))
|
|
Looks like someone spent too much time using LISP, or Perl, or worse... APL
|
|
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.... |
|
That is awesome. object DoEverythingConceivable(string whatToDo, object whatToDoItWith) |
|
Jeez, it's about time you posted tdwtf. It's 4:30! You're normally here at 3PM on the dot!
|
|
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? |
|
Yes! Finally, void* is back! |
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. |
Re: Vector Oriented Programming
2006-03-29 16:26
•
by
loneprogrammer
|
DoEverythingConceivable("go to hell", handbasket); |
|
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! |
|
Well, at least they use Vector. Most "clever" people use hashtables to
implement "flexible" objects, but using Vectors instead adds some, well, inflexibility. |
Re: Vector Oriented Programming
2006-03-29 16:31
•
by
foxyshadis
|
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 |
Yes. It is not strongly typed but, at least, it is rigidly obtuse! |
|
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 |
Re: Vector Oriented Programming
2006-03-29 16:34
•
by
StupidPeopleTrick
|
|
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 |
Re: Vector Oriented Programming
2006-03-29 16:35
•
by
JamesCurran
|
Except C++ does have a "Vector" or a "String" (it has "std::string" and "std:vector<Order>".) |
|
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! |
I don't think that would ever return. |
|
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.
|
|
Actually, in Java you need to cast everything coming out of a Vector
(since Vectors store Objects). So really, it is something like: poNumber = ((((String)orderVector.get(4)).equals("shipped"))?(String)orderVector.get(6):(String)orderVector.get(5)); |
Well, it seems nothing can keep the clever guys from using Javadoc comments and Java classnames in C++ program. Why not? |
|
I think this is the preferred way of programming in PHP 3.
|
No. poNumber could as well be declared as Object; equals(Object obj) is a method of Object. So, technically speaking, no casting required here. |
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. |
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 ... |
|
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 |
Re: Vector Oriented Programming
2006-03-29 16:46
•
by
Hubert Farnsworth
|
Alright, the smilies, it's apparently no good idea just to type them. Too simple. But otherwise it actually worked as intended! |
Re: Vector Oriented Programming
2006-03-29 16:50
•
by
John Hensley
|
You can never spend too much time using Lisp! (Just don't use it for contract work) |
|
llllol
|
|
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". |
Re: Vector Oriented Programming
2006-03-29 16:54
•
by
kipthegreat
|
Well you're almost right, but the first cast is unneeded (polymorphism takes care of it). So it simplifies down to this: poNumber = ((orderVector.get(4).equals("shipped"))?(String)orderVector.get(6):(String)orderVector.get(5)); |
|
But can it return a vector of vectors of vectors? --Rank |
Re: Vector Oriented Programming
2006-03-29 16:57
•
by
kipthegreat
|
Umm... no it won't. |
Re: Vector Oriented Programming
2006-03-29 16:59
•
by
Marshall T. Vandegrift
|
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? |
|
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. |
What's this I keep hearing about about polymorphism and virtual functions? |
Re: Vector Oriented Programming
2006-03-29 17:06
•
by
kipthegreat
|
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. |
|
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.
|
|
Sigh. My edit-time expired .0 seconds after posting that. It's in reference to the vector of vector of vectors post above...
|
|
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!"); } } } |
|
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: /** |
Order Vector, Error Vector I'm a Vector, He's a Vector Wouldn't you like to be a Vector, too? |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |