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.
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.
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.
Haskell also tends to have really small main functions, since the functional paradigm encourages splitting it up
“Hmmmm. This codebase seems surprisingly lightweight.”
Opens random ‘Helper’ class.
“Oh… Oh boy.”
main : IO () main = test allTestsNo OOP in sight: https://gitlab.com/bss03/grtt/-/blob/f760eb6f0c1f1b171a1a3a114e156f008e4227d0/grtt-machine/test/src/Main.idr
deleted by creator
You should post the code!
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.
Is it normal to need an account to view code on GitLab?
Unfortunately, yes
Script? Not library?
In my case it was a script, but for libraries this would hold true too.
i have been summoned
“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.
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.
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. 🥴
How it should be.
It’s a beautiful feeling when everything is nicely encapsulated.
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.





