The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Son of a ... Representative Line

Last post 02-20-2012 12:16 PM by veggen. 18 replies.
Page 1 of 1 (19 items)
Sort Posts: Previous Next
  • 02-15-2012 4:18 PM

    Son of a ... Representative Line

    New code a programmer here wrote recently. I'm trying to understand what he really wants to do to help him unscrew it.

    code = (String) (((Object[) objArr)[0]);

    Sadly, it appears to be an 'upstream' issue as one of our predecessors wrote a method which returns an

    ArrayList<Object[ ]>
    data structure.
  • 02-15-2012 4:34 PM In reply to

    Re: Son of a ... Representative Line

    zelmak:

    New code a programmer here wrote recently. I'm trying to understand what he really wants to do to help him unscrew it.

    code = (String) (((Object[ objArr)[0]);

    Sadly, it appears to be an 'upstream' issue as one of our predecessors wrote a method which returns an

    ArrayList<Object[ ]>

    data structure.

    Is this Java?  I think there is a syntax error, but ignoring that it looks as if you're casting objArr to an object array, then grabbing the first item in the collection and casting that to a string, right?

    An array of object arrays.  Just think of the flexibility!  Besides, you don't need type safety when you have casting and type checking, right?

    EDIT: Wait, "son of a representative line"?  You're telling me these bastards are multiplying?!

  • 02-15-2012 4:38 PM In reply to

    Re: Son of a ... Representative Line

    zelmak:

    Sadly, it appears to be an 'upstream' issue as one of our predecessors wrote a method which returns an

    ArrayList<Object[ ]>
    data structure.
    Do you work in Hell? Like, seriously, all you have are hideous Java WTFs. What sins did you commit in a past life? Why is this happening to you??

    Let the healing begin!

  • I may not agree with everything Morbs just said, but he expresses himself in a way that is dignified, respectful, polite and non-threatening!
  • 02-15-2012 4:41 PM In reply to

    Re: Son of a ... Representative Line

    C-Octothorpe:

    zelmak:

    New code a programmer here wrote recently. I'm trying to understand what he really wants to do to help him unscrew it.

    code = (String) (((Object[ objArr)[0]);

    Sadly, it appears to be an 'upstream' issue as one of our predecessors wrote a method which returns an

    ArrayList<Object[ ]>

    data structure.

    Is this Java?  I think there is a syntax error, but ignoring that it looks as if you're casting objArr to an object array, then grabbing the first item in the collection and casting that to a string, right?

    An array of object arrays.  Just think of the flexibility!  Besides, you don't need type safety when you have casting and type checking, right?

    Could be C# in .Net 1.1 (assuming the return type is actually "ArrayList" and not "ArrayList<Object[>").  1.1 didn't have generics, so unfortunately you had to do some casting when using lists and sets. 
  • 02-15-2012 4:47 PM In reply to

    Re: Son of a ... Representative Line

    Sutherlands:
    Could be C# in .Net 1.1 (assuming the return type is actually "ArrayList" and not "ArrayList<Object[>").
    No, it's definitely Java. Hell doesn't use C#.

    Let the healing begin!

  • I may not agree with everything Morbs just said, but he expresses himself in a way that is dignified, respectful, polite and non-threatening!
  • 02-15-2012 4:54 PM In reply to

    Re: Son of a ... Representative Line

    morbiuswilters:
    Sutherlands:
    Could be C# in .Net 1.1 (assuming the return type is actually "ArrayList" and not "ArrayList<Object[>").
    No, it's definitely Java. Hell doesn't use C#.
    So says you.  I had to perform an exorcism on the old code base before VS2005 would open the solution...

  • 02-15-2012 5:09 PM In reply to

    Re: Son of a ... Representative Line

     

    zelmak:
    code = (String) (((Object[) objArr)[0]);

     This reminds me of a Java web app I was given to maintain at my last job. Simple little thing to pull some data about some events from two separate databases and show them on one calendar on the web. The original developer, whom I never met, was passing the data for each event around as an array of Strings, usually called s_data.

    s_data[0] was a String representation of the date of the event in m/d/yy format. s_data[1] was the title of the event. Some events might have a URL where you could find more information. The URL would be in s_data[2] if it existed. s_data[3] might be "***", which indicated the event was important or urgent; it might also be either null or an empty String, depending on which source database the event had come from, either of which indicating the event wasn't important or urgent. If there was no URL associated with the event, the important/urgent flag would be in s_data[2] instead.

  • 02-15-2012 5:22 PM In reply to

    Re: Son of a ... Representative Line

    zelmak:
    ArrayList<Object[ ]>
    That looks like the sort of thing you get back from an unstructured / ad hoc query (that is, something that isn't annotated or defined in xml somewhere, but just a sql statement that gets executed). At least, that's what Hibernate does.
    I denounce myself for this post
  • 02-15-2012 7:15 PM In reply to

    Re: Son of a ... Representative Line

    Someone You Know:

    The original developer, whom I never met, was passing the data for each event around as an array of Strings, usually called s_data.

    s_data[0] was... holy jesus fucking ass-shit

     

    Either you worked the same place I work, or both your formed dev and my formed dev copy-pasta'd from the same homework website.

     

     


    HardwareGeek:

    <blink> and you're dead!



    "Where is grumpy cat?"
    - Mozilla's MOST ADVANCED USER!
  • 02-15-2012 11:22 PM In reply to

    Re: Son of a ... Representative Line

    Someone You Know:

     

    zelmak:
    code = (String) (((Object[) objArr)[0]);

     This reminds me of a Java web app I was given to maintain at my last job. Simple little thing to pull some data about some events from two separate databases and show them on one calendar on the web. The original developer, whom I never met, was passing the data for each event around as an array of Strings, usually called s_data.

    s_data[0] was a String representation of the date of the event in m/d/yy format. s_data[1] was the title of the event. Some events might have a URL where you could find more information. The URL would be in s_data[2] if it existed. s_data[3] might be "***", which indicated the event was important or urgent; it might also be either null or an empty String, depending on which source database the event had come from, either of which indicating the event wasn't important or urgent. If there was no URL associated with the event, the important/urgent flag would be in s_data[2] instead.

    I did NOT need the EDI flashback. Order lines are in a 15- field line, where any of the first three field can be the quantity, the next three can hold the unit price, and so on. Invariably, every single customer will use a different layout. It's the standard designed by Groucho Marx.
  • 02-16-2012 9:14 AM In reply to

    Re: Son of a ... Representative Line

    Lorne Kates:

    Someone You Know:

    The original developer, whom I never met, was passing the data for each event around as an array of Strings, usually called s_data.

    s_data[0] was... holy jesus fucking ass-shit

     

    Either you worked the same place I work, or both your formed dev and my formed dev copy-pasta'd from the same homework website.

     

    I'd say the latter is very possible. Looking at the complete set of this guy's code, it was pretty clear he had come to the job with no Java experience. This was not a huge surprise since the hiring process was a major WTF.

    This was a New York civil service job, which meant that each position had a specific Title. Each Title had a Job Description and certain Requirements (usually a number of years of experience). The requirements were very rigid; there was no way to, say, hire someone for a job that required 2 years of experience if he only had 22 months of experience, even if he was very qualified. None of this information had been updated in decades — the Job Description sheet I received for my Title was written on a typewriter and dated sometime in the late 1970s. No new titles had been created in years. The hiring process had come down to the difficult art of finding someone who was competent to do what the job actually entailed, and whose resume could be twisted in such a way as to fit what the Requirements claimed the job entailed. 

    Example: the Requirements for my Title listed "a working knowledge of COBOL". (Remember that this is a job developing Java web apps.) At one point I asked my boss about this, and he said, "Can you spell it?" When I did so successfully, he said, "Works for me."

     

     

     mod: fixed quotha –dh

  • 02-16-2012 10:19 AM In reply to

    • galgorah
    • Top 75 Contributor
    • Joined on 04-18-2007
    • Cambridge, Ma
    • Posts 731

    Re: Son of a ... Representative Line

    morbiuswilters:
    zelmak:

    Sadly, it appears to be an 'upstream' issue as one of our predecessors wrote a method which returns an

    ArrayList<Object[ ]>
    data structure.
    Do you work in Hell? Like, seriously, all you have are hideous Java WTFs. What sins did you commit in a past life? Why is this happening to you??
    Hell would be debugging MUMPS code.

     

    Reformed Developer and SQL Server DBA
  • 02-16-2012 11:06 AM In reply to

    Re: Son of a ... Representative Line

    morbiuswilters:
    Do you work in Hell? Like, seriously, all you have are hideous Java WTFs. What sins did you commit in a past life? Why is this happening to you??

    I don't know ... I ponder these questions daily ...

    It must've been something really bad, though, as I feel driven to come back every day ...

     

  • 02-16-2012 11:09 AM In reply to

    Re: Son of a ... Representative Line

    boomzilla:
    zelmak:
    ArrayList<Object[ ]>
    That looks like the sort of thing you get back from an unstructured / ad hoc query (that is, something that isn't annotated or defined in xml somewhere, but just a sql statement that gets executed). At least, that's what Hibernate does.

    Jesus H. Christ on a cracker! All the crap you've seen me post and you think we're using something FUCKING INTELLIGENT like Hibernate?

    No, the 'data access layer' (used to) consist (primarily) of two files, one of 55K lines, and the other of 25K lines where all access to the database went. Except when someone wouldn't want to muck around in there (you really can't blame them for that, eh?) and would write their own queries and their own (lack of) error-handling code and their own data-access frameworks.

  • 02-16-2012 11:22 AM In reply to

    Re: Son of a ... Representative Line

    zelmak:
    Jesus H. Christ on a cracker! All the crap you've seen me post and you think we're using something FUCKING INTELLIGENT like Hibernate?
    No, but I have no idea what generic JDBC (or whatever else you might be using) might do, so mentioning Hibernate was just me attempting to preempt the pedantic dickweeds from telling me about whatever their DAO does.
    I denounce myself for this post
  • 02-16-2012 11:40 AM In reply to

    • erikal
    • Top 500 Contributor
    • Joined on 12-23-2011
    • Netherlands
    • Posts 137

    Re: Son of a ... Representative Line

    boomzilla:
    No, but I have no idea what generic JDBC (or whatever else you might be using) might do
     

    Return a nice and sane ResultSet with which you can do whatever your heart desires. Including turning that ResultSet into the data structure from hell apparently. I mean even the biggest dickweed on earth (I'm adapting) doesn't write code that returns a list wrapping an object array and doesn't think "I either change this or shoot myself right here, right now". You have to be chief dickweed from planet Dickweed.

     

  • 02-16-2012 3:06 PM In reply to

    Re: Son of a ... Representative Line

    erikal:

    boomzilla:
    No, but I have no idea what generic JDBC (or whatever else you might be using) might do
     

    Return a nice and sane ResultSet with which you can do whatever your heart desires. Including turning that ResultSet into the data structure from hell apparently. I mean even the biggest dickweed on earth (I'm adapting) doesn't write code that returns a list wrapping an object array and doesn't think "I either change this or shoot myself right here, right now". You have to be chief dickweed from planet Dickweed

    Actually, I've started messing around with DAO calls which return List<Map<String, String>> or List<Map<String, Object>> ... where every map is a row with key/value pairs and the list is just the collection of them ... its quite liberating to actually worth with a reasonably sane data structure. I further wrote a TableModel which properly renders such a data structure. So, if I need to display some random query, do the random query, return the ListMap and toss it into a generic JTable wrapped with the appropriate ListMapTableModel ... all the boilerplate code just melts away.

    I mean, seriously, what's the difference between

    map.get(KEY_NAME);

    versus

    object.getKeyName();

    ?

  • 02-16-2012 3:16 PM In reply to

    Re: Son of a ... Representative Line

    zelmak:

    erikal:

    boomzilla:
    No, but I have no idea what generic JDBC (or whatever else you might be using) might do
     

    Return a nice and sane ResultSet with which you can do whatever your heart desires. Including turning that ResultSet into the data structure from hell apparently. I mean even the biggest dickweed on earth (I'm adapting) doesn't write code that returns a list wrapping an object array and doesn't think "I either change this or shoot myself right here, right now". You have to be chief dickweed from planet Dickweed

    Actually, I've started messing around with DAO calls which return List<Map<String, String>> or List<Map<String, Object>> ... where every map is a row with key/value pairs and the list is just the collection of them ... its quite liberating to actually worth with a reasonably sane data structure. I further wrote a TableModel which properly renders such a data structure. So, if I need to display some random query, do the random query, return the ListMap and toss it into a generic JTable wrapped with the appropriate ListMapTableModel ... all the boilerplate code just melts away.

    I mean, seriously, what's the difference between

    map.get(KEY_NAME);

    versus

    object.getKeyName();

    ?

    ZOMG! Insufficient boilerplate! Invalid Java! Needs more accessors and mutators!!!

    Let the healing begin!

  • I may not agree with everything Morbs just said, but he expresses himself in a way that is dignified, respectful, polite and non-threatening!
  • 02-20-2012 12:16 PM In reply to

    Re: Son of a ... Representative Line

    This is *obviously* a Java fault. It shoul have educated the developer automatically. Any good language would do that.
Page 1 of 1 (19 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems