/r/programminghorror
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
/r/programminghorror
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.
Is it better to cry before, during, or after you program? As as overachiever, I tried all three and then got really dehydrated.
Pointers are ... well ... convoluted.
Source video (credit): https://youtu.be/qclZUQYZTzg
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.
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
Help
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
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. :)
Thanks in advance! Question in title. Also the function name is self explanatory
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…