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.


  • @zelmak said:

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



  • @zelmak said:

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



  • @C-Octothorpe said:

    @zelmak said:

    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. 


  • @Sutherlands said:

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



  • @morbiuswilters said:

    @Sutherlands said:
    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...



  •  @zelmak said:

    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.


  • ♿ (Parody)

    @zelmak said:

    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.


  • Trolleybus Mechanic

    @Someone You Know said:

    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... [b]holy jesus fucking ass-shit[/b]

     

    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.

     

     


  • Discourse touched me in a no-no place

    @Someone You Know said:

     @zelmak said:

    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.



  • @Lorne Kates said:

    @Someone You Know said:

    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



  • @morbiuswilters said:

    @zelmak said:

    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.

     



  • @morbiuswilters said:

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

     



  • @boomzilla said:

    @zelmak said:
    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.


  • ♿ (Parody)

    @zelmak said:

    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.



  • @boomzilla said:

    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.

     



  • @erikal said:

    @boomzilla said:

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

    ?



  • @zelmak said:

    @erikal said:

    @boomzilla said:

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



  • This is obviously a Java fault. It shoul have educated the developer automatically. Any good language would do that.


Log in to reply