<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 10 December 2013 12:32, H. S. Teoh <span dir="ltr"><<a href="mailto:hsteoh@quickfur.ath.cx" target="_blank">hsteoh@quickfur.ath.cx</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Dec 10, 2013 at 02:42:05AM +0100, deadalnix wrote:<br>
> On Sunday, 8 December 2013 at 05:37:09 UTC, H. S. Teoh wrote:<br>
> >Or maybe this is just another one of those cultural old age<br>
> >indicators?  Has the term "refactoring" shifted to mean "variable<br>
> >renaming" among the younger coders these days? Genuine question. I'm<br>
> >baffled that these two things could even remotely be considered<br>
> >similar things.<br>
> ><br>
><br>
> Refactoring is changing your code, without changing what it does. It<br>
> is done in order to make your code easier to understand, more<br>
> maintainable, more testable, or whatever.<br>
><br>
> Both extracting some code into a function and renaming a variable<br>
> are refactoring operations.<br>
<br>
</div></div>OK, but isn't renaming among the more trivial refactoring operations?<br>
Albeit, granted, it is probably also the most easily automated.<br>
Splitting an overly-long function into smaller pieces is a more<br>
meaningful (IMO) refactoring operation, but probably much more difficult<br>
to automate (if it even can be).<br></blockquote><div><br></div><div>It can be done. I use tools like this.</div><div>One of my favourites goes:</div><div><br></div><div>* highlight text</div><div>* click 'refactor' (or hotkey)</div>
<div>* type name for function</div><div><br></div><div>New function is produced containing the selected code. If the selected code was an expression, then the function is generated with a return statement and the appropriate return type.</div>
<div>If the selected code relied on any local variables, they are automatically added as function parameters. The call-site is updated with the new function call, and the local variables previously referenced passed to the function as arguments appropriately.</div>
<div><br></div><div>There's room for an extension to this tool which might scan for the same code throughout the project, and offer to replace the same pattern with calls to the new function, again, automatically filling out the function parameters.</div>
<div><br></div><div>This is only one of many useful tools that become available once tooling has a thorough semantic analysis library available.</div><div>It would be amazing if there was some real effort put into a convenient tooling API in the DMD front-end lib.</div>
</div></div></div>