Live data from Hacker News

The worst program I ever worked on

jacquesmattheij.com

61–70 of 136 posts

Re: The worst program I ever worked on

#61
code from a 150 line long method which is part of a 6000 line class. Obviously I can't post the actual code on here (but what it is doing isn't important in this context).

   private XXXXXXXXXXX XXXXXXXXXXX(final XXXXXXXXXXX[] XXXXXXXXXXX, final int XXXXXXXXXXX,
          final Long XXXXXXXXXXX, final Long XXXXXXXXXXX, final int XXXXXXXXXXX, final Long XXXXXXXXXXX,
          final XXXXXXXXXXX XXXXXXXXXXX, final int XXXXXXXXXXX, final int XXXXXXXXXXX, final Long XXXXXXXXXXX,
          final XXXXXXXXXXX XXXXXXXXXXX) {
   
         if (XXXXXXXXXXX || XXXXXXXXXXX) {
            XXXXXXXXXXX
            return null;
         }
   
         final XXXXXXXXXXX
         if (XXXXXXXXXXX) {
            XXXXXXXXXXX
            return null;
         }
   
         XXXXXXXXXXX

      if (XXXXXXXXXXX) {

         XXXXXXXXXXX
         XXXXXXXXXXX

         final XXXXXXXXXXX
         final XXXXXXXXXXX
         if (XXXXXXXXXXX {
            for (XXXXXXXXXXX) {
               final XXXXXXXXXXX
               final XXXXXXXXXXX
               if (XXXXXXXXXXX) {
                  if (XXXXXXXXXXX) {
                     if (XXXXXXXXXXX || XXXXXXXXXXX) {
                        if (XXXXXXXXXXX || XXXXXXXXXXX)
                            || XXXXXXXXXXX)) {
                           final XXXXXXXXXXX
                           if (XXXXXXXXXXX) {
                              if (XXXXXXXXXXX) {
                                 final XXXXXXXXXXX
                                 if (XXXXXXXXXXX) {
                                    int XXXXXXXXXXX
                                    if (XXXXXXXXXXX) {
                                       if (XXXXXXXXXXX) {
                                          XXXXXXXXXXX
                                       }
                                       if (XXXXXXXXXXX) {
                                          XXXXXXXXXXX
                                          XXXXXXXXXXX
                                          XXXXXXXXXXX
                                          XXXXXXXXXXX
                                       }
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }

      } else {

         XXXXXXXXXXX
         XXXXXXXXXXX
         XXXXXXXXXXX
         XXXXXXXXXXX
         XXXXXXXXXXX

         final XXXXXXXXXXX
         final XXXXXXXXXXX
         
         if (XXXXXXXXXXX) {
            for (XXXXXXXXXXX) {
               final XXXXXXXXXXX
               final XXXXXXXXXXX
               if (XXXXXXXXXXX) {
                  if (XXXXXXXXXXX) {
                     if (XXXXXXXXXXX) {
                        if (XXXXXXXXXXX)
                            || XXXXXXXXXXX) {
                           final XXXXXXXXXXX
                           if (XXXXXXXXXXX) {
                              if (XXXXXXXXXXX) {
                                 final XXXXXXXXXXX
                                 if (XXXXXXXXXXX) {
                                    if (XXXXXXXXXXX) {
                                       final XXXXXXXXXXX
                                       if (XXXXXXXXXXX) {
                                          if (XXXXXXXXXXX) {
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                          }
                                       }
                                       final XXXXXXXXXXX
                                       if (XXXXXXXXXXX) {
                                          if (XXXXXXXXXXX) {
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                          }
                                       }
                                    } else {
                                       final XXXXXXXXXXX
                                       if (XXXXXXXXXXX) {
                                          if (XXXXXXXXXXX) {
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                          }
                                       }
                                       final XXXXXXXXXXX
                                       if (XXXXXXXXXXX) {
                                          if (XXXXXXXXXXX) {
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                             XXXXXXXXXXX
                                          }
                                       }
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }

      }

      if (XXXXXXXXXXX) {
         XXXXXXXXXXX
      }

      return XXXXXXXXXXX

   }

Re: The worst program I ever worked on

#62
post #40

Earlier quoted context omitted.

Yes, i remember working for a company (java devs) where at some point we ended up having wrappers around wrappers around wrappers delegating stuff around, factories of factories ... It made your head spin.

Yes. APIDelegatorInvocationHandler and APIAbstractFactoryFactoryProvider. (actual Java class names)

http://c2.com/cgi/wiki?PrematureAbstraction a known anti-pattern :)

Re: The worst program I ever worked on

#63
I'll summarize it by saying that one can have a lot of debugging 'fun' when you have to maintain code that starts including all kinds of other files in nested control structures which, in turn, reside in things like while-loops..

Re: The worst program I ever worked on

#64
I came across a similar thing in the mid 1990s. The program had been written in the late 1980s, and the original author had since died, so he couldn't be consulted. In those days memory was scarce, so the program had been "compacted" by removing all spaces and with all variables represented by single characters. The original non-compacted source code had disappeared along with its originator. For any practical purpose, the whole program was unreadable.

Re: The worst program I ever worked on

#65
You really don't know bad programming until you have spent some time in a 50000 line cobol program. I'd post some crap I work on every day but I don't want to make anyone cry. Nevermind. Here's some random code I'm working on.

             MOVE SPACES TO LISTBAT-NAME.
             STRING WORK-FILES "LIST.BAT" DELIMITED BY "  "
             INTO    LISTBAT-NAME.
             OPEN OUTPUT LISTBAT.
             MOVE SPACES TO SCR-S.
             STRING "DIR /B " DATA-PREFIX " > " 
             WORK-FILES "TMPLIST" DELIMITED BY "  " 
             INTO  SCR-S.
             MOVE SCR-S TO LISTBAT-REC.
             WRITE LISTBAT-REC.
             CLOSE LISTBAT.
             CALL "C$system" USING LISTBAT-NAME, 96 
             GIVING STATUS-VAL.
             MOVE SPACES TO TMPLIST-NAME.
             STRING WORK-FILES "TMPLIST" DELIMITED BY "  " 
             INTO  TMPLIST-NAME.
             OPEN INPUT TMPLIST.
             MOVE LOW-VALUE TO LIST-NAME.
             PERFORM UNTIL 1 = 2
             READ TMPLIST
             INTO SCR-S
                AT END EXIT PERFORM
             END-READ
             ADD 1 TO PROGRESS-REC-CT
             INSPECT SCR-S CONVERTING LOWER-CASE-ALPHA TO 
              UPPER-CASE-ALPHA
              PERFORM VARYING SCR-X FROM 50 BY -1 UNTIL 
              SCR-X = 1
              IF SCR-S(SCR-X:1) = "."
              MOVE SPACES TO SCR-S(SCR-X:)
              EXIT PERFORM
              END-IF
             END-PERFORM
             CALL "CC/STRINGER" USING SCR-S, STRING-INFO
             MOVE SCR-S(1:STRING-INFO-LENGTH) TO TMP-RID
             PERFORM LOAD-RPT-FILE THRU END-LOAD-RPT-FILE
             END-PERFORM.
             CLOSE TMPLIST.

The newline on some of those lines is off because HN makes it wrap but you get the idea

Re: The worst program I ever worked on

#66
post #30
post #16

Earlier quoted context omitted.

For the Chinese guy, I wonder if the code would have been way easy to maintain for the average Chinese developer. That would be an interesting analysis.

I once worked in a Chinese software company on the mainland and often maintained code written by Chinese developers. I'm Irish and didn't appreciate their comments in Chinese, they didn't appreciate my comments in Irish. Once that was understood we swapped quickly over to English for all comments / variables / declarations.

On that note, Python's style guide, PEP 8, contains this:

"Python coders from non-English speaking countries: please write your comments in English, unless you are 120% sure that the code will never be read by people who don't speak your language."

http://www.python.org/dev/peps/pep-0008/

Re: The worst program I ever worked on

#68
post #34

Earlier quoted context omitted.

I work with a guy, long time ago, who would take code already split into functions and refactor it into one big function. I am not joking here, actually happened.

I've seen that too. I don't think it was intentional -- the programmer simply didn't understand what the existing code structure was for, and "defactored" it.

Just think of all the function-call overhead he saved!

Re: The worst program I ever worked on

#69
post #56

One of my former classmates names everything he can get his hands on after various obscure anime references-- database names, variables, servers, you name it. Once in a blue moon, I'd recognize a function name as being a character or item from one of the few animes I'd seen and after a bit of tortured logic based on the background it almost seemed like a reasonable choice. Needless to say, he does better working on h…

I wonder if he read the Manga guide to databases:

http://www.amazon.com/Manga-Guide-Databases-Mana-Takahashi/d...

Re: The worst program I ever worked on

#70

A project I worked at during an internship had an unmanaged C++ portion for rendering complex typography, which was written when every letter in a variable cost $10 (or so it seems). The result was that "pointer to a metadata character" became the variable "pmc", and that was just the beginning of it. I never quite did understand what the variable lpmnoics meant, and debugging the C++ was quite the drag and the task…

That sort of thing is a lot easier to understand if you have the secret decoder key: http://www.joelonsoftware.com/articles/Wrong.html

But it's probably a defensible idea, in context. The idea is to supplement the type system of a low-level language with a manually-checked type system that helps you find semantic errors.

Post reply on HN