Skip to article

Software engineeringExample

Business rules you can change without redeploying

Moving rates, thresholds and scales out of the code so the business can update them itself.

In calculation software, rates, thresholds and scales change more often than the code. If every change needs a developer and a deployment, the software falls behind the regulations. The fix is to move these values out of the code.

The problem

A hard-coded value, like an 18% rate, is simple at first. Then the finance act changes the rate, adds an exemption, creates a bracketed scale. Each change becomes a ticket, a review, a deployment, and a regression risk.

Describing parameters as data

Each parameter is stored in the database, with its type and validity period. The code reads the value in force on the calculation date instead of knowing it in advance.

ts
type Parameter = {
  code: string; // e.g. "VAT_STANDARD_RATE"
  value: number | { brackets: { upTo: number | null; rate: number }[] };
  start: string; // effective date, YYYY-MM-DD
  end: string | null; // null: still in force
  source: string; // text that sets the value
};

Versions and effective dates

A new value does not replace the old one: it is added with its effective date. An old file can then be recalculated with the rules of its time.

CodeValueStartEnd
VAT_STANDARD_RATE18%2020-01-01in force
REAL_REGIME_THRESHOLD50,000,0002021-01-012025-12-31
REAL_REGIME_THRESHOLD100,000,0002026-01-01in force

An interface for the business

An admin page lets experts view, create and schedule values without touching the code. Each change keeps its author, its date and the text that justifies it.

Testing with parameters

Tests load a dated set of parameters and check real cases: the same file, calculated before and after a change in the law, must give both expected results.

Share the article