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.

  • kryptonianCodeMonkey@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    8 days 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.

  • deadbeef79000@lemmy.nz
    link
    fedilink
    arrow-up
    0
    ·
    8 days ago

    “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.

    • da_cow (she/her)@feddit.orgOP
      link
      fedilink
      arrow-up
      1
      ·
      8 days 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
    link
    fedilink
    arrow-up
    0
    arrow-down
    1
    ·
    8 days 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.