<div dir="ltr"><div>Subject: Re: Extract Method improvements in Cuis<br><br>Hi Hilaire and Hernán,<br><br>Thank you both for the feedback, and thank you for the kind words, Hernán.<br><br>Hilaire, I understand your concern. The examples in my original email were deliberately small so that the mechanics of each improvement were visible, but I agree they were not the best for evaluating whether the resulting code is easier to understand in a real-world situation.<br><br>The main goal of the assignment block and returning block patterns is not to suggest that this form is always more readable. Their purpose is to make the Extract Method possible in cases where it previously failed completely — because the selected fragment contained assignments to temporary variables or non-local returns. Before these improvements, you would just get an error.<br><br>I looked carefully at how other environments handle this. Pharo and Squeak both attempt to extract fragments with assignments and returns, but produce incorrect results in several cases — wrong return values, unreachable code, or missing assignments in the caller — and some of those cases end in an exception. IntelliJ IDEA does better, and I studied it as part of this work, but it also has cases where the result isn't quite right since it lacks the full context. My goal was to get this right for Cuis, preserving the correct semantics in all cases I identified.<br><br>In simple cases, the generated code remains as straightforward as before. These patterns are only introduced when additional machinery is required to preserve the behavior of the original code, such as when several assigned variables are still needed by the caller, or when a return occurs from inside a nested block.<br><br>I agree that making a refactoring technically possible does not necessarily mean that applying it will improve the code. There is a trade-off between extracting the fragment and introducing additional indirection, and the developer still needs to evaluate whether the result is clearer in that particular context. The refactoring provides a valid transformation, but it does not force the developer to keep it.<br><br>The parameterizable code detection is separate from these two patterns. It only presents structurally similar occurrences as optional candidates, and the developer can review each one and decide whether introducing parameters actually improves the code.<br><br>I think the best way to see the impact is to use it on real code. With fewer restrictions, Extract Method will simply work in more situations than before — and the parameterizable detection will surface patterns that were previously invisible to the tool.<br><br>Best<br>Joel</div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><br></div><a href="https://10pines.com/" style="font-family:Roboto,Helvetica,Arial,sans-serif;font-size:medium" target="_blank"><img width="108" src="https://10pines.github.io/email-signature/10pines-firma@2x.png" style="margin-bottom:0.5em"></a><h1 style="margin:0px;font-size:14px"><font color="#999999">Joel Cámera</font></h1><h2 style="color:rgb(100,100,100);margin:0px 0px 1em;font-size:14px">Agile Software Development</h2><h1 style="margin:0px;font-size:14px"><font style="font-weight:normal" color="#666666"><p style="margin:0px;font-size:12px">Alem 896, Floor 6, Buenos Aires, Argentina</p><p style="margin:0px;font-size:12px">+54 9 011 6091 3125</p></font></h1></div></div></div><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">El mar, 28 jul 2026 a las 10:53, Hilaire Fernandes via Cuis-dev (<<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div bgcolor="#FFFFFF">
<p><font size="4">Hi Hernan, </font></p>
<p><font size="4">I got situations where method refactoring failed
because of the reasons mentioned in Joel work. However, the
resulting factored code in his example afraid me because of a
degradation in code understanding. I will test when such
opportunities arise again.</font></p>
<div>Le 27/07/2026 à 21:46, Hernán Wilkinson
a écrit :<br>
</div>
<blockquote type="cite">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>
</blockquote>
<pre cols="72">--
<a href="http://mamot.fr/@drgeo" target="_blank">http://mamot.fr/@drgeo</a></pre>
</div>
-- <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>