Posts

Showing posts with the label State Management

Why a Dual-State Calculator Needs an Explicit Equals Button

A two-pane calculator looks simple: place calculator A next to calculator B and let both accept input. The difficult part is not drawing two keypads. It is deciding exactly which state a key is allowed to change, when an unfinished expression becomes a result, and what should be written to history. Twin Calculator uses an explicit equals button for each pane. It does not continuously evaluate both panes after every keystroke. That choice gives the user a clear commit point, keeps errors inside one calculator, and makes calculation history describe completed actions rather than every temporary input. The short version Each calculator owns its own entry, accumulator, pending operator, and error flag. A digit edits only the focused calculator. The equals action commits only that calculator's pending operation and creates one history record. The other pane remains untouched. Two displays are not enough If the implementation stores only two display strings, it cannot reliably ...