You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GH-74: Split the 164-line mapSingleObject() along its phases (#120)
* GH-74: Split mapSingleObject() along its four phases
The method ran a full pipeline in one body, its phases already marked by
comment blocks. It is now an orchestration that reads as the pipeline it
is - collect converted values, apply the unknown collector, report missing
properties, hydrate - with each phase in its own method.
The state the phases hand along - the converted values, the names actually
mapped, the diverted unknown keys - travels by return rather than by
shared locals, so each method's inputs and outputs are its signature. That
is also why collectConvertedValues() returns the unknown keys separately
for applyUnknownCollector() rather than merging inline: the merge is a
distinct phase, not a tail of the collection loop.
180 lines of body became a 31-line orchestration plus four named methods.
Behaviour-neutral: the whole suite was green before this commit's own
formatting pass. #72 and #73 had already removed the configuration round
trip and the per-element reflection this method used to carry, so what
remained split cleanly along the existing seams.
* GH-74: Fold the collector merge into the collect phase
The simplicity review pushed back on applyUnknownCollector() as its own
method, and the argument held: it re-read metadata->collectorProperty that
collectConvertedValues() already has as a local, and it forced that method
to return a third tuple element whose only purpose was to be handed
straight back for merging. The divert and the merge are two halves of one
concern - a key with no declared property is diverted during the loop and
the gathered keys merged after it - so they belong in one method.
collectConvertedValues() now does both and returns a two-tuple. The
orchestration drops to three phases, and the double read is gone. The
issue suggested applyUnknownCollector() as a phase name, but 'e.g.' - and
a single-caller method re-reading its own input is what KISS ranks below
keeping the concern whole.
Also trimmed per the review: the orchestration's lead comment no longer
narrates the refactor's history, and a docblock sentence that restated an
inline comment three lines down is gone.
0 commit comments