[Cuis-dev] Extract method and select category refactor

Juan Vuletich juan at cuis.st
Tue Dec 10 06:57:43 PST 2024


On 12/7/2024 6:04 PM, Matías Waisman via Cuis-dev wrote:
>
> Hello everybody, happy Saturday!
>
> While using the Extract Method refactoring, I often found myself 
> wanting to move a newly extracted method to a different category most 
> times. It was quite tedious to first extract the method and then 
> manually create or select the target category. Sometimes, I even 
> forgot to move the method altogether. I realized it would be very 
> useful if the "Extract Method" refactoring also allowed the user to 
> specify the category for the extracted method as part of the process.
>
> The refactoring first prompts the user to name the method and its 
> parameters (as usual). Then, an additional prompt asks the user to 
> specify the target category for the new method. By default, it 
> suggests the current category where the extraction is taking place. If 
> the specified category does not already exist, it will be created, and 
> the method will be placed inside it.
>
> Initially, I thought the best way to implement this feature was to 
> enhance the existing Extract Method refactoring by adding the category 
> selection functionality. However, after telling my idea to Hernán 
> Wilkinson, he pointed out that it might not be ideal to force the user 
> to click an additional button during the process. Following his 
> advice, I implemented this as a new refactoring option that coexists 
> with the original Extract Method refactoring.
>
> The new refactoring is accessible via Cmd + Lor from the usual 
> refactoring menu.
>
> Since much of the functionality is shared with the existing 
> ExtractMethodApplierclass, I made some adjustments. Specifically, I 
> modified requestRefactoringParametersand 
> createExtractMethodNewMethodForto include the category as a parameter 
> in the class ExtractMethodAndSelectCategoryApplier.
>
> I also reorganized ExtractMethodApplierto serve as a superclass, with 
> two subclasses: ExtractMethodInSameCategoryApplierand 
> ExtractMethodAndSelectCategoryApplier. Each subclass defines the 
> specific parameters to request from the user during the refactoring 
> process. References to the original ExtractMethodApplierwere updated 
> to use ExtractMethodInSameCategoryApplier.
>
> Regarding the naming of the classes, I had some doubts. An alternative 
> naming could rename ExtractMethodApplier(the superclass) to 
> TransferCodeApplierand revert ExtractMethodInSameCategoryApplierto 
> simply ExtractMethodApplier. I’m open to suggestions on this!
>
> Any feedback or comments are appreciated, below is the change set.
>
>

Hi Matías,

Smalltalk and Cuis encourage appropriating the system to suit your needs.

But the main distribution of Cuis needs to keep a balance between 
personal preferences of users and overall system complexity. Otherwise 
Cuis would become the (theoretical set) union of all their users 
preferences, and this doesn't scale.

I suggest keeping this separated from the standard Cuis image, either as 
a package file or as a change set.

Thanks,

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20241210/db18e50f/attachment-0001.htm>


More information about the Cuis-dev mailing list