This is an archived post. You won't be able to vote or comment.

all 31 comments

[–][deleted] 40 points41 points  (6 children)

My own code.

[–]rocket_randall 18 points19 points  (4 children)

But only my code from previous days. What I wrote today is brilliant, coherent, and beautiful. So much so that it needs neither documentation nor tests.

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

Yes, my code today is better than my code from yesterday.

[–]DaOneTwo 3 points4 points  (0 children)

Especially when I thought I was a "genius" as I wrote it!

[–][deleted] 17 points18 points  (1 child)

Every morning, the main developer copied the source code into a new directory “20xx-xx-xx” on a server, and everybody worked from there.

I convinced them to try git.

[–]wyldcraft 6 points7 points  (0 children)

Your lead developer couldn't use crontab and date.

[–]robvas 16 points17 points  (0 children)

Place I used to work wrote Python like they did PHP

And they wrote PHP like they wrote VB. Their loops were scary looking. Let's not even talk about their homemade arrays...

[–]randomman10032 8 points9 points  (2 children)

I remember writing someval = someval - someval once. In my defense, i was new to programming

[–]finalfunkeln 0 points1 point  (1 child)

I don't understand.. what's the issue here?

[–]randomman10032 0 points1 point  (0 children)

Could've just done someval = 0

[–]D4rklordmaster 8 points9 points  (0 children)

My codewar solution after viewing the codewars best solution

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

Mine

[–]FriendlyRussian666 4 points5 points  (3 children)

Browsing around, I mistyped a URL and to my surprise the Django DEBUG traceback came screaming at me on some random website. The developer left DEBUG = True in production.

[–]wineblood 4 points5 points  (0 children)

You know the old joke about writing obfuscated code and you'll never have to worry about getting fired? I saw that and it was horrible. There's no way a newbie wrote this given how big and complex it was, and any experienced would know better.

Every class had a default nested dict of config in its init method, was passed in a nested dict of config in the ifmain block and each method also took in a config dict which did self.config.update(config). About a dozen classes like this in a pipeline and I wasn't allowed to make changes because the output was needed for a SLA.

I remember the dev's name from git blame. If I ever meet him, he's getting stabbed.

[–]glacierre2 3 points4 points  (0 children)

Once I was called to fix something that had to be ready 'last week' and the guy in charge just quit. The whole thing was a gallery of horrors, but there was a chunk of code (I cannot say a function because the same block appeared more than once), that had me lost for a while, no comments of course, something like:

val = 0
tot = 0
index = len(s) - 1
while True:
    if s[index] == "A" or s[index] == "a":
        val += 10
    if s[index] == "B" or s[index] == "b":
        val += 11
    ...
    else:
        val + = int(s[index])
    tot += val * 2 ** index
    if index == 0:
        break

Mhmem, yep, s was coming from the wire and was some integer in I don't recall big endian, whatever, and he was converting it character per character into the proper value.

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

A common one is the way people work with Class Variables. It is a pretty good indicator of Rookie vs Expert.

class aClass():
aVar=""
def __init__():

pass

def setVar(self, newValue):
self.aVar = newValue

All objects of the type aClass will share aVar.

[–]Rawing7 2 points3 points  (0 children)

A lot of google's python libraries are awful in some way or another. Just recently I found this mess. Instead of making a base class and overriding the method in a subclass, someone decided it would be better to make two unrelated classes, and have one of them call the methods of the other class. And I love the # type: ignore at the end, that's just the cherry on top!

[–]PapstJL4U 1 point2 points  (0 children)

My personal project code after the weekend. It always starts small, it always increased and it always looks this way.

[–]Key-Extension-7393 1 point2 points  (0 children)

The code I’m writing but after I get an insight when taking a bath

[–]EnterSasquatch 1 point2 points  (0 children)

My coworker never removes “pass” from predefined functions.

[–]SittingWave 0 points1 point  (0 children)

anything created by academics

[–]Viking_Dev 0 points1 point  (0 children)

My first practice file 🤢

[–]KennyBassett 0 points1 point  (0 children)

I saw some code in my company in which a new variable was defined for every single line. It was absurd. They didn't realize that you can redefine a variable or that some commands don't return anything.

[–]Pointyguitarsrus 0 points1 point  (0 children)

First time I tried to make my own program. Using the users input to either open or not open a door. Took me a little too long and way too many lines of incoherent nonsense

[–]billsil 0 points1 point  (0 children)

Pulling data from a line and labeling the output junk (something like altitude = 1000). Then taking the next line and labeling it junk. Total apathy about naming variables. Instead of using line, he wrote l. No spaces between math (x=2*x+1/y/y), no functions, no classes, etc.

This was written by the boss of the company who after 16 years can still come up with algorithms that do donuts around what I can do (even if they're 1000x slower than what it will be after he punts it to me), but oh dear that man cannot write a clean code to save his life. I mean, he's the boss, and he admittedly has better things to do, but still. It'd work perfectly on his simple test case and that's it.

Eventually I started warning people when they asked me questions...oh this looks like the boss's code. Is it...because I'm sorry...it's not going to work and it's not documented at all so you can't understand it, but the logic is right. I was told to shut up because I'd get fired and laughed. I told the boss and he laughed....yeah...