Comment On Vector Oriented Programming

It's not too often that we have the opportunity to unveil the next paradigm in software development: Vector Oriented Programming (or, VOP). In addition to sounding cooler than OOP, VOP offers all the benefits of OOP and a healthy heap of flexibility. Take, for example, this method uncovered in an order entry system used within a mid-western shipping company ... [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Vector Oriented Programming

2006-03-29 16:13 • by ParkinT
"What's our Vector, Victor?"

Re: Vector Oriented Programming

2006-03-29 16:13 • by pongalong.com
First! WTF!

Re: Vector Oriented Programming

2006-03-29 16:13 • by Rain Dog
Brillant!

I need to brush up on this amazing soluition!

Re: Vector Oriented Programming

2006-03-29 16:15 • by loneprogrammer
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.

Re: Vector Oriented Programming

2006-03-29 16:17 • by Joost_
Would they have had utility functions that make life easier when dealing with this function?

Re: Vector Oriented Programming

2006-03-29 16:18 • by ParkinT
I am so dis-Oriented by this vects-ing code <grin>

Re: Vector Oriented Programming

2006-03-29 16:18 • by nonDev
Alex Papadimoulis:

 * @param getOrSet indicates what action to take. can be:
* "get", "set", "close", "find"


I like this part. True, False, Null, FileNotFound strikes again.

Re: Vector Oriented Programming

2006-03-29 16:19 • by Disgruntled DBA
Pepper makes this code taste like burning.

Re: Vector Oriented Programming

2006-03-29 16:20 • by ammoQ
Alex Papadimoulis:

And sure, you may need to constantly
pepper your code with things like, "poNumber =
((orderVector[4]=="shipped")?orderVector[6 ]:orderVector[5 ])", but you
see, that's the beauty of it. Pepper makes everything taste better.





Unless I missed something, it's rather

poNumber = ((orderVector.get(4).equals("shipped"))?orderVector.get(6):orderVector.get(5))

Re: Vector Oriented Programming

2006-03-29 16:21 • by Adonoman
Looks like someone spent too much time using LISP, or Perl, or worse... APL

Re: Vector Oriented Programming

2006-03-29 16:21 • by Miguel Farah
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....

Re: Vector Oriented Programming

2006-03-29 16:22 • by Ralph
66257 in reply to 66251

That is awesome.


object DoEverythingConceivable(string whatToDo, object whatToDoItWith)

Re: Vector Oriented Programming

2006-03-29 16:23 • by Volmarias
66259 in reply to 66257
Jeez, it's about time you posted tdwtf. It's 4:30! You're normally here at 3PM on the dot!

So basically

2006-03-29 16:24 • by Brian Kemp
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:

  • LastSaved_Username --or-- LastSaved_Date (past 11/12/02, it is Date)[LastSaved_Username] (exists only past 11/12/02)

Which date?  The current date? The last saved date?

Re: Vector Oriented Programming

2006-03-29 16:24 • by Snoopy
66261 in reply to 66255

Yes! Finally, void* is back!

Re: Vector Oriented Programming

2006-03-29 16:25 • by squirrel
Alex Papadimoulis:
And sure, you may need to constantly pepper your code with things like, "poNumber = ((orderVector[4]=="shipped")?orderVector[6 ]:orderVector[5 ])", but you see, that's the beauty of it. Pepper makes everything taste better.


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
66263 in reply to 66257
Anonymous:

That is awesome.


object DoEverythingConceivable(string whatToDo, object whatToDoItWith)



DoEverythingConceivable("go to hell", handbasket);

Re: Vector Oriented Programming

2006-03-29 16:26 • by Volmarias
66264 in reply to 66259
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!

Re: Vector Oriented Programming

2006-03-29 16:28 • by ammoQ
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
66266 in reply to 66254
ammoQ:
Alex Papadimoulis:

And sure, you may need to constantly
pepper your code with things like, "poNumber =
((orderVector[4]=="shipped")?orderVector[6 ]:orderVector[5 ])", but you
see, that's the beauty of it. Pepper makes everything taste better.





Unless I missed something, it's rather

poNumber = ((orderVector.get(4).equals("shipped"))?orderVector.get(6):orderVector.get(5))

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

Re: Vector Oriented Programming

2006-03-29 16:31 • by ParkinT
66267 in reply to 66265

ammoQ:
Well, at least they use Vector. Most "clever" people use hashtables to implement "flexible" objects, but using Vectors instead adds some, well, inflexibility.


Yes. It is not strongly typed but, at least, it is rigidly obtuse!

Re: Vector Oriented Programming

2006-03-29 16:33 • by kedge

Re: Vector Oriented Programming

2006-03-29 16:34 • by StupidPeopleTrick
66269 in reply to 66264

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
66270 in reply to 66266

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.


Except C++ does have a "Vector" or a "String"  (it has "std::string" and "std:vector<Order>".)

Re: Vector Oriented Programming

2006-03-29 16:35 • by Disgruntled Lisp guy
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!

Re: Vector Oriented Programming

2006-03-29 16:35 • by Ralph
66272 in reply to 66263
loneprogrammer:
Anonymous:

That is awesome.


object DoEverythingConceivable(string whatToDo, object whatToDoItWith)




DoEverythingConceivable("go to hell", handbasket);


I don't think that would ever return.

Re: Vector Oriented Programming

2006-03-29 16:37 • by kedge
66273 in reply to 66268
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.

Re: Vector Oriented Programming

2006-03-29 16:38 • by MVP
66275 in reply to 66254
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));


Re: Vector Oriented Programming

2006-03-29 16:41 • by ammoQ
66276 in reply to 66266
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




Well, it seems nothing can keep the clever guys from using Javadoc comments and Java classnames in C++ program. Why not?

Re: Vector Oriented Programming

2006-03-29 16:43 • by kipthegreat
I think this is the preferred way of programming in PHP 3.

Re: Vector Oriented Programming

2006-03-29 16:43 • by ammoQ
66278 in reply to 66275
Anonymous:
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));





No. poNumber could as well be declared as Object; equals(Object obj) is a method of Object.

So, technically speaking, no casting required here.

Re: Vector Oriented Programming

2006-03-29 16:44 • by Urzumph
66279 in reply to 66255
Adonoman:
Looks like someone spent too much time using LISP, or Perl, or worse... APL


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.

Re: Vector Oriented Programming

2006-03-29 16:44 • by Hubert Farnsworth
Alex Papadimoulis:
 * @param  orderNumber     number of the order
* @param orderId id of the order
* @param customerNumber number of the customer




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!?

Alex Papadimoulis:

 * @return                 vector of 18 elements or a vector of vectors
* or an error vector



Yeeeeeeeeeeeeey big fuuuuuuuuuuuuuuuuuuun!



Alright, I'll cross my fingers, hoping that the forum SW lets this very extremely complicated thing pass properly ... uuuuuh ...



Re: Vector Oriented Programming

2006-03-29 16:45 • by its me

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
66284 in reply to 66281
Hubert Farnsworth:
:-P


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
66286 in reply to 66255
Adonoman:
Looks like someone spent too much time using LISP, or Perl, or worse... APL


You can never spend too much time using Lisp!



(Just don't use it for contract work)

Re: Vector Oriented Programming

2006-03-29 16:51 • by Anonymous
66287 in reply to 66272
llllol

Re: Vector Oriented Programming

2006-03-29 16:52 • by MVP
66288 in reply to 66278
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
66290 in reply to 66275
Anonymous:
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 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));

Re: Vector Oriented Programming

2006-03-29 16:56 • by Rank Amateur

But can it return a vector of vectors of vectors?


--Rank

Re: Vector Oriented Programming

2006-03-29 16:57 • by kipthegreat
66293 in reply to 66288
Anonymous:
orderVector.get(4).equals("shipped")  --> will return false 100% of the time.



Umm... no it won't.

Re: Vector Oriented Programming

2006-03-29 16:59 • by Marshall T. Vandegrift
66294 in reply to 66276
ammoQ:


Well, it seems nothing can keep the clever guys from using Javadoc comments and Java classnames in C++ program. Why not?


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?

Re: Vector Oriented Programming

2006-03-29 17:00 • by MVP
66295 in reply to 66290
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. 

Re: Vector Oriented Programming

2006-03-29 17:03 • by John
66296 in reply to 66288
Anonymous:
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".



What's this I keep hearing about about polymorphism and virtual functions?

Re: Vector Oriented Programming

2006-03-29 17:06 • by kipthegreat
66297 in reply to 66295
MVP:
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. 

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.

Re: Vector Oriented Programming

2006-03-29 17:08 • by HitScan
66298 in reply to 66291
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.

Re: Vector Oriented Programming

2006-03-29 17:10 • by HitScan
66299 in reply to 66298
Sigh. My edit-time expired .0 seconds after posting that. It's in reference to the vector of vector of vectors post above...

Re: Vector Oriented Programming

2006-03-29 17:11 • by joe
66300 in reply to 66295
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!");
}
}
}

Re: Vector Oriented Programming

2006-03-29 17:12 • by Josh
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:



/**
* Returns an Order vector or a vector of Order vectors, based on one
* or more parameter values. If there was an error retreiving the
* Order, then a standard Error vector is returned. (see docs)
*
* @param inputVector vector of 4 elements
* @return vector of 18 elements or a vector of vectors
* or an error vector
*/

public Vector getSetOrder(Vector inputVector)
{
...
}


Re: So basically

2006-03-29 17:14 • by gtllama
66302 in reply to 66260
Anonymous:
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.


Order Vector, Error Vector
I'm a Vector, He's a Vector
Wouldn't you like to be a Vector, too?

« PrevPage 1 | Page 2 | Page 3Next »

Add Comment