{
  "id": 11356878,
  "title": "If someone might want it different, it should not be a literal",
  "url": "https://urgent.news/2026/10/02/if-someone-might-want-it-different-it-should-not-be-a-literal",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-02T04:30:08.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/idlecultivation/if-someone-might-want-it-different-it-should-not-be-a-literal-4h3m"
  },
  "original_language": "en",
  "account": "During the period from August 2, 2026, to August 6, 2026, a project established a rule for determining whether a value should be a setting or a literal in the code. The question guiding this decision is whether a reasonable person could want the value to be different without modifying the code. This principle applies to various aspects such as drop chances, cooldowns, discount rates, caps, page sizes, thresholds, feature switches, and numerous text elements.\n\nOne significant challenge identified was settings that were not being utilized. A tax on a transaction was once a properly configured setting yet remained unused, uncharged, and undetected in the code. The issue stems from the fact that the setting was present in the operator's list of changes but had no reader to enforce its application. To address this, a test was implemented to traverse all registered settings and flag those without a reader. This test proved effective in uncovering both real gaps and deliberate placeholders, which then required documentation.\n\nAnother common issue was the presence of duplicated constants. Developers would register a setting with its previous value as the default and then forget to remove the old constant. Consequently, the system would suffer from two sources of the same number. When the operator changed the setting, no changes occurred, leading to confusion and the erroneous conclusion that the system was broken. An example was a setting named after a discount, where the code applied its own value instead of the registered setting. Deleting the literal constant was essential to make the feature functional.\n\nA subtler issue involved settings that stored data differently. For instance, the purchasability of an item was stored as a flag on the item when the catalog was first created. The shop's stock list, however, was maintained separately. This discrepancy led to an item remaining purchasable even after it was removed from the shop, as the flag remained unchanged. Deriving the flag from the stock list rather than copying it at creation time resolved this issue by ensuring a single source of truth.\n\nThe project also addressed the challenge of offline defaults. Some settings needed to be accessible on the player's device, with the client requiring a floor for when no connection was available. Each of these values existed in two forms: one set by the operator and another compiled into the game as a minimum value. The two values had to be identical to prevent inconsistent behavior depending on whether a connection was present or not. A test was employed to ensure that the compiled floor matched the registered default, catching a subtler regression where the game would continue using the floor even if the value was no longer marked as client-accessible.\n\nCertain values, such as structural values, version markers on saved data, and formula shapes, were explicitly excluded from this rule. Structural values are not mere settings but represent different designs. Version markers and formula shapes are integral parts of the code and should not be treated as settings. The remaining values were identified as settings that developers should anticipate needing to adjust in the future, particularly during late-night debugging sessions. This approach has proven beneficial for the Idle Cultivation Game, ensuring clarity and maintainability in the codebase.",
  "summary": "Development covered 2 Aug 2026 to 6 Aug 2026 (commit dates). The rule this project has settled on is one question. Could somebody reasonably want this value different, without a code change? If yes, it is a setting, and a number sitting in a source file is a defect. That covers far more than it first sounds like: drop chances, cooldowns, discount rates, caps, page sizes, thresholds, feature…",
  "key_points": [
    "Rule established to determine if value should be setting or literal",
    "Identified unused settings, duplicated constants, and data discrepancies",
    "Implemented tests to flag settings without readers and ensure consistency"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}