Skip to content

refactor: replace program/target/ion magic numbers with named constants #114

Description

@grzanka

Part of #108 (health-review epic).

Problem

Several semantically meaningful thresholds appear as bare literals scattered across src/dedx.c and src/dedx_validate.c:

  • program >= 100 — the "analytical program" threshold (Bethe/default).
  • target > 99 — the "custom compound id" threshold.
  • ion > 120 / i < 112 — maximum atomic number / ion-table extent.

These are easy to get subtly wrong (note > 99 vs >= 100, and 112 vs 113 buffer sizing) and obscure intent.

Proposed change

Introduce documented named constants (e.g. DEDX_ANALYTICAL_PROGRAM_MIN, DEDX_COMPOUND_ID_MIN, DEDX_MAX_ELEMENT_Z) in a central internal header and use them everywhere the literals currently appear. No behavior change.

Acceptance criteria

  • The literals 100/99/120/112 used as these thresholds are replaced by named constants with explanatory comments at their definition.
  • No behavioral change — full ctest suite still passes.
  • A single source of truth defines the max-Z / table extent used for both the loop bound and any buffer sizing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions