A comparison table becomes dangerous when it produces a precise-looking answer for values that were never comparable.
I ran into this while implementing a Gear comparison view. Each item could expose base stats and inherent modifiers. Values could be flat numbers, percentages, or per-second rates. Either side could also omit a field entirely.
The tempting implementation was to join rows by the visible label and subtract right from left. That would have allowed a flat Attack Damage value to collide with an Attack Damage percentage, and it would have encouraged treating a missing value as zero.
The safer implementation turned out to be a small Map keyed by three pieces of semantic identity.
Model the comparison result explicitly
The result row needs to preserve more than two numbers:
type StatSource = "base" | "inherent";
interface ComparisonRow {
key: string;
label: string;
source: StatSource;
unit: "flat" | "percent" | "per-second";
left: number | null;
r
Discussion
Don’t hold back—comment!
Don’t wait—start sharing your ideas now!