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,40 @@
|
||||
<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>
|
||||
</defs>
|
||||
<rect width="760" height="460" fill="#ffffff"/>
|
||||
<text x="24" y="34" font-size="20" font-weight="bold" fill="#0f172a">Step 2 — extract the dependency-using code into a lambda</text>
|
||||
<text x="24" y="56" font-size="13" fill="#dc2626" font-weight="bold">ALL of it goes inside — the static write too. The lambda is the adapter; it is not supposed to be pure.</text>
|
||||
|
||||
<!-- method -->
|
||||
<rect x="60" y="74" width="380" height="356" rx="10" fill="#f8fafc" stroke="#64748b" stroke-width="1.5"/>
|
||||
<text x="76" y="98" font-size="14" font-weight="bold" fill="#0f172a">printSalesForecasts()</text>
|
||||
|
||||
<!-- loop -->
|
||||
<rect x="80" y="184" width="340" height="152" rx="8" fill="#eef2ff" stroke="#818cf8"/>
|
||||
<text x="94" y="204" font-size="11" font-family="Menlo, Consolas, monospace" fill="#1e1b4b">for (String name : names)</text>
|
||||
|
||||
<!-- lambda -->
|
||||
<rect x="94" y="214" width="312" height="90" rx="8" fill="#faf5ff" stroke="#9333ea" stroke-width="1.5"/>
|
||||
<text x="106" y="236" font-size="12" font-weight="bold" fill="#9333ea">λ nameToSalesScore</text>
|
||||
<text x="106" y="258" font-size="11" font-family="Menlo, Consolas, monospace" fill="#dc2626">if (Steve) Scorer.flavour = Strawberry;</text>
|
||||
<text x="106" y="276" font-size="11" font-family="Menlo, Consolas, monospace" fill="#dc2626">else scorer.updateSelection();</text>
|
||||
<text x="106" y="294" font-size="11" font-family="Menlo, Consolas, monospace" fill="#dc2626">return scorer.getSalesForecast();</text>
|
||||
|
||||
<circle cx="90" cy="326" r="4" fill="#9333ea"/>
|
||||
<text x="102" y="330" font-size="11" font-family="Menlo, Consolas, monospace" font-weight="bold" fill="#6b21a8">println(name + " score: " + λ.apply(name));</text>
|
||||
|
||||
<text x="94" y="366" font-size="10" fill="#d97706" font-weight="bold">System.out.println stays in the loop — next time's split</text>
|
||||
<text x="94" y="414" font-size="10" fill="#64748b">names list lives above the loop, unchanged</text>
|
||||
|
||||
<!-- Scorer -->
|
||||
<rect x="580" y="200" width="150" height="100" rx="8" fill="#fef2f2" stroke="#dc2626" stroke-width="1.5"/>
|
||||
<text x="655" y="230" font-size="14" font-weight="bold" fill="#dc2626" text-anchor="middle">Scorer</text>
|
||||
<text x="655" y="250" font-size="11" fill="#7f1d1d" text-anchor="middle">static field + Random</text>
|
||||
<text x="655" y="268" font-size="11" fill="#7f1d1d" text-anchor="middle">both touches in the λ now</text>
|
||||
|
||||
<line x1="410" y1="250" x2="572" y2="234" stroke="#dc2626" stroke-width="1.5" stroke-dasharray="5 4" marker-end="url(#arrR)"/>
|
||||
<line x1="410" y1="288" x2="572" y2="262" stroke="#dc2626" stroke-width="1.5" stroke-dasharray="5 4" marker-end="url(#arrR)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
Reference in New Issue
Block a user