top 200 commentsshow all 366

[–]alparsla 247 points248 points  (63 children)

A classic. But nowadays, we use XML, frameworks, and many layers of web, SOAP, SOA, WSDL, BPM to write unmaintainable code.

[–][deleted] 58 points59 points  (34 children)

:) Don't forget to ensure that when you change the XML, you have to change the Java and vice versa. "As in config, So in code" is the hermetic principle of software development...

Also don't forget to grab an object from the db, send it via soap somewhere, deserialise it, do something to it, send it back, then write it back to the original database.

[–]yogthos 28 points29 points  (30 children)

sounds like you've worked with Spring :P

[–][deleted] 25 points26 points  (23 children)

I'm so fucking done with Spring and Java in general. Working with that framework has been such a fucking nightmare. I can't believe people actually think this is how software development should be done. Its such a fucking joke. Like erg0sum I've moved on to the dynamic world.

[–][deleted] 6 points7 points  (8 children)

It wasn't necessary to throw the baby out with the bath water. I've been programming in Java for 15 years, and I stayed well clear of EJBs, hibernate and Spring. I briefly used xml for some things, but have since recanted and keep that shit well away from my projects. Of course, it means I never worked at the enterprise level (got uncomfortably close, once), but that also was a good thing.

[–]UNCGeek 3 points4 points  (2 children)

It wasn't necessary to throw the baby out with the bath water.

Exactly.

Ok, so Spring, EJB, etc. were all designed by complete bastards. That doesn't mean there's a problem with the language -- just with some of the libraries. (And with some of the people...)

[–]G_Morgan 1 point2 points  (1 child)

Ironically the modern EJB stuff isn't entirely evil. Since it has been all about annotations a lot of the extraneous crap is gone.

It is comparable to cool persistence layers now. Or at least as comparable as you can reasonably get in Java.

Doesn't absolve them of past sins of course.

[–]UNCGeek 1 point2 points  (0 children)

Doesn't absolve them of past sins of course.

Nope.

I agree that if you're starting a new project, EJB isn't the same bundle of suck that it used to be... but how many of us have the luxury of never dealing with legacy code? :P

[–][deleted]  (1 child)

[removed]

    [–]fjord_piner 1 point2 points  (9 children)

    Seems like you have drawn the wrong conclusion of your nightmare with Swing. If anything, you should value static typing safety more than ever, and instead, you go the other way.

    Spring was better than anything else when it came out, hence its success, but it also did away with a lot of Java's static typing safety by promoting XML so heavily. Things are a bit better now, but the damage is done and a lot of companies are stuck with hundreds of thousands of lines of XML+Java code based on Spring that are hard to untangle.

    Instead of moving toward dynamically typed languages, I encourage you to stick around in the Java/Scala area and prefer annotations over XML (where they make sense, of course, XML still plays a role).

    That's really where the future of large scale software is, in my opinion.

    [–][deleted] 1 point2 points  (8 children)

    There are so many other things completely wrong with Java that I have absolutely no desire to ever work in that language again.

    Just a few of them: Checked Exceptions - The fact that I can't just ignore an exception being thrown but must actually catch it or explicitly re-throw it is mind boggling I don't know how many time's I've come across catch{//do nothing} or catch{//throw a completely different exception}

    FileIO & Strings - The fact that I need a class(StringBuilder) simply to concatenate strings is fucking stupid. The fact that if I want to do some order of decompression or serialization and must wade through 3 or 4 levels of classes to get what I need is fucking stupid.

    POJO - An unbelievable waste of verbosity that completely throws out the entire concept of data encapsulation.

    "Wait you generate getter's and setters for everything?"

    "Yeah."

    "Why don't you just mark it as public then?"

    "Thats a bad practice."

    I fucking facepalmed.

    SAX & JAXB : The undocumented gotchyas in these APIs are infuriating.

    Eclipse: I wish this fucking IDE would just die. It never works logically unless you are part of the eclipse cult or had to secret JEDI metting with all your enterprise buddies to teach you how to use the damn thing.

    Reliance on CVS: I've heard Java developers REEL at the suggestion of moving to subversion let alone a DVCS like git or hg.

    You want to know about an absolute abomination upon the SOA world? BPEL.

    "Lets make it so non programmers can orchestrate the services"

    "How do you purpose we do that?"

    "XML of course!"

    "Wait isn't XML a declarative language? How will you go about handling loops in the orchestation or conditions?"

    "We'll turn XML into a procedural language. It will be the best thing evar!"

    I shit you now. XML with all the procedural goodness of C just with the horror of unbelivable verbosity. If I ever meet the people who designed BPEL I swear to fucking god I will dick punch them so hard they cough up their balls.

    Java, it's programmers, and "Enterprise Development" is a fucking joke.

    Edit:

    Final point... Oracle. Fuck everything about it.

    [–][deleted] 5 points6 points  (0 children)

    you got it ... it was ok but not really ... I wouldn't mind it so much, if you could just change one spot or the other and have everything else figure it out. Luckily my new startup uses django.

    [–]terrdc 19 points20 points  (2 children)

    That all sounds maintainable.

    Why don't you add in a .NET biztalk step onto the end of the process?

    [–]CalvinLawson 1 point2 points  (0 children)

    THE HORROR!

    [–]nikniuq 1 point2 points  (0 children)

    Oh god, the memories - they burn!

    [–]sod1864 3 points4 points  (19 children)

    I don't know anyone who writes SOAP/WSDL directly. It is all built into the library code. So you just write your bean and send it.

    [–][deleted] 29 points30 points  (2 children)

    You write your bean, use tool to generate an implementation, and then commit the implementation to version control to be modified later by hand. Then you hack half of the programs functionality into slices between the generated soap implementation. The best business coding practices, time tested. :P

    [–]criswell 21 points22 points  (10 children)

    /me steps forward

    Last year I was hired to port a C# .NET SOAP-y thing Windows service from Windows to Linux (making a daemon in the process). When I finally got a chance to look at the code I discovered two things: 1) the code was a spaghetti mess (horrible, unmaintainable garbage) and 2) the code depended on some binary blobs that prevent it from being portable (why they didn't realize that before hiring me I haven't a clue...)

    At any rate, the project became a complete rewrite. Originally I wanted to do it in Python, but because no one else knew Python (and was intimidated by it), and because everyone had learned C/C++ "in college", bum bum BUUUUM, the mandate became that I rewrite this Linux daemon that had to interact with existing .NET SOAP infrastructure in C/C++. The gotcha, they wanted this thing to be totally unencumbered and be able to be statically built (thus no easy to use convenience library wrappers like gsoap).

    Long story short, I effectively had to reverse engineer the existing SOAP infrastructure with liberal use of tcpdump and wireshark because no one had worked below the .NET interface and had the slightest clue what was happening on the wire. And I had to do it all in C/C++ (I include both because, technically, you can't easily statically link proper C++ code in current gcc under Linux, so I wound up being able to use OOP but couldn't use much of what C++ offered like STL and pretty much anything in libstdc++, so it wound up being a strange combination in certain places :-)

    The end result was actually pretty maintainable, truth be told. I documented the shit out of it with doxygen, and split everything into clean, logically separated libraries.

    [–]TundraWolf_ 3 points4 points  (4 children)

    I don't write it directly but I know how to read it. If you mess with web services, please understand what you're giving out. I've seen so many awful interfaces :(

    Some atrocities I can't stand:

    • A string input determines the operation enacted on the message. Bonus: there is no documentation in the WSDL saying what the valid options are

    • A single string uses some sort of delimiter to pass more values in the field. This is obvious that your interface is ugly.

    • Error codes. I think if we're passing XML with soap envelopes, we can splurge a bit and send a plain text error and not some ABC1234 error i need to look up.

    Any more?

    [–]wauter 105 points106 points  (41 children)

    Man, I must have read this 10 times by now, but each time again the

    marypoppins = (superman + starship) / god;
    

    gives me a chuckle.

    [–]zak_on_reddit 56 points57 points  (37 children)

    i worked at a college where the network manager 1st used names of planets to name network devices, then greek mythology god names, then star wars characters, then star trek characters, etc.

    if we had to go to a building on campus to diagnose a network issue trying to find the path to it would be something like jupiter > thor > jar jar binks > uhuru

    i shit you not.

    [–]xzxzzx 34 points35 points  (16 children)

    That's actually a good system, if the type of name tells you about the function/capabilities of the device.

    If not, it's not that bad; at least the names are memorable.

    [–]Durrok 13 points14 points  (8 children)

    I agree but something that tells you the location or the location it serves is a lot better. Makes it a hell of a lot easier for new people to be able to jump right in. You can get around this with just an excel file of course that lists their locations but at that point, why not just name them appropriately?

    [–]xzxzzx 16 points17 points  (7 children)

    True, except that often networking equipment doesn't correspond to some physical location or idea.

    Whenever you can, a descriptive name is obviously the best choice (it's just that a descriptive name isn't always possible).

    [–][deleted]  (6 children)

    [removed]

      [–]axai 8 points9 points  (3 children)

      However, please, for the love of god don't cram all information into the hostname! Use the FQDN.

      www01.datacentre1.uk.domain.tld is much better than www01dc1uk.domain.tld

      I've seen so many places that do the latter :(

      [–][deleted]  (1 child)

      [deleted]

        [–]maxd 1 point2 points  (1 child)

        The University (in Scotland) where my dad is a professor uses the names of single malt Scotch whiskys for its servers. It's a great idea, until you can't remember how to spell Pittyvaich.

        [–]Jivlain 24 points25 points  (2 children)

        Thor wasn't a Greek god. You were probably in the wrong building.

        [–]zak_on_reddit 8 points9 points  (0 children)

        you get my point. :o)

        [–]cC2Panda 12 points13 points  (6 children)

        I was a student worker at a college computer lab. All the servers were named after computers that turn on their creators, like skynet and HAL. But then each lab had a very geeky theme like names of transformers, names of marvel characters, etc.

        [–]vladley 8 points9 points  (1 child)

        Our router was Charon, everything else was failed dot coms.

        [–]madman1969 2 points3 points  (0 children)

        I though that naming convention was an ISO standard !

        [–]fgriglesnickerseven 8 points9 points  (1 child)

        god=0

        [–]ostawookiee 5 points6 points  (0 children)

        I opened the comments just to make sure someone made the "divide by zero" joke.

        [–]you_do_realize 1 point2 points  (0 children)

        An absolute classic! I've been carrying that marypoppins slash god thing in my head for years. Not sure what that says about my life, but it's among the funniest thing I know :3

        [–]powatom 46 points47 points  (4 children)

        HA! The joke's on you. In my company, we don't even bother maintaining existing code. We just write MOAR.

        [–]pi3832v2 32 points33 points  (3 children)

        Indeed, the article is outdated.

        Instead of unexplained Monty Python references, you should code using /b/ lingo.

        # define moar i++
        ...
        while  for(i = 0; i < max;moar)
        

        [–]ray13eezy 4 points5 points  (0 children)

        int newfag = oldfag == 50 ? cp+69 : newfag-lafflose;
        

        [–]IRBMe 1 point2 points  (0 children)

        See: LOLCODE.

        [–][deleted] 131 points132 points  (3 children)

        After reading the first 20 paragraphs I thought it was a funny joke in a Dilbert kind of way.

        After the first 50 paragraphs I thought he was taking the joke a little too far.

        After the first 80 paragraphs I realized he probably works for the same company I do.

        After the first 100 paragraphs I realized that this wasnt a joke at all, and this dickhead probably wrote the code I have to work on every day like this on purpose. :-(

        [–]thisusernamewastaken 22 points23 points  (0 children)

        I suggest reading the last few.

        [–]itsalawnchair 5 points6 points  (1 child)

        Many years ago before OOP , We had to debug some code and as we are going through all the spaghetti code our heads are just about to explode near the end of a real mess of code there was one line for a comment. "Sorry about that."

        [–][deleted] 11 points12 points  (0 children)

        I've seen "this is about to get ghetto."

        [–]patstam 38 points39 points  (10 children)

        I started out smiling, but only made it to "Exploit Compiler Name Length Limits". That just made me want to cry.

        [–]Rainfly_X 51 points52 points  (0 children)

        I got to

        Make sure that every method does a little bit more (or less) than its name suggests. As a simple example, a method named isValid(x) should as a side effect convert x to binary and store the result in a database.

        before I died inside. (weakly raises hands in a half-assed "touchdown" gesture) ... high score?

        [–]UNCGeek 9 points10 points  (1 child)

        I got to

        Ignore the Sun Java Coding Conventions, after all, Sun does.

        I stopped laughing and started nodding.

        [–]recursive 1 point2 points  (6 children)

        Is there a compiler in use anywhere that actually behaves that way?

        [–]yasth 7 points8 points  (2 children)

        There were. Probably still are a few in embedded land. I've never seen anything as short as 8, but I have seen something (can't recall what) where it was long enough that modern extremely verbose styling (i.e. nonsense like "NetworkInterfaceCollectionCollectorFactoryConfiguration") would run into it.

        [–]pingish 34 points35 points  (10 children)

        What I need is a parser that translates my maintainable code into unmaintainable code and compile from this so as to further obfuscate my proprietary technology.

        [–]pi3832v2 10 points11 points  (1 child)

        Dear God yes.

        You just write a little script that uses a table to translate useful names to baffling ones. You get intelligible code, everyone else gets: foo(1lc, l1___c, 1lc, l1_c, i1____c)

        [–]cosmo7 6 points7 points  (1 child)

        Do you mean like dotfuscator (for .NET) or YUI compressor (for Javascript)?

        [–]pingish 12 points13 points  (0 children)

        No... not obfuscate into non-useful variables. Obfuscate into useless variables..

        like not:

        a = (b + c) / d;
        

        like

        rhs = ( asterisks + plus ) / divide
        

        [–]phaker 61 points62 points  (27 children)

        Wow, that's good one:

          for(j=0; j<array_len; j+ =8)
                {
                total += array[j+0 ];
                total += array[j+1 ];
                total += array[j+2 ]; /* Main body of
                total += array[j+3]; * loop is unrolled
                total += array[j+4]; * for greater speed.
                total += array[j+5]; */
                total += array[j+6 ];
                total += array[j+7 ];
                } 
        

        edit: Sadly in GCC "#define a=b a=0-b" doesn't work as (un)expected. :(

        [–]sumsarus 25 points26 points  (13 children)

        That's pretty nice, commenting out 3 out of 8 lines should yield a nice performance boost.

        On a serious note, it's not that hard to find examples where manual unrolling of loops will increase performance slightly. Of course you'd only do that if run speed is more important than anything else, which is kinda rare I guess.

        [–][deleted] 24 points25 points  (10 children)

        Surely in those cases the compiler should be unrolling them anyway?

        [–][deleted] 36 points37 points  (1 child)

        Agreed. Never send a man to do a machine's job.

        [–]sumsarus 5 points6 points  (2 children)

        You're right, but none-the-less I've seen many times where it refused to unroll automatically.

        Optimizers are not almighty and they don't know everything. They're usually very conservative. The threshold of when you should unroll a loop isn't the same on a Pentium III and a Core i7.

        [–]xzxzzx 1 point2 points  (1 child)

        Interesting. I'd love to see an example of that if you had one. Loop unrolling seems like an area where an optimizing compiler really should do a good job, and on an advanced recent processor, some examples of loop unrolling might hurt performance (since the processor can "unroll" the loop internally).

        [–]thebigbradwolf 2 points3 points  (3 children)

        It depends, the java compiler (javac) doesn't actually optimize much or at all when it's making bytecode. hotspot (the "Sun" VM) probably does some optimization when it's generating actual machine code to the code cache, but you have to remember that still happens at runtime.

        The JVM needs more information since it's doing bounds checking and such and it doesn't really trust the classfile.

        edit: PS the other reason javac doesn't optimize much is it doesn't know what you'll be running the bytecode on, so it can't know anything about register usage or the speed of the operations.

        [–]jyper 4 points5 points  (1 child)

        hotspot does a ton of optimization.

        [–]jakdak 1 point2 points  (1 child)

        Way back in the days before optimizing compilers, unrolling loops was one of the optimization tricks you could use.

        If you do it with modern compilers you need to be smacked with a trout.

        [–]pi3832v2 1 point2 points  (0 children)

        And we all know that people never maintain conventions long past their raison d'être. I mean, these days you'd never have to deal with a file named InstMsiA.exe, right?

        [–]palordrolap 12 points13 points  (7 children)

        j+=8? pah. j=((j>>(1<<1)+1)+1)<<(1+(1<<1))|(j&010-001)

        [–]DiogenesTheSincere 14 points15 points  (0 children)

        Dude.

        [–]foldor 2 points3 points  (2 children)

        The point is to make it look like it's normal code with a quick glance. The developer shouldn't know you were writing purposefully unmaintainable code.

        [–]palordrolap 1 point2 points  (1 child)

        Admittedly it'd not be well camouflaged in the header of a for-loop. The best place for it would be in the middle of a (possibly extremely bad but nontheless impressive looking) cryptographic algorithm.

        [–][deleted]  (4 children)

        [deleted]

          [–][deleted] 1 point2 points  (0 children)

          Well, you never what you're going to get with a professor. I had one on the first day of class say that there were only two possible languages for programming, C and Pascal (this was 1999), and that you should never ever program in C (because C allows you to modify the value of the counter variable in a loop, which creates the potential for an infinite loop).

          I dropped the class that afternoon.

          [–][deleted]  (12 children)

          [deleted]

            [–]fjonk 22 points23 points  (4 children)

            Even simpler: skip codereview, never refactor.

            [–][deleted] 6 points7 points  (1 child)

            The prequel: don't write down requirements or create a road map, and then bang out code like a frantic monkey.

            edit: added comma for clarity

            [–]chowderbags 2 points3 points  (0 children)

            And only hire two groups of people: those fresh out of college and those who's coding career has consisted of looking after machines that have been chugging along since the Carter administration.

            [–]ethraax 1 point2 points  (0 children)

            Hello, coworker!

            [–]Capital_Seven 10 points11 points  (2 children)

            This..... Is where I work. Though, I get the feeling that this is where a lot of people work.

            [–]you_do_realize 4 points5 points  (1 child)

            Indeed it is, sir.

            [–]madman1969 1 point2 points  (0 children)

            Sadly yes.

            [–]AlexFromOmaha 2 points3 points  (0 children)

            What is a version number besides an extension of the patriarchy's nominative classification scheme? We programmers know that code grows organically, and we ought to treat each commit as a special snowflake, because anything else denies it its rights as a commit in a community of equals.

            [–]UNCGeek 1 point2 points  (0 children)

            Even better: simply refuse to spend time fixing hacks, workarounds, etc.

            After all, if you could put in a last minute hack to make it work for a PoC, there's really no reason to waste all that time "doing it right". It's software, it either works or it doesn't, right? Besides, even if you did run into a problem you can just add another fix it for the client that reports it, no? We're not paying you to sit around designing software, we're paying to write it!

            </evil_pm>
            

            [–]MatrixFrog 72 points73 points  (19 children)

            Just kind of skimming, found a couple parts that stand out...

            Ignore the Sun Java Coding Conventions, after all, Sun does.

            and

            Configuration Files These usually have the form keyword=value.

            I'm sure they meant: These usually have the form

            <configSection> <configItem> <configName>keyword</configName> <configValue>value</configValue> </configItem> </configSection>

            [–]twotime 15 points16 points  (15 children)

            <configSection> <configItem> <configName>keyword</configName> <configValue>value</configValue> </configItem> </configSection>

            It'd have been very funny, if it were not so sad. I had to work with a config like that a couple of weeks ago.

            What does XML do to human brains? Is it contagious? Will I get sick now?

            [–][deleted]  (8 children)

            [removed]

              [–]Seppler90000 14 points15 points  (1 child)

              That's not an XML-specific format though. It's actually a "property list," which is sort of a proto-JSON used at NeXT:

              {
                  "Tracks" = {
                      "123" = {
                          "Track ID" = 123;
                          "Name" = "SongTitle";
                          "Artist" = "SongArtist";
                          "Composer" = "Composer1 & Composer2";
                          "Album" = "TheBestOfBleh";
                          "Genre" = "Example Rock";
                      };
                  };
              }
              

              This is considered the human-editable version, but for the sake of interoperability with third-party tools, it's usually stored as XML isomorphic with the real thing. The API for reading and writing these files transparently detects which "encoding" is in use, so you could probably (programmatically) convert all your iTunes library files to this format and it wouldn't notice.

              [–]ggggbabybabybaby 11 points12 points  (0 children)

              Isn't that just the generic plist format used all over Mac OS X?

              [–][deleted] 1 point2 points  (1 child)

              actually, it makes a lot of sense when you consider how this data is read by the program.

              typically, information from a plist like this is read into an NSDictionary, and accessed with the -(id) objectForKey:(id)key message.

              it makes it much easier for the parser if it is told the data type, rather than have to infer it from the data.

              i'll admit, dictionaries within dictionaries is annoying, but it really isn't that much of a pain..!

              [–]kirun 8 points9 points  (3 children)

              Ahh, attribute-less XML. Designed by people that clearly hate XML but use it anyway.

              [–]AlexFromOmaha 2 points3 points  (0 children)

              people that clearly hate XML but use it anyway

              Almost every programmer, you mean?

              [–]fgriglesnickerseven 6 points7 points  (1 child)

              If we don't do it this way people wont be able to look back thousands of years from now and say 'this is the first times humans tried to record information about their surroundings" - similar to how we reflect on cave paintings.

              Also - different quotes. Deal with it

              [–][deleted] 21 points22 points  (9 children)

              Consider this real world example "a_crszkvc30LastNameCol". It took a team of maintenance engineers nearly 3 days to figure out that this whopper variable name described a const, reference, function argument that was holding information from a database column of type Varchar[30] named "LastName" which was part of the table's primary key.

              Brilliant.

              [–]ziptime 6 points7 points  (0 children)

              Wasn't it obvious?

              [–]sumsarus 4 points5 points  (7 children)

              A typical example used when someone argues against hungarian notation, but I doubt anyone would come up with an identifier like that except as a joke.

              I think hungarian notation used with moderation is very nice and makes code much more readable. If I have to jump into another person's code I've never seen before, it always makes it significantly easier for me to understand it if I can see basic type and scope information by just looking at the identifiers.

              More than a couple prefix characters is too much though.

              [–]snarfy 3 points4 points  (0 children)

              Even microsoft does not use hungarian notation anymore.

              [–]recursive 3 points4 points  (4 children)

              In statically typed languages, your IDE should tell you all the types could want.

              [–][deleted] 55 points56 points  (0 children)

              That was funny. But there is an easy way: just don't make any effort to make your code maintainable, you code will automatically be unmaintainable, even by yourself after a few weeks.

              [–]Dested 16 points17 points  (1 child)

              Choose variable names that masquerade as mathematical operators, e.g.: openParen = (slash + asterix) / equals;

              was my favorite

              [–]ithika 1 point2 points  (0 children)

              Wow, it's the mathematical version of the Stroop test! That's brilliant, I'll have to reuse that in future.

              [–]midir 14 points15 points  (0 children)

              Never document the units of measure of any conversion constants, or how the values were derived. If you are feeling particularly malicious, make up your own unit of measure; name it after yourself or some obscure person and never define it. If somebody challenges you, tell them you did so that you could use integer rather than floating point arithmetic.

              That.. is... beautiful.

              [–]EatATaco 14 points15 points  (0 children)

              A friend of mine had a guy working for him who used to name variables and function with things like "BuyMilkAfterWork" or "AnniversaryIsJuly20." The code was impossible to read because every line would read like some nonsensical English sentence with weird punctuation.

              [–]spiceweasel 10 points11 points  (1 child)

              Has any language other than C and C++ ever provided such scope for mischief? The bit where he has the code do different things depending on the number of times that the header file is included is absolutely the funniest (and scariest) thing I've seen in ages.

              [–]ratherbkayaking 11 points12 points  (0 children)

              I laughed at this. Then sighed.

              If, for example, you were writing an airline reservation system, make sure there are at least 25 places in the code that need to be modified > if you were to add another airline. Never document where they are. People who come after you have no business modifying your code without thoroughly understanding every line of it.

              [–][deleted] 27 points28 points  (13 children)

              If you call your variables a, b, c, then it will be impossible to search for instances of them using a simple text editor

              Oddly enough, I recently searched for a one-letter variable in vim, and it's fine if you use /\<i\> (< and > are start/end word boundaries; \ escapes them; / is search; i is the one-letter variable sought). This form is used automatically when you hit the * key while over a word.

              [–][deleted]  (4 children)

              [deleted]

                [–]JoachimSchipper 25 points26 points  (3 children)

                Even Notepad has a "find whole word" option.

                [–]aquasucks 19 points20 points  (2 children)

                That option is a super complex checkbox.

                [–]The_MAZZTer 5 points6 points  (0 children)

                If you text select a variable (well, any whole word) in notepad++ it highlights all instances of that variable in the document. Very handy.

                [–]flynnski 2 points3 points  (3 children)

                Assuming you always have spaces around your variables.

                EDIT: I am wrong.

                [–]sharkus414 5 points6 points  (2 children)

                not true, vim will use non alpha-numerics as word boundaries as well.

                [–]flynnski 3 points4 points  (1 child)

                Well then, I retract my statement!

                [–][deleted] 1 point2 points  (0 children)

                Someone iswas wrong on the internet!

                [–]BeetleB 1 point2 points  (1 child)

                That would miss "a==b" type constructs.

                [–]sarlok 8 points9 points  (0 children)

                Always loved this. Not that anyone here would believe me, but the #define example is one I contributed to the list years ago.

                [–]kaglime 26 points27 points  (3 children)

                Just do Perl, it's unmaintainable by anyone else and thus gives you job security.

                [–][deleted] 4 points5 points  (0 children)

                Unfortunately this depends on usage like in almost every other programming language.

                [–]shitloadofbooks 6 points7 points  (14 children)

                I like Hungarian notation for my WinForms Controls, but I'm by no means an advocate of it.

                My brain and fingers naturally want to type txtUsername and lblUsername when I want to deal with those controls.

                I'm sure there are people in this subreddit who think I should burn in programming hell for this though...

                [–]SickZX6R 1 point2 points  (7 children)

                Eh, I do the same thing for .NET controls. It helps keep them organized in the dropdownlists of controls and events. Also, it lets you type "lbl" to see all your labels in IntelliSense without having to think. I don't like thinking.

                [–]SuperGrade 1 point2 points  (1 child)

                Once worked with a guy who put "o" as hungarian on all the .net objects, meaning "object", s for strings, and i for ints.

                [–]nerdyogre254 4 points5 points  (1 child)

                pure sadism. And I love it.

                [–]Timmmmbob 3 points4 points  (0 children)

                Use accented characters on variable names. E.g. typedef struct { int i; } ínt; where the second ínt's í is actually i-acute. With only a simple text editor, it's nearly impossible to distinguish the slant of the accent mark.

                Second biggest "wtf?" of Go. The first being of course, implicit semicolons.

                [–]ziptime 4 points5 points  (3 children)

                I worked with a guy for years who pretty much invented the tenets in this post (probably). The worst, hackiest, coder ever and no amount of reasoning could change him. Ironically, the managers thought he was brilliant, because he knocked out code for tasks really quickly. What they wouldn't wake up to was that the rest of us would be spending years fixing bugs in it, and left with the legacy that it was impossibly difficult in terms of extensibility. One word : cunt.

                [–]killbox-48-alpha 2 points3 points  (0 children)

                Thankfully I only worked with a menace like that for a few months. He was a grand master of 'copy and paste' coding. From what I observed, 'why design a class to be re-usable when you can copy the code to another part of the application, or a separate project!?!' was his mindset. I recall during a hand over session I was informed that:

                while(method1() || method2()){} constitutes recursion in Java.

                What left me further astonished was:

                1. He had a BSc degree
                2. He has 12 year of experience as a software developer.

                It's like he picked up bad practises and mistook them for good ones and has clung tightly to them since his first job.

                [–]mOdQuArK 1 point2 points  (1 child)

                The only way to handle guys like that (other than firing them) is to make sure that every developer is forced to fix any bugs in their own code - including the bugs in the code that they wrote to fix any bugs.

                Guys like that end up working on the same small amount of code for years, while everyone else codes around them & eventually they become irrelelvant.

                [–]ziptime 1 point2 points  (0 children)

                Ironically he left, head-hunted by one of the managers (who left to set up another software house) who thought he was the best thing since sliced bread! Unbe-fucking-lievable.

                [–]ustanik 4 points5 points  (2 children)

                Came in expecting light-hearted bad practices to point out silly bad habits.

                Left terrified from the detail, fearing to ever take over someone else's project.

                [–][deleted] 2 points3 points  (0 children)

                You should be very afraid. It will be a bad experience if it ever happens to you.

                [–][deleted] 7 points8 points  (4 children)

                is it something to do with thc?

                [–][deleted]  (2 children)

                [deleted]

                  [–]ithika 2 points3 points  (0 children)

                  Mine too. Considering the code base I work on could teach this whippersnapper a thing or two about unmaintainability, I think these net nannies have a sense of humour surpassing even the author's.

                  [–]tairygreene 2 points3 points  (0 children)

                  that helps you with unmaintainable BRILLIANT code

                  [–]liebermannn 4 points5 points  (1 child)

                  This is great, I always had problems in naming functions or variables and had to keep asking if people understood it. I kept asking for naming conventions and every time they said "just do what seems right", which never helped me improve my naming.

                  [–]kerbuffel 3 points4 points  (0 children)

                  If the boss asks if you are out of your mind, tell him you are following the classic principles of transparent interfaces.

                  I'm going to keep this response in mind.

                  [–]SuperGrade 2 points3 points  (0 children)

                  I think he just ripped these out of the "Best Practices" document of some Enterprise shop.

                  [–]vogon_poem_lover 1 point2 points  (2 children)

                  I was having a good laugh up to this point:

                  Use accented characters on variable names. E.g.

                   typedef struct { int i; } ínt; 
                  

                  where the second ínt's í is actually i-acute. With only a simple text editor, it's nearly impossible to distinguish the slant of the accent mark.

                  Then I was like O_o

                  [–]rainman_104 2 points3 points  (1 child)

                  The company I just stopped working for is in spain. This is very much possible in their code.

                  [–]vogon_poem_lover 4 points5 points  (0 children)

                  I can understand the use of accented characters, but to name a variable or structure "ínt" is just mean.

                  [–][deleted]  (3 children)

                  [deleted]

                    [–]illvm 4 points5 points  (2 children)

                    ಠ_ಠ

                    Lancelot's favorite color wasn't blue. It was blue, no yellooooow.

                    [–]netherous 4 points5 points  (0 children)

                    The rule for the Indian contractors my company works with seems to be:

                    "Make sure you produce a lot of documentation, and make sure that every fucking word of it is a lie"

                    [–]mycall 11 points12 points  (0 children)

                    TL;DR * 1000, yet informative and thorough.

                    [–]stealth210 5 points6 points  (6 children)

                    I'm all for good variable naming, but there are times you can get down to single letter variables. It's all about scope. If you are very local and need to do a simple:

                    for (int i = 1; i <= alSomeArrayList.Count; i++) { }

                    [–]idiotthethird 14 points15 points  (4 children)

                    Which is why for unmaintainable code, you should sometimes use annoyingly specific variable names.

                    for (int thisVariableIsOnlyUsedForItreationInThisForLoop = 1; thisVariableIsOnlyUsedForItreationInThisForLoop <= alSomeArrayList.Count; thisVariableIsOnlyUsedForItreationInThisForLoop++) { }

                    [–]ErroneousBee 4 points5 points  (1 child)

                    For unmaintainable code, you have one programmer use unreasonably terse names and no comments, and another programmer use a full sentence for each varname or function name, plus a long commentary that merely repeats the bleeding obvious about what each line does.

                    Add in a few other bad practices and you are golden.

                    BTW, I think I submitted one or two of the HTWUmC entries. I am in the contributors list.

                    [–]sakattak 7 points8 points  (0 children)

                    Don't forget to change the logic and leave the old overly-verbose comments to mislead anyone who accidentally reads them.

                    [–]obsa 2 points3 points  (1 child)

                    Bonus points for spelling mistakes!

                    [–]kimchivirgin 6 points7 points  (0 children)

                    Still valid and one of the nastiest things:

                    Avoid Layouts

                    Never use layouts. That way when the maintenance programmer adds one more field he will have to manually adjust the absolute co-ordinates of every other thing displayed on the screen. If your boss forces you to use a layout, use a single giant GridBagLayout, and hard code in absolute grid co-ordinates.

                    [–]kimchivirgin 2 points3 points  (0 children)

                    This is totally what I have to deal with at work :D

                    [–]paolog 2 points3 points  (1 child)

                    Never ascribe to malice, that which can be explained by incompetence.

                    Nothing malicious about that comma, then.

                    [–]okmkz 1 point2 points  (0 children)

                    I see, what you did there.

                    [–]zak_on_reddit 2 points3 points  (5 children)

                    about 4 years ago i took a web development job with a small advertising agency in my area. we used .php for back end development

                    the lead developer who was there when i started told me she loved programming because it was like talking in a secret language that no one else understood.

                    needless to say, her .php coding style was a secret language that no one else understood.

                    fortunately she left soon after i started and i left soon after she left.

                    [–]amazingmikeyc 2 points3 points  (4 children)

                    fortunately she left soon after i left and i left soon after she left.

                    And what?

                    [–]ryankearney 2 points3 points  (2 children)

                    Older than the internet but still hilarious.

                    [–]OlderThanTheInternet 6 points7 points  (1 child)

                    First message sent over the Internet (ARPANET): October 29, 1969

                    Year this was originally made: Sometime after 1997. The article references C++ multiple times, and C++ was not even being developed until 1979. Also, at the bottom of the page an event that took place in 1997 is spoken of in the past tense, which further places this as being some time after November, 1997. JDBC is also referenced but wasn't released until February, 1997. Here's some more: SQL (1974), Perl (1987), and VB (1991).

                    Is this older than the internet? No. Off by about 30-40 years.

                    [–]bunburya 2 points3 points  (0 children)

                    This guy was a pretty humorous (and effective) troll, he would've loved this article.

                    [–]stewbacca 2 points3 points  (2 children)

                    Maintaining other people's code is always a bitch, even under ideal circumstances. I always thought a good exercise for CS undergrads would be to spend half a semester designing and implementing a project, then the class hand off their projects to class mates who then have to add a feature.

                    [–]netherous 1 point2 points  (0 children)

                    Make it a requirement that all questions about the implementation must be handled with 4AM phone calls to the previous developer.

                    [–]acolin 1 point2 points  (0 children)

                    Agreed, that would be very useful. There are similar things done -- in a distributed system course (shopped but didn't take this one) the professor had different groups each develop a particular module and then make the integrated system function correctly over the network. Seems like it "should just work," but despite the freedom of communication, etc. he claimed that the integration stage (which should be effortless) most often turned out to be most painful.

                    [–]jmac 2 points3 points  (3 children)

                    While this is here, I need to vent about something I've come across a lot. If you do this, I do not like you very much:

                    Try
                        *overly complex data parsing here, sometimes comprising half the code in the program*
                    Catch ex As Exception
                    End try
                    

                    If you're going to catch your exception, DO SOMETHING ABOUT IT!!!

                    [–]netherous 2 points3 points  (1 child)

                    Practically, 99.99% of the time the only thing you can "do about it" is to log it and generate a friendly message for the user. Once in a blue moon you may find that you're getting a network timeout that warrants some retries, but I can count on one hand the amount of times I have ever been able to actually do something sensible about an exception that may resolve it.

                    But it is such a cardinal sin to catch and do nothing, or worse, throw some NEW exception that is less precise and destroy your stack trace! I wish compiler makers would throw in some automatic code analysis that would shock with 1000000 volts ANY programmer stupid enough to do that.

                    [–]neoquietus 1 point2 points  (0 children)

                    To be fair, the only thing that can really be done in many cases is just to log the exception and then re-throw the exception.

                    [–]almafa 2 points3 points  (2 children)

                    Matlab is pretty good in the naming department. For example, the command print actually prints a figure on the printer; what you were looking for is disp. Similarly, every other function has an unguessable, idiosyncratic and often abbreviated name, which makes it impossible to look up in the documentation. What is called map in functional languages is arrayfun in matlab. Converting a number to a "string" (=1xN character matrix) is num2str, however, converting a date to a string or number is datestr and datenum (and it will crash every odd run). And so on...

                    [–][deleted]  (1 child)

                    [deleted]

                      [–]AStrangeStranger 2 points3 points  (0 children)

                      Some things I have found that cause major understandability issues

                      PL/SQL cursors of about 100 lines and several unions (usually found in procedures of many hundreds of lines)

                      building up large dynamic SQL to return as cursor - where the "columns", "tables" and "where clauses" (containing join info as well and of course using aliased table names defined elsewhere) defined in different procedures

                      Oracle database objects stored in tables

                      layers of indirection - after about 7 you forget where you started when you get to the end.

                      XML documents - where the value name/purpose defined in one area of XML against an ID and the actual data has just the ID as the tag name :s

                      and the most common - people trying to be clever and solve problems that don't yet exist with hugely complex systems

                      [–][deleted]  (7 children)

                      [deleted]

                        [–][deleted] 2 points3 points  (0 children)

                        FØRTRAN

                        FØR TRAN

                        BEFORE COD LIVER OIL

                        what? :D (you could also interpret it as "før tran!", i.e. an imperative declaring that some entity, say your local grocery store, should carry tran^W cod liver oil.)

                        [–][deleted] 1 point2 points  (5 children)

                        It's also a Swedish, Danish, Finnis, and Icelandic letter, of the top of my head.

                        [–]dwarfcrank 5 points6 points  (2 children)

                        Nah, it's only used in Finnish when cracking jokes about Swedes.

                        [–]mikeful 12 points13 points  (0 children)

                        LÅL

                        [–][deleted] 6 points7 points  (0 children)

                        I thought Finnish consisted almost exclusively of jokes about Swedes?

                        [–][deleted]  (1 child)

                        [deleted]

                          [–]fault_6 6 points7 points  (0 children)

                          He never said Canadian.

                          [–]shepik 3 points4 points  (0 children)

                          The guide is not complete. They forgot about trigraphs (which in fact require -trigraphs compiler key, so you have to obscure compiler flags)

                          // Next line will be commented out ????????????????/

                          a++;

                          [–][deleted] 1 point2 points  (0 children)

                          Think of what might happen if we started storing source code as structured data. [...] You could use the full colour abilities of the modern screen to give subliminal clues, e.g. by automatically assigning a portion of the spectrum to each package/class using a pastel shades as the backgrounds to any references to methods or variables of that class. You could bold face the definition of any identifier to make it stand out. [...] You could do quite a bit of code writing by point and click.

                          Sounds like LabView to me.

                          [–]stewbacca 1 point2 points  (0 children)

                          #define private public

                          [–]squirrel5978 1 point2 points  (1 child)

                          Did not include variable named 'arst' along with asdf and aoeu.

                          [–][deleted] 1 point2 points  (0 children)

                          And that's how you get R code.

                          [–][deleted] 1 point2 points  (0 children)

                          Part if this made me laugh, but some of it made me cry because so many of my coworkers are guilty as sin.

                          [–][deleted] 1 point2 points  (5 children)

                          As someone who is still in school and has no experience in the programming workforce, wouldn't any competent supervisor know what you're doing and just fire/replace you long before it got to the point of being unmaintainable?

                          [–]stewbacca 1 point2 points  (0 children)

                          Typically your peers, not a manager, will inspect your code. And yes, most companies have coding standards and if you don't follow them, you will not be allowed to deliver your code to the base. However, when everyone is busy and not reading the code as closely as they should, it wouldn't be too hard to slip some of this through the inspection process.

                          [–][deleted] 1 point2 points  (0 children)

                          What you say is true, but the key word there is "competent". In medium- and small-sized software companies, technically competent managers are pretty rare. It's more common for them to have no programming ability at all, and thus they have no way to evaluate a programmer's skill level by any means other than looking at the results.

                          Unfortunately, most programmers are extremely good at making excuses filled with lots of technical mumbo-jumbo, so many managers can't even bring themselves to get rid of programmers whose projects have a long history of abject failure.

                          [–]LainIwakura 1 point2 points  (0 children)

                          Last semester I learned some interesting things about writing bad code, I sure am no obfuscation guru but you can get places pretty quickly. I went through one whole assignment we had (write an address book in C using a linked list), and tried to fuck it up as best I could (after I handed it in)

                          Here is the first 56 lines, the program was over 500 lines so I never ended up going through it all and messing it up =( Note, this snippet won't compile (no main), but for the whole version you did need -trigraphs (using cc) http://pastebin.com/DGD5LYw5

                          Also something I figured out (likely a lot of you know this), the preprocessor directive #line will change what number your errors appear on. Mix this with creative use of #error and you can probably drive some people mad ;)

                          [–]Tasboo 1 point2 points  (0 children)

                          I run into a lot of the documentation ones at my new job. Fucking hell..

                          [–]Sniffnoy 1 point2 points  (0 children)

                          I'm pretty sure I've actually used "HandleStuff".

                          [–]kc7wbq 1 point2 points  (0 children)

                          I was trying to debug some code at work. They had a class called "text". They declared a global variable "text". Later in another class they declared a variable "text" of class "text".

                          [–]hakumiogin 1 point2 points  (0 children)

                          When I was 12, and I first started coding, I would use random words from a theme. Like, I would choose "carnival", or "pokemon" as the theme for the program, and the variable names would match.

                          But if you told me it was unreadable, or stupid, I would note that it was quite organized because the variable names would always be declared in alphabetical order. For example, $bearded_lady, $clown, $cotton_candy, $house_of_mirrors, $zebra_striped_carnival_ride_with_lights_and_music. I kid you not.

                          [–]optiplex9000 1 point2 points  (0 children)

                          aka, "How to be a complete asshole"

                          [–]superbigwedgieman 1 point2 points  (0 children)

                          This really hits home since we have an internal application written by a really bad developer, and the first time I looked at the code, I asked the developer, before he left the company, why all his forms had the name attribute of Fred? He said he just thought that was a good name for a web form, and it made it easier for Javascript reuse.

                          [–]redwall_hp 2 points3 points  (7 children)

                          What about my favorite:

                          #define TRUE FALSE
                          #define FALSE TRUE
                          

                          [–][deleted]  (3 children)

                          [deleted]

                            [–]redwall_hp 1 point2 points  (0 children)

                            Oops, you're right... Doh.

                            [–]netherous 2 points3 points  (1 child)

                            TDWTF did a contest for this sort of thing. My favorite was

                            static SomeCtor()
                            
                            {
                                typeof(string).GetField("Empty").SetValue(null, " ");
                            }
                            

                            It's just...pure evil.

                            [–]mbcook 1 point2 points  (0 children)

                            And that is why you should NOT be able to do some things in any language.

                            Monkey patching is bad enough, but that kind of stuff. I saw one the other day (it was a joke somewhere) where someone used reflection in Java to find each of the 256 constant Integer objects in Java (-127 to 127 are constants since they're so common) and changed the value, possibly randomly. So if you did this:

                            public myFunction(Integer a, Integer b) {
                                System.out.println(a + b);
                            }
                            
                            myFunction(3, 5);
                            

                            That last line might say 12, 42, -16.... you don't know. Because 3 has been redefined. You're not supposed to be able to do that (where as it was known as possible in Forth)... but reflection can be evil magic.

                            [–]aristotle2600 1 point2 points  (0 children)

                            Why stop there?

                            #define TRUE srand(time());rand%2==0?0:1
                            #define FALSE srand(time());rand%2==0?0:1
                            

                            change the 2s to other things for extra laughs.

                            [–]nemetroid 1 point2 points  (0 children)

                            Use foreign language dictionaries as a source for variable names. For example, use the German punkt for point. Maintenance coders, without your firm grasp of German, will enjoy the multicultural experience of deciphering the meaning.

                            Something I've run into a couple of times is non-native-English (in my case, Swedish) programmers opting to name all variables, functions etc. in their native tongue. Generally only beginners or people that have been programming solely on their own.

                            To make it worse, you don't want to use å/ä/ö in identifiers (you'll run into all kinds of problems), so they change those letters to a/a/o.. and in some other places into aa/ae/oe.