Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

Keep rough size bands separate from measured area

The paving planner asks whether a project is small, medium, large or uncertain. It stores the answer as a label in the summary. That works for planning. Reusing a rough category as though it were an area would create an

The paving planner asks whether a project is small, medium, large or uncertain. It stores the answer as a label in the summary. That works for planning. Reusing a rough category as though it were an area would create an ambiguous value for any later takeoff or pricing logic.

Give a future contract distinct types

A measurement needs a unit and provenance. A size band needs a finite set of categories. Treating both as a number makes it easy to accidentally cast Medium to an invented area. The following is a proposed boundary type for a future measurement feature. The current planner has no measure-to-price calculation.

type Size =
  | { kind: 'band'; value: 'small' | 'medium' | 'large' | 'unknown' }
  | { kind: 'measured-area'; squareMetres: number };
function verifiedArea(size: Size): number | undefined {
  return size.kind === 'measured-area' ? size.squareMetres : undefined;
}

Test that a category stays a category

In the current UI, choose Driveway, Replace existing paving, Medium area and a time. Finish the brief and inspect Size in the summary. It should display the chosen band, without a numeric area or price. Then repeat with Not sure yet. The system should have no basis for substituting the same default area for either choice.

If a measured-area feature is implemented, validate positive finite values at the API boundary and reject a linear unit pasted into an area field. Test that documented conversions apply only when the source unit is known. Keep a future estimate separate from the draft brief so the UI can explain which user inputs actually support it.

In the summary, preserve the value exactly as entered or selected. A debug view for a proposed API can show provenance such as homeowner estimate versus confirmed site measure. Only the appropriate one should satisfy a later measured-area requirement.

Perth Quotes paving planner is the live preview. Online enquiries are closed.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.