this post was submitted on 22 Jan 2026
183 points (96.0% liked)

Programmer Humor

29982 readers
1329 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

It was literally like that. I had a script of about 310 lines and the main function was like 10-20 lines of code. I had a very nice Setup of objects that handled all functionality possible behaviours independent and so my main function was just receiving a user input from another function and add accordingly which included like 3-4 different scenarios that are being handled in the main function.

all 22 comments
sorted by: hot top controversial new old
[–] lwhjp@piefed.blahaj.zone 41 points 1 month ago (1 children)

It's a beautiful feeling when everything is nicely encapsulated.

[–] cows_are_underrated@feddit.org 9 points 1 month ago

Its also very nice, when you spend hours writing everything else and then once all of it has been tested you write a few lines of code in the main function and 10 minutes later everything works as it should.

"Hmmmm. This codebase seems surprisingly lightweight."

Opens random 'Helper' class.

"Oh... Oh boy."

[–] kryptonianCodeMonkey@lemmy.world 23 points 1 month ago

I mean... that is just good design. The main function should be the initializer and orchestrator of the logic. You should be able to look at the main function and tell, at a high level, what the program is doing. It should be usually pretty basic and procedural. Other functions handle the details and complexity.

[–] Ephera@lemmy.ml 15 points 1 month ago

Yeah, always found that weird as a junior. I basically never touched the main-function, because well, it set up some fundamentals and then called some other function or created some objects and then I was tweaking things somewhere below that.

Now that I'm a senior and taking over the lead of projects, I'm the person that touches the main-function and others generally do not. 🥴

[–] deadbeef79000@lemmy.nz 8 points 1 month ago* (last edited 1 month ago) (1 children)

"My Script" should be another dozen books the same thickness as main.

Not, I stress, for the sake of it, but for proper implementation of the suitable patterns for the application.

[–] cows_are_underrated@feddit.org 5 points 1 month ago

Well, it was really just a script that has exact one purpose. I just split it up beautifully, so that my main function is very short.

[–] bitcrafter@programming.dev 7 points 1 month ago

Just be wary of writing ravioli code which forces the person reading your script to have to constantly jump around it in order to figure out what is actually going on.

[–] bss03@infosec.pub 6 points 1 month ago (1 children)
[–] MonkderVierte@lemmy.zip 6 points 1 month ago (1 children)
[–] cows_are_underrated@feddit.org 4 points 1 month ago

In my case it was a script, but for libraries this would hold true too.

[–] KSPAtlas@sopuli.xyz 5 points 1 month ago

Haskell also tends to have really small main functions, since the functional paradigm encourages splitting it up

[–] andioop@programming.dev 4 points 1 month ago

i have been summoned

[–] victorz@lemmy.world 4 points 1 month ago

How it should be.

[–] seadoo@lemmy.world 3 points 1 month ago (1 children)
[–] cows_are_underrated@feddit.org 4 points 1 month ago* (last edited 1 month ago) (1 children)

Here you go: https://gitlab.com/foss9293204/southpark-downloader

Keep in mind, this is in production code that works in a testing environment, but is not ready yet. Theres also almost no documentation.

[–] bitcrafter@programming.dev 4 points 1 month ago (2 children)

Is it normal to need an account to view code on GitLab?

[–] mnemonicmonkeys@sh.itjust.works 3 points 1 month ago (1 children)
[–] bitcrafter@programming.dev 1 points 1 month ago (1 children)

Then sadly, the code shall remain a mystery for me.

[–] cows_are_underrated@feddit.org 2 points 1 month ago

See my other edited comment.

[–] cows_are_underrated@feddit.org 2 points 1 month ago* (last edited 1 month ago)

Idk, this is the first time I used gitlab in private (i literally just set up my personal gitlab account for this, since pastebin complained about some parts of the code).

Edit: It should be publically visible now: https://gitlab.com/Aipathon/southpark-downloader