• (cs)

    "What's our Vector, Victor?"

  • pongalong.com (unregistered)

    <font size="3">First! WTF!</font>

  • Rain Dog (unregistered)

    Brillant!

    I need to brush up on this amazing soluition!

  • (cs)

    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.

  • (cs)

    Would they have had utility functions that make life easier when dealing with this function?

  • (cs)

    I am so dis-Oriented by this vects-ing code <grin>

  • (cs)
    Alex Papadimoulis:

    <font color="#006600"> * @param getOrSet indicates what action to take. can be: * "get", "set", "close", "find" </font>


    I like this part. True, False, Null, FileNotFound strikes again.
  • (cs)

    Pepper makes this code taste like burning.

  • (cs)
    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))
  • (cs)

    Looks like someone spent too much time using LISP, or Perl, or worse... APL

  • Miguel Farah (unregistered)

    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....

  • Ralph (unregistered) in reply to ParkinT

    That is awesome.

    <FONT size=2>

    object DoEverythingConceivable(string whatToDo, object whatToDoItWith)

    </FONT>
  • (cs) in reply to Ralph

    Jeez, it's about time you posted tdwtf. It's 4:30! You're normally here at 3PM on the dot!

  • Brian Kemp (unregistered)

    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?

  • Snoopy (unregistered) in reply to Adonoman

    Yes! Finally, void* is back!

  • (cs)
    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.

  • (cs) in reply to Ralph
    Anonymous:

    That is awesome.

    <font size="2">

    object DoEverythingConceivable(string whatToDo, object whatToDoItWith)

    </font>


    <font><font size="2">DoEverythingConceivable("go to hell", handbasket);</font></font>
  • (cs) in reply to Volmarias

    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!

  • (cs)

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

  • (cs) in reply to ammoQ
    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
  • (cs) in reply to ammoQ

    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!

  • kedge (unregistered)
  • StupidPeopleTrick (unregistered) in reply to Volmarias

    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

  • (cs) in reply to foxyshadis

    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>".)

  • Disgruntled Lisp guy (unregistered)

    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!

  • Ralph (unregistered) in reply to loneprogrammer
    loneprogrammer:
    Anonymous:

    That is awesome.

    <FONT size=2>

    object DoEverythingConceivable(string whatToDo, object whatToDoItWith)

    </FONT>



    <FONT size=+0><FONT size=2>DoEverythingConceivable("go to hell", handbasket);</FONT></FONT>

    I don't think that would ever return.

  • kedge (unregistered) in reply to kedge

    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.

  • MVP (unregistered) in reply to ammoQ

    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));

  • (cs) in reply to foxyshadis
    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?
  • (cs)

    I think this is the preferred way of programming in PHP 3.

  • (cs) in reply to MVP
    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.
  • Urzumph (unregistered) in reply to Adonoman
    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.
  • (cs)
    Alex Papadimoulis:
    <font color="#006600"> * @param  orderNumber     number of the order
    * @param orderId id of the order
    * @param customerNumber number of the customer
    </font>


    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:

    <font color="#006600"> * @return                 vector of 18 elements or a vector of vectors
    * or an error vector
    </font>

    Yeeeeeeeeeeeeey big fuuuuuuuuuuuuuuuuuuun!

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

    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

  • (cs) in reply to Hubert Farnsworth
    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!
  • John Hensley (unregistered) in reply to Adonoman
    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)
  • Anonymous (unregistered) in reply to Ralph

    llllol

  • MVP (unregistered) in reply to ammoQ

    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".

  • (cs) in reply to MVP
    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));

  • (cs)

    But can it return a vector of vectors of vectors?

    --Rank

  • (cs) in reply to MVP
    Anonymous:
    orderVector.get(4).equals("shipped")  --> will return false 100% of the time.


    Umm... no it won't.
  • Marshall T. Vandegrift (unregistered) in reply to ammoQ
    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?
  • MVP (unregistered) in reply to kipthegreat

    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. 

  • John (unregistered) in reply to MVP
    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?
  • (cs) in reply to MVP
    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.
  • (cs) in reply to Rank Amateur

    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.

  • (cs) in reply to HitScan

    Sigh. My edit-time expired .0 seconds after posting that. It's in reference to the vector of vector of vectors post above...

  • joe (unregistered) in reply to MVP

    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!"); } } }

  • Josh (unregistered)

    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:

    <font>/**
    * 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
    */</font>
    <font>public</font> Vector getSetOrder(Vector inputVector)
    {
    ...
    }

  • gtllama (unregistered) in reply to Brian Kemp
    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?

Leave a comment on “Vector Oriented Programming”

Log In or post as a guest

Replying to comment #:

« Return to Article