Hello all, These weeks I added new refactorings, following I will give some examples of them. 1. Create accessors with lazy initialization This refactoring create accessors for variables with lazy initialization, for example: - we have a class Object subclass: #SomeClass instanceVariableNames: 'stringVar' classVariableNames: '' package: 'Example' - we can create accessors with lazy initialization executing this script: (RBCreateAccessorsWithLazyInitializationForVariableRefactoring variable: #stringVar class: SomeClass classVariable: false defaultValue: '''example''') execute the result of this refactoring is: SomeClass >> stringVar ^ stringVar ifNil: [ stringVar := '' ] SomeClass >> stringVar: anObject stringVar := anObject 2. Extract setUp refactoring (is the first version by the moment, it need to be improved) This refactoring create a setUp method from a code fragment. You can select an interval of some code in a test method and call this refactoring to create a setUp method implementing that code and replace the code by nothing. The selected class need to be a subclass of TestCase. For example: - given a class TestCase subclass: #SomeTest instanceVariableNames: '' classVariableNames: '' package: 'Example' SomeTest >>testFoo self x. self assert: true SomeTest >> self x self doSomething - To extract setUp method you can execute this script: (RBExtractSetUpMethodRefactoring extract: (10 to: 16) from: #testFoo in: SomeTest) execute the result of this refactoring is: SomeTest >> setUp super setUp. self x. SomeTest >> testFoo self assert: true 3. Move method to class side refactoring (This refactoring is still awaiting review) This refactoring move a method to class side. For example: - given a method ClassX >> annotatedBlockMarkup ^ '@@' - we can execute the refactoring with this script: (RBMoveMethodToClassSideRefactoring method: (ClassX >> #annotatedBlockMarkup) class: ClassX) execute. the result of this refactoring is: ClassX >> annotatedBlockMarkup ^ self class annotatedBlockMarkup ClassX class >> annotatedBlockMarkup ^ '@@' Any suggestions or comment of these refactorings are welcome. I hope these new refactorings are useful to you . Regards, Evelyn C. |
Hi How does your "move method to class side" differ from the one already there? Best, Kasper |
Hi, The current move method to class side refactoring, doesn't correct the senders of this method, neither checks correctly references to instance variables or method calls (on instance side). At the moment this improvement only covers that method's senders won't break, creating a method on instance side with the same name referring to the method on side class, as shown in the example. - given a method ClassX >> annotatedBlockMarkup ^ '@@' the result of this refactoring is: ClassX >> annotatedBlockMarkup ^ self class annotatedBlockMarkup ClassX class >> annotatedBlockMarkup ^ '@@' I still need to improve, but it's a small advance that I wanted to show you to get feedback. Regards, Evelyn C. El lun, 8 feb 2021 a las 14:57, Kasper Osterbye (<[hidden email]>) escribió:
|
Evelyn - this is brillian stuff, I appreciate the work going into this to make it all better. Keep pushing on it. Tim On Mon, 8 Feb 2021, at 7:20 PM, Evelyn Cusi Lopez wrote:
|
In reply to this post by EVELYN CUSI LOPEZ
Thanks evelyn for the announce.
I will use it for the blog :)
-------------------------------------------- Stéphane Ducasse 03 59 35 87 52 Assistant: Aurore Dalle FAX 03 59 57 78 50 TEL 03 59 35 86 16 S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France |
Free forum by Nabble | Edit this page |