/r/programminghorror

Photograph via snooOG

Share strange or straight-up awful code.

RULES:

  • All posts MUST show terrible code. There are no exceptions.

  • No Editor Themes - If it's just your editor that looks bad, it doesn't belong here.

  • No Advertisement Code. This is generally written by people in marketing who only know what "code" looks like from other ads. It's not real code, so it doesn't belong.

  • No Student Code. Yes, they're learning, but bad code is part of the process.

  • No Generated Code. If it's minified JS, generated XML, or what have you, we don't want it here. Yes, the YouTube homepage has an extra right-angle bracket. We know.

  • No Asking for Help. Go to r/learnprogramming. What are you doing here?

  • No Spamming/Advertising. We don't care about your shitty Youtube video or new crypto that will "change the world".

  • Be Nice. No hate speech of any kind is allowed, as well as generally being a jerk. Talk about the code, not eachother.

  • No Direct Contact of the Mods. Please use the modmail, we don't want to be contacted directly.

  • Please direct stories without code to /r/talesfromtechsupport, and programming questions to /r/learnprogramming

Programming Horror is where developers come together to revel in the idiocy of our peers.

This subreddit is meant for sharing funny programming related stories and strange or straight-up awful code.


For the sake of not being mauled by rabid lawyer bears, please make sure to anonymize your stories - changing the names of people and companies.

For code examples, indent all your lines with 4 spaces to make it more readable:

foo = 'bar'

Sister subreddits

  • talesfromtechsupport - Not everything that involves a computer is a programming horror story. For IT support related submissions, head on over here.
  • talesfromdesigners - For our more artistically inclined brothers and sisters.
  • badcode - When you don't have a story to go along with the horrible, horrible code.
  • shittyprogramming - ninjas that only write in the <b>BEST</b> code
  • usemysoftware - A subreddit for software developers to come post their software and for users to test it.

/r/programminghorror

346,725 Subscribers

108

My first GDscript game...rate how shitty it looks

31 Comments
2024/09/06
13:33 UTC

0

Fake open source projects in Github

17 Comments
2024/09/06
09:29 UTC

0

Requirements of entry level positions nowadays

Yesterday I got someone to show me an exercise requested from them to complete, within a day, in order to move to the next level of interview. This position is for entry level candidates, people who just finished their universities and wanna start a career. I remember when I started programming things where a lot simpler and faster, companies where willing to teach and invest in their new people.

Now I see this exercise requested, again for an entry level position, with 24 hours time limit.

"An organization has a need to create a membership management and booking system for its cultural and sporting activities. The information it wants to store for its members is Name, Email, Mobile Phone and Age.

The organization maintains various departments (Swimming Pool, Traditional Dances, CrossFit, etc.). Each department has its own schedule of days and hours (eg Monday 09:00-11:00 and 16:00-18:00, Tuesday 10:00-12:00, Wednesday 16:00-17:00). Each section has a maximum number of participants of 6 people. The organization also has 2 subscription packages. A package of 8 visits per month and a package of 15 visits per month. Each package is combined with the activity/section chosen by the member.

For example, a member may have (at the same time) an 8 visit package for the Swimming Pool and a 15 visit package for CrossFit. The member can choose which days and times of the department's program to participate in, based on their membership package.

The member can change the days and hours of the section he has chosen from a point of time onwards whenever he wishes. He can also change the day and time of his section, if there is a vacancy, to another day and time when a place is available.

Wanted:

Describe the basic classes/interfaces you would use to approach the solution/representation model of the above project.

What is requested is the illustration of the class model and not the full development of the system.

Focus on the classes and the relationships between them, on the "assigned" functionality that each class will perform in the overall system and on the "competencies", as well as on the basic characteristics (attributes / properties) that it will have."

Like, OOP exercise right of the bat, an one actually that is challenging even doing on paper for people. When I landed my first job this was something you would see after like months in training, and if I recall correctly the university curriculum only had like 1 subject regarding OOP and that was it.

Do really people and companies require this level of knowledge from people with zero working experience, that have just now started searching for a position? I am making this post because honestly I was a bit dumbfounded and disappointed, because if you set the bar this high, you are gonna 100% lose people and talents, and secondly, you are forcing everyone to use AI services in order to complete your asking test in the required amount of time.

The following is code created by ChatGPT regarding the specific test.

class Member: def __init__(self, name, email, phone, age): self.name = name self.email = email self.phone = phone self.age = age self.subscriptions = []

def add_subscription(self, package): self.subscriptions.append(package)
def book_schedule(self, department, date, time_slot):

def change_schedule(self, department, old_time_slot, new_time_slot):

class Department: def __init__(self, name): self.name = name self.schedules = []

def add_schedule(self, day, time_slot): self.schedules.append(Schedule(day, time_slot))
def get_available_time_slots(self): return [s for s in self.schedules if s.is_available()]

class Schedule: def __init__(self, day, time_slot, max_participants=6): self.day = day self.time_slot = time_slot self.max_participants = max_participants self.current_participants = []

def is_available(self): return len(self.current_participants) < self.max_participants
def add_participant(self, member): if self.is_available(): self.current_participants.append(member)

class SubscriptionPackage: def __init__(self, package_type, department): self.package_type = package_type self.department = department self.visits_left = 8

if package_type == "8 visits" else 15 def use_visit(self):
if self.visits_left > 0: self.visits_left -= 1
def has_visits_left(self): return self.visits_left > 0

class BookingSystem: def __init__(self): self.members = [] self.departments = []

def add_member(self, member): self.members.append(member)
def add_department(self, department): self.departments.append(department)
def book_member(self, member, department, day, time_slot):

And I truly can't comprehend people are now asking for students to be able to produce something like that, within a day, and be able to recreate it if needed while have all knowledge of how it's interconnections are working.

Either, the market has being filled to the neck with skilled people, and now only a selected few can actually compete for a position, or everyone has lost humanity and just search for already experienced people to hire in order to avoid spending time and money into shaping a new engineer.

Is this happening solely in my country or its a worldwide phenomenon? Because I had fresh people asking me for advice to land a job, and the only thing I could think of was "You should have started working while studying", and I couldn't believe it myself, that today someone needs working experience in order to be accepted in a job position that requires no work experience.

Is this the state we are at the moment in our markets?

P.S. I don't think people shouldn't try and make projects on their own and stuff, build a GitHub etc. I only state that for people that haven't even reach this part, those kinds of requirements are too much. The fact that you need to invest time for projects to showcase in order to even get noticed, after spend 4-6 years studying it's in my eyes truly unnecessary for a entry level position.

21 Comments
2024/09/06
09:00 UTC

75

This is not temp links

9 Comments
2024/09/05
09:06 UTC

40

Humor or contempt?

5 Comments
2024/09/04
18:44 UTC

225

Encoder code

52 Comments
2024/09/04
12:02 UTC

0

C++ needed an 'and' keyword

16 Comments
2024/09/03
18:56 UTC

77

For some reason my nutrition major requires web design... I have a quick question about work flow for any seasoned programmers in HTML.

Is it better to cry before, during, or after you program? As as overachiever, I tried all three and then got really dehydrated.

75 Comments
2024/09/03
07:43 UTC

244

200 iq move

11 Comments
2024/09/02
20:11 UTC

911

One reason to not learn C++

Pointers are ... well ... convoluted.

Source video (credit): https://youtu.be/qclZUQYZTzg

193 Comments
2024/09/02
18:50 UTC

1,167

My co-developer created a programming language and is migrating the project.

Me and my co-developer, let's call him James, have been working on an independant duolingo-like platform for endengared languaegs. We had a pretty solid system but James never really liked the fact that I used Firebase for the backend. He always said "we need our own backend" and I though nothing of it. Just wanted a stable demo to show people.

A month or so ago James disappeared claiming he is to "fix our issues".

When he returned, he had returned with a 145mb executable of a "compiler" that I can only assume was his Node app bundled in some way or another. He had also given me a 7,000 lines long file claiming it was "the documentation". With no syntax highlighting, my best bet was renaming the file to .js in order to get a bit of colour.

The programming lanague used what James described as "tags" to organise it's code which were just fancy objects.

public Tag main;

public function main.main(): void {
  println("hello world");
}

Everything had to have a tag, and I mean everything.

tag myint: int;

let myint.num = 1;

One good side might've been that one item could belong to multiple tags but even that was obscured behind some weird syntax. I still haven't figured out how multi-tags work so I'll just share his code example:

tag x: int;
tag y: int;

let tagsCluster(x, y).z = 5;
println(from(tags(get(x))).z); // 5

To keep it short, tags were a mess to work with and almost completely useless. But they were everywhere.

James also developed some form of manual memory management which I cannot comprehend as the code compiles to javascript. Everything is fine apart from the fact that the memory management uses a symbol that my keyboard does not have which is the "©" symbol.

// memory managamant is handlad by  the copyright © system
// after something is copyrighted, no one can use it.
public Tag main;
Tag ints: int;
Tag forloop: label;

public function main.main(): void {
  forloop.for (let ints.i = 0; ints.i < 10; ints.i++) {
    println(ints.i);
    i == 15 ? runner.run({
      println("i is 15");
      ©(i);
      break forloop.for;
    })
  }
}

James suggested we write the entire project in this obscure language of his. I'm currently trying to talk him out of it.

134 Comments
2024/09/01
08:35 UTC

43

Terrifying bug in the default flutter app that randomly popped out and scared the hell out of me

5 Comments
2024/08/31
15:18 UTC

786

if it works it works...

38 Comments
2024/08/31
14:11 UTC

258

my horrific way to deal with files in 8th grade

this was for real

for my defense: I learnt programing from a text tutorial, but it never really taught me to not use too many for and if statements, and one project was really big (making a mini version of git), so dealing with copying the files I just did whatever.

honestly I don't want to understand the code, I think it was for checking if a file is legit to copy and to copy it. anyways feel free to use this in compilations & stuff

25 Comments
2024/08/26
18:30 UTC

1,157

No or Yes

94 Comments
2024/08/23
11:05 UTC

146

This commit was pushed at 3:15am

45 Comments
2024/08/22
23:09 UTC

1,543

Some nice duality in JavaFX’s documentation

Help

49 Comments
2024/08/22
11:47 UTC

701

To maximise portability of code always use trigraphs (yes this compiles*)

53 Comments
2024/08/22
09:18 UTC

929

Undertale dialog system is one giant switch statement that goes on for 5k+ lines of code

108 Comments
2024/08/21
14:05 UTC

150

What in the enterprise code is this?

6 Comments
2024/08/21
09:01 UTC

0

Dumb turtle senior dev writes 2000 lines of code in one file.

This dumb turtle wrote 2000 lines of Python in one file, combined with streamlit, the vector store code, llm code, web crawler code, image gen code and all. Client says the UI looks terrible, so I get handed the entire project to convert it into a backend + react frontend.

I’m just a stupid lil Junior. And he’s supposed to be a senior dev. Why does he do this. Logic is repeated multiple times across the file. Why?

Help me for the love of god

24 Comments
2024/08/21
06:10 UTC

9

A really bad decompression routine in c

2 Comments
2024/08/21
05:28 UTC

178

I hate inheriting code. Or maybe I hate Machine Learning idiots. Maybe both.

33 Comments
2024/08/20
22:12 UTC

14

This took me 2 Days to write.. /!s

I hope this counts (feel free to delete this or inform me otherwise), it's a serious piece of Code and i literally spent 2 Days thinking about a problem that stopped my project from progressing, and the Code is part of the solution. :)

https://preview.redd.it/qnbr85ewjujd1.png?width=355&format=png&auto=webp&s=1197e3ec31066635e5e01e0ac7a3e16586aa69d4

19 Comments
2024/08/20
16:35 UTC

0

Shoud I focus more on writing clean code or is this fine?

Thanks in advance! Question in title. Also the function name is self explanatory

86 Comments
2024/08/20
14:32 UTC

269

The part of our data access layer that prevents me from updating it with generic typing

So yeah, we got a method that returns an Object, but that object is either a single object, a collection, or an Integer indicating a count, depending on which flag you pass into the method. Not sure whether this can be made generic without splitting it into three methods…

49 Comments
2024/08/20
12:48 UTC

15

my method to snap mouse position to hexagonal grid... surely gotta be an easier way?

3 Comments
2024/08/19
17:24 UTC

839

Someone turned on flake8 on build server without any filters. Someone else is not having it.

83 Comments
2024/08/19
02:39 UTC

Back To Top