<div dir="ltr">Hi Hilaire,<div> I think Joel's example isn't effective for understanding its impact on real code, it only shows how it works.</div><div> In a real-life example it is a very useful refactoring. By the way, you can decide not to use it and just apply the refactoring only to the selected code as before.</div><div> Joel, maybe you can explain more about that particular improvement of the extract method.</div><div><br></div><div> I take the time to congratulate Joel for this work, which is part of his master's thesis that he will be defending soon :-) Thanks Joel!!! </div><div><br></div><div>Cheers!</div><div>Hernan</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Jul 27, 2026 at 3:19 PM H. Fernandes via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Joel,<br>
<br>
I am wondering if it makes sense to allow such refactored code.<br>
For a human, the resulting code is more difficult to understand than the former one; at least for me.<br>
<br>
<br>
Dr. Geo -- <a href="http://gnu.org/s/dr-geo" rel="noreferrer" target="_blank">http://gnu.org/s/dr-geo</a><br>
<br>
----- Joel Camera via Cuis-dev &<a href="mailto:lt%3Bcuis-dev@lists.cuis.st" target="_blank">lt;cuis-dev@lists.cuis.st</a>&gt; a écrit :<br>
> Hi everyone,<br>
> <br>
> I wanted to share some improvements I made to the Extract Method<br>
> refactoring in Cuis. There are three main additions:<br>
> <br>
> *1. Support for assignments to temporary variables*<br>
> <br>
> Previously, if you tried to extract a fragment that assigned a temp var,<br>
> the refactoring would fail with an error. Now it handles several cases<br>
> automatically:<br>
> <br>
> - If the variable isn't used after the fragment, it just moves inside the<br>
> new method.<br>
> - If it's used after, the new method returns it and the call site assigns<br>
> it back.<br>
> - If multiple variables are assigned and all used afterwards, it uses an<br>
> "assignment block" pattern:<br>
> <br>
> *"Before:"*<br>
> process<br>
> | subtotal tax |<br>
> subtotal := self price.<br>
> tax := subtotal * self taxRate.<br>
> ^ subtotal + tax<br>
> <br>
> *"After extracting 'subtotal := self price. tax := subtotal * self<br>
> taxRate.':"*<br>
> process<br>
> | subtotal tax |<br>
> self computeAssigningWith: [ :newSubtotal :newTax |<br>
> subtotal := newSubtotal. tax := newTax. ].<br>
> ^ subtotal + tax<br>
> <br>
> computeAssigningWith: anAssignmentBlock<br>
> | subtotal tax |<br>
> subtotal := self price.<br>
> tax := subtotal * self taxRate.<br>
> ^ anAssignmentBlock value: subtotal value: tax<br>
> <br>
> *2. Support for non-local returns*<br>
> <br>
> Extracting fragments with a `^` also used to fail. Now:<br>
> <br>
> - A plain `^` in the fragment becomes the return of the new method.<br>
> - A `^` inside a block uses a "returning block" pattern so the non-local<br>
> return still works correctly:<br>
> <br>
> *"Before:"*<br>
> findFirst<br>
> self do: [:each | each isValid ifTrue: [^each]].<br>
> ^ nil<br>
> <br>
> *"After extracting 'self do: [...]':"*<br>
> findFirst<br>
> self findValidElementReturningWith: [:res | ^ res].<br>
> ^ nil<br>
> <br>
> findValidElementReturningWith: aReturningBlock<br>
> self do: [:each | each isValid ifTrue: [^ aReturningBlock value: each]].<br>
> <br>
> <br>
> *3. Parameterizable code detection*<br>
> <br>
> Extract Method now detects occurrences that are structurally similar to the<br>
> selected fragment but differ in some arguments — just like it already does<br>
> for equivalent code, it searches across the whole class hierarchy. When<br>
> found, a new window appears letting you decide whether to parametrize them:<br>
> <br>
> *"Before:"*<br>
> process<br>
> self foo: 10 bar: 'hello'.<br>
> self foo: 20 bar: 'hello'.<br>
> self foo: 10 bar: 'world'.<br>
> <br>
> *"After selecting 'self foo: 10 bar: ''hello''' and accepting<br>
> parametrization:"*<br>
> process<br>
> self m: 10 with: 'hello'.<br>
> self m: 20 with: 'hello'.<br>
> self m: 10 with: 'world'.<br>
> <br>
> m: aFoo with: aBar<br>
> self foo: aFoo bar: aBar<br>
> <br>
> All three improvements are already integrated into Cuis. Thanks Juan for<br>
> merging them!<br>
> <br>
> Happy to answer any questions!<br>
> <br>
> <<a href="https://10pines.com/" rel="noreferrer" target="_blank">https://10pines.com/</a>>Joel CámeraAgile Software Development<br>
> <br>
> Alem 896, Floor 6, Buenos Aires, Argentina<br>
> <br>
> +54 9 011 6091 3125<br>
<br>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-size:small"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px"><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal"><span style="font-weight:bold">Hernán Wilkinson</span><br>Agile Software Development, Teaching & Coaching</span></font></span></span></strong></span></div><div style="font-size:12.8px"><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">Phone: +54-011</span></font></span></span></strong></span><font face="tahoma, sans-serif" size="2">-4893-2057</font></div><div style="font-size:12.8px"><strong style="font-family:tahoma,sans-serif;font-size:xx-small"><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">Twitter: @HernanWilkinson</span></font></span></span></strong></div><div style="font-size:12.8px"><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">site: <a href="http://www.10pines.com/" style="color:rgb(17,65,112)" target="_blank">http://www.10Pines.com</a></span></font></span></span></strong></span></div><div style="font-size:12.8px"><font face="tahoma, sans-serif"><span style="border-collapse:collapse">Address: Alem 896</span></font>, Floor 6, Buenos Aires, Argentina</div></div></div></div></div></div></div></div>