• Justin@lemmy.jlh.name
    link
    fedilink
    English
    arrow-up
    30
    ·
    edit-2
    7 months ago

    This is a really important principle of making APIs that people don’t really talk about. There’s a fine balance between hardcoded literals and full-gui options menu.

    Every piece of data in your program has a different level of configurability, and you need to make that trade-off to decide how hard or easy it should be to change. You could hardcode the data as a literal, or you could hoist it to the top of your source file as a const. You could have a separate static const configuration class, or you could have a runtime configuration file. You could even go for an interactive configuration editor/ options menu. It’s all a tradeoff based on offering your users choice but not overburdening them with it, as well as balancing development cost.

    • dustyData@lemmy.world
      link
      fedilink
      arrow-up
      10
      ·
      7 months ago

      I know it’s not always that straight forward. But that’s why it’s so important to pick sane defaults, and be very transparent in the documentation.

    • lysdexic@programming.dev
      link
      fedilink
      English
      arrow-up
      5
      ·
      7 months ago

      This is a really important principle of making APIs that people don’t really talk about. There’s a fine balance between hardcoded literals and full-gui options menu.

      I think this principle might fly under some people’s radar because it has been a solved problem for decades.

      Even Makefiles don’t require changes to the file to be configured. They take environment variables as input parameters, an approach that directly and indirectly permeated into high-level build systems. One example is the pervasive use of the VERBOSE flag.

      After all these years I only had to tweak build config files by hand when I wanted them to do something that they were not designed to do. All build tools I know don’t require it. The ones linked with IDEs already provide GUIs designed with this in mind.