Rename split-loop-with-lambda to slice-with-lambda
The refactoring is now published as Slice on sammancoaching.org: https://sammancoaching.org/refactorings/slice.html - git mv ideas/split-loop-with-lambda -> ideas/slice-with-lambda - rename learning-hour file and update frontmatter name - update paths in tools/rehearse scripts and report title - update prose: 'Split Loop with Lambda' -> 'Slice with Lambda' in learning hour, exercise READMEs, storyboard, solution comments - link the published Slice refactoring from the pattern draft
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 460" font-family="Helvetica, Arial, sans-serif">
|
||||
<defs>
|
||||
<marker id="arrR" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M0,0 L10,5 L0,10 z" fill="#dc2626"/>
|
||||
</marker>
|
||||
<marker id="arrG" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M0,0 L10,5 L0,10 z" fill="#475569"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="760" height="460" fill="#ffffff"/>
|
||||
<text x="24" y="34" font-size="20" font-weight="bold" fill="#0f172a">Inset — the overload: let the λ come from outside</text>
|
||||
<text x="24" y="56" font-size="13" fill="#475569">Add the λ as a parameter (Change Signature), drop the local. A no-arg overload bakes in the real λ — callers unchanged.</text>
|
||||
|
||||
<!-- left: no-arg overload -->
|
||||
<rect x="50" y="90" width="320" height="250" rx="10" fill="#f8fafc" stroke="#64748b" stroke-width="1.5"/>
|
||||
<text x="66" y="114" font-size="13" font-weight="bold" fill="#0f172a">longRangeForecast()</text>
|
||||
<text x="66" y="130" font-size="10" fill="#475569">no-arg overload — existing callers keep working</text>
|
||||
|
||||
<rect x="66" y="144" width="288" height="92" rx="8" fill="#faf5ff" stroke="#9333ea" stroke-width="1.5"/>
|
||||
<text x="80" y="166" font-size="11" font-family="Menlo, Consolas, monospace" font-weight="bold" fill="#9333ea">daysForward -> {</text>
|
||||
<text x="80" y="186" font-size="11" font-family="Menlo, Consolas, monospace" fill="#dc2626"> scorer.updateSelection();</text>
|
||||
<text x="80" y="206" font-size="11" font-family="Menlo, Consolas, monospace" fill="#dc2626"> return scorer.lookupWeather(days);</text>
|
||||
<text x="80" y="226" font-size="11" font-family="Menlo, Consolas, monospace" font-weight="bold" fill="#9333ea">}</text>
|
||||
|
||||
<text x="66" y="278" font-size="11" font-family="Menlo, Consolas, monospace" fill="#0f172a">return longRangeForecast(<tspan fill="#9333ea" font-weight="bold">λ</tspan>);</text>
|
||||
<text x="66" y="316" font-size="10" fill="#64748b">the "real" weather lambda lives here</text>
|
||||
|
||||
<!-- delegate arrow -->
|
||||
<line x1="374" y1="150" x2="424" y2="150" stroke="#475569" stroke-width="1.5" marker-end="url(#arrG)"/>
|
||||
<text x="376" y="140" font-size="10" fill="#475569">delegates</text>
|
||||
|
||||
<!-- right: the seam -->
|
||||
<rect x="430" y="90" width="300" height="250" rx="10" fill="#f8fafc" stroke="#64748b" stroke-width="1.5"/>
|
||||
<text x="446" y="114" font-size="12" font-weight="bold" fill="#0f172a">longRangeForecast(<tspan fill="#9333ea">λ</tspan>)</text>
|
||||
<text x="446" y="132" font-size="10" fill="#475569">the seam: weather is a parameter now</text>
|
||||
|
||||
<rect x="446" y="150" width="268" height="40" rx="8" fill="#ffffff" stroke="#475569" stroke-width="1"/>
|
||||
<text x="460" y="166" font-size="11" font-family="Menlo, Consolas, monospace" fill="#0f172a">expectedWeather =</text>
|
||||
<text x="460" y="182" font-size="11" font-family="Menlo, Consolas, monospace" fill="#0f172a"> collectExpectedWeather(<tspan fill="#9333ea" font-weight="bold">λ</tspan>)</text>
|
||||
|
||||
<rect x="446" y="206" width="268" height="40" rx="8" fill="#eef2ff" stroke="#818cf8"/>
|
||||
<text x="460" y="230" font-size="11" font-family="Menlo, Consolas, monospace" fill="#1e1b4b">reset loop: result.put(flavour, 0)</text>
|
||||
|
||||
<rect x="446" y="262" width="268" height="56" rx="8" fill="#eef2ff" stroke="#818cf8"/>
|
||||
<text x="460" y="284" font-size="11" font-family="Menlo, Consolas, monospace" fill="#1e1b4b">scoring loop: += 10 / +5 / +2</text>
|
||||
<text x="460" y="304" font-size="11" font-family="Menlo, Consolas, monospace" fill="#1e1b4b">return result;</text>
|
||||
|
||||
<!-- scorer still reachable from the no-arg overload only -->
|
||||
<rect x="80" y="380" width="180" height="56" rx="8" fill="#fef2f2" stroke="#dc2626" stroke-width="1.5"/>
|
||||
<text x="170" y="402" font-size="12" font-weight="bold" fill="#dc2626" text-anchor="middle">Scorer</text>
|
||||
<text x="170" y="422" font-size="10" fill="#7f1d1d" text-anchor="middle">only the no-arg overload knows it</text>
|
||||
<line x1="170" y1="378" x2="170" y2="346" stroke="#dc2626" stroke-width="1.5" stroke-dasharray="5 4" marker-end="url(#arrR)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
Reference in New Issue
Block a user