Code That Made Me Cry, #CTMMC™

95% of all code makes me cry. The other 5% are white space.

Talk Like a Robot (COBOL, #42 / 48)

PROCEDURE DIVISION.

   100-MAIN-PROCESS.
   OPEN INPUT STOCK-IN
        OUTPUT STOCK-OUT
   MOVE ST-TRANSACTION-INFORMATION TO ST-TRANSACTION-INFORMATION-OUT
   PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
       READ STOCK-IN
           AT END
               MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
           NOT AT END
               PERFORM 200-PROCEDURE-RTN
               ADD 1 TO RECORD-OUT
       END-READ
   END-PERFORM
   CLOSE STOCK-IN
         STOCK-OUT
   STOP RUN.

   200-PROCEDURE-RTN.
   IF RECORD-OUT = 4
       MOVE 'YES' TO IS-THIS-PAGE-FULL
       MOVE 0 TO RECORD-OUT
       MOVE 'NO ' TO IS-THIS-PAGE-FULL
       ADD 1 TO PAGE-OUT
   END-IF

   MULTIPLY ST-PURCHASE-PRICE BY ST-TRANSACTION-SHARES GIVING TOTAL-PURCHASE
   MULTIPLY ST-SALE-PRICE BY ST-TRANSACTION-SHARES GIVING TOTAL-SALE
   SUBTRACT TOTAL-PURCHASE FROM TOTAL-SALE GIVING TOTAL-PROFIT
   WRITE STOCK-RECORD-OUT.
        

Right. And I would add: AT END MOVE 'PIZZA' TO MY-HOUSE AND READ COBOL-CODE UNTIL MY-BRAIN = 'IS THIS HEALTHY?' I don't know, but these COBOL guys really like talking to the machine. They even prefer 'NO' and 'YES' instead of FALSE and TRUE!!! Martín Eduardo Proenza Arias found this answer by Luyao Tian on Stack Overflow

Source: http://stackoverflow.com/q/15801076/521799

comments powered by Disqus

Submit your own Code That Made You Cry

Send us your own example of code that made you cry! Please include:

Send the above to ctmmc@datageekery.com. All accepted submissions will be licensed as CC BY-SA 3.0. Submit only code of a compatible license.

Note that we may choose not to publish some submissions if we feel they're not appropriate. We hope you understand.

Don't let your SQL code make you cry!

Use jOOQ, instead of JDBC.

jOOQ generates Java code from your database and lets you build typesafe SQL queries through its fluent API.

Don't let your SQL code make you cry! Get back in control of your SQL with jOOQ.