Split generateSlide into per-slide-type serialisers (341 to 110 lines) #52

Merged
brenno merged 1 commit from refactor/split-generateslide into main 2026-06-30 17:41:13 +00:00
Owner

First refactor behind the method-length ratchet from #51.

generateSlide was a 341-line method: a switch over SlideType with a fat body per case. Each case body moves verbatim into a _writeXxxSlide helper in a new part (extension _MarkdownSerialize on MarkdownService), and the switch becomes a thin dispatcher.

Why this is safe

  • Exhaustiveness preserved. The switch still lists every SlideType case (each now a one-line call), so adding a new slide type still fails to compile until it is handled here — the compiler guard the slide-type checklist depends on stays intact.
  • Byte-identical output. The case bodies are unchanged, so the serialised markdown is exactly the same. The round-trip / fuzz / mutation suite — which serialises a deck, re-parses it, and compares — is the behavioural proof.

Result

  • generateSlide: 341 → 110 lines; its methodLengthBaseline entry is removed (now 27 baselined).
  • Main file stays well under the file-size ceiling (370 lines); the 16 serialisers live in the 296-line part.

Verification

  • flutter analyze --fatal-infos — clean
  • flutter test921 passed (incl. the markdown round-trip suite)
  • dart run tool/check_method_length.dart — green, 27 baselined
  • dart format — clean
First refactor behind the method-length ratchet from #51. `generateSlide` was a **341-line** method: a `switch` over `SlideType` with a fat body per case. Each case body moves **verbatim** into a `_writeXxxSlide` helper in a new part (`extension _MarkdownSerialize on MarkdownService`), and the switch becomes a thin dispatcher. ### Why this is safe - **Exhaustiveness preserved.** The switch still lists every `SlideType` case (each now a one-line call), so adding a new slide type still fails to compile until it is handled here — the compiler guard the slide-type checklist depends on stays intact. - **Byte-identical output.** The case bodies are unchanged, so the serialised markdown is exactly the same. The **round-trip / fuzz / mutation** suite — which serialises a deck, re-parses it, and compares — is the behavioural proof. ### Result - `generateSlide`: **341 → 110 lines**; its `methodLengthBaseline` entry is removed (now 27 baselined). - Main file stays well under the file-size ceiling (370 lines); the 16 serialisers live in the 296-line part. ### Verification - `flutter analyze --fatal-infos` — clean - `flutter test` — **921 passed** (incl. the markdown round-trip suite) - `dart run tool/check_method_length.dart` — green, 27 baselined - `dart format` — clean
Split generateSlide into per-slide-type serialisers (341 -> 110 lines)
Some checks failed
CI / Test (windows-latest) (push) Has been cancelled
CI / Gate (Linux) · Format · Analyze · Coverage (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Web hardening (push) Has been cancelled
CI / Docs links (push) Has been cancelled
CI / Gate (Linux) · Format · Analyze · Coverage (pull_request) Has been cancelled
CI / Test (macos-latest) (pull_request) Has been cancelled
CI / Test (windows-latest) (pull_request) Has been cancelled
CI / Web hardening (pull_request) Has been cancelled
CI / Docs links (pull_request) Has been cancelled
2afe669280
generateSlide was a 341-line method: a switch over SlideType with a fat
body per case. Each case body moves verbatim into a `_writeXxxSlide`
helper in a new part (extension _MarkdownSerialize on MarkdownService);
the switch becomes a thin dispatcher.

Crucially the switch still lists every SlideType case, so its exhaustiveness
is preserved — adding a new slide type still fails to compile until it is
handled here (the guard the slide-type checklist relies on). The case
bodies are unchanged, so the serialised markdown is byte-identical; the
round-trip/fuzz/mutation suite (which serialises then re-parses and
compares) is the proof.

generateSlide drops to 110 lines and leaves methodLengthBaseline (now 27
entries). First of the method-length refactors that follow the ratchet
in #51.
brenno merged commit afe6b652b9 into main 2026-06-30 17:41:13 +00:00
brenno deleted branch refactor/split-generateslide 2026-06-30 17:41:14 +00:00
Sign in to join this conversation.
No description provided.