• FM (unregistered)


  • (nodebb)

    It feels like a WTF, but I can't pinpoint what's actually wrong with this code.

  • Quite (unregistered)

    Indenting consistent? No? Reject.

  • MiniMax (unregistered)

    Of course I have. Well, from a list of error numbers and corresponding error messages to Java property files. 

  • (nodebb)

    Wait a minute... no cornify? no sprinkling of editor comments? Who are you and what have you done to the real Remy?

  • (nodebb)

    Looks like a standard Java extension to me. What are we supposed to do if Java lacks all the good metaprogramming facilities?

  • Actually... (unregistered)

    " But hey, it does have a use strict declaration, guaranteeing you’ll get errors if you access uninitialized variables".....although in my brief look at this code, given that all the variables tended to be properly initialized with "my", I suspect that any errors/warnings from strict would be fixed by the developer. That is the whole purpose of that module, you know. To make sure the perl code tries to be well-written?

    I personally think this is brillant, er, I mean brilliant. TBH I've done similar things in the past, written perl code that reads an XML schema and creates simple ADT-like classes in Java with getters and setters. It saved a ton of time, not having to spend 45 minutes writing a simple wrapper class. The wtf in my case was probably: a) why aren't we using a data modeling tool to create that code for us (although many people consider THAT a wtf) or b) this was in the Java 1.5 days so maybe the wtf was using Java before autoboxing and templates and stuff.

    Or maybe I'm actually a developer that creates my own WTFs.

    In fact, maybe the wtf is just using Java at all.

    CAPTCHA: Palm trees?

  • kyureki (unregistered) in reply to gleemonk

    Don't use metaprogramming?

    Or, alternatively, use a language better suited for this sort of work?

  • Quite (unregistered)

    I confess this does remind me just slightly of how I wrote a program in FORTRAN once to parse a COBOL file defining a file structure, thence to use that program to write the output from an Oracle database into files of exactly that COBOL format, complete with EBCDIC coding. It afforded us sufficient backward compatibility that we could continue to keep our existing customer base happy while we gradually enhanced the accounts of those willing to upgrade to our new system without having to maintain too much legacy code. This was done as part of a millennialization program we had been tasked with. Unfortunately the FORTRAN-to-COBOL bit worked so neatly and seamlessly, we could not persuade the customers to upgrade. Ten years later they were still using their old system.

  • (nodebb)

    Reminds me of the time I used Visual Basic 6 to turn COBOL source code into color coded and hyperlinked HTML.

  • thosrtanner (unregistered)

    Use strict gives you an error if you attempt to use an undeclared variable. use warnings will tell you you've accessed uninitialised ones. I have to say I'm somewhat disappointed and the lack of comments and unicorns doesn't help.

  • Simon (unregistered)

    Interesting. It's a little hard to follow, but I think what they're doing is patching generated Java code... the JAXB references suggest that they're taking source files generated from an XML schema, then customising them in some way. It's not the proper way of doing this - JAXB does have some ability to customise the code from the generator itself - but given the quality of the documentation for doing so, I can't exactly fault this approach too much...

  • löchlein deluxe (unregistered) in reply to Quite

    The indentation is perfectly consistent, there's just two huge blocks of multiline string in there which I'd have refactored out. And even those look like their indentation will probably blend in perfectly with the rest of the generated code. All in all, frankly, this is not more SAN-draining than any other Perl.

  • Overpaid Consultant (unregistered)

    I have had the wonderful opportunity of being part of doing something like that.

    A large group of talented professionals whose profession is to provide state-of-the-art enterprise solutions decided that the proper way to communicate with the system that they were implementing was via web services. And that's well.

    What wasn't so well was that the talented professionals responsible for defining the web service schema were apparently talentedly doing it for the first time in their lives. They split the functionality that we needed into six different web services. That all used the same namespace (and that, incidentally, was the default namespace of the system, the one that comes with warnings of 'Don't ever use this for anything!'). And naturally each web service distributed a wsdl file containing just the parts of the schema that it itself needed.

    To use web service 1 we needed a JAXB class Foo with the method bar(). To use web service 2 we needed Foo with the method baz(). Neither of the services provided both methods. Getting the talented multinational team of highly paid experts to change their architecture was absolutely out of question, and their company had much more clout than our, so we had to learn to live with it.

    The solution was to take the generated JAXB classes and then mangle and mung them together into an unholy union of all of the web services. Though, we did it using Java's compiler classes and reflection instead of Perl.

  • chris (unregistered)

    You think the XML in ant is bad? I raise you one- Jelly. (http://commons.apache.org/proper/commons-jelly/) If there ever was an idea that should have been killed at birth, it's that one. "Jelly is a tool for turning XML into executable code." Had to use that in some Jenkins plugin a few years and we'll let's say I taught myself many new and creative ways of cursing

  • Contract Auditor (unregistered)

    The ListWrapper violates the List interface Contract. It overrides add, addAll, and set, but not get, size, or any other method.

  • airdrik (unregistered) in reply to Contract Auditor

    ListWrapper is a WTF, not because it fails to implement all of the necessary methods (it extends ArrayList which is a concrete class), but because it violates is the expected behavior of List.
    What you get is a list with a write-only list appendage attached to it that absorbs all of the items you add using the normal add methods. (though it somehow seems appropriate, considering the write-only nature of the language used to add it)

  • tgape (unregistered)

    I'd guess the biggest WTF is copy-pasting a class everywhere, instead of writing a single instance of that class.

    Oh, and then there's this thing:

    $_ =~ s/name\s*=\s*"$1"/name = "$1$multiples{$1}"/gis;

    For the uninitiated, this line says, search for every 'name' any number of spaces '=' any number of spaces '"' the results of the last search '"', and replace that with 'name = ""', and produce two warnings about using an uninitialized variable and a third warning about using an uninitialized variable in a hash element.

Leave a comment on “An Ant Pushes a Perl”

Log In or post as a guest

Replying to comment #:

« Return to Article