The Artima Developer Community
Sponsored Link

Agile Buzz Forum
New Refactorings for Smalltalk

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
New Refactorings for Smalltalk Posted: Jan 26, 2005 7:15 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: New Refactorings for Smalltalk
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From David Buck - Blog

Advertisement

Travis gives praise to the Refactoring Browser in his article A Tribute. I agree whole-heartedly with his comments and I too count the Refactoring Browser as the best thing to come to Smalltalk since it was released in 1980.

Travis asks whether there are any new refactorings that could be added to the RB. I can suggest several.

  • change multiple statements sending to anObject to be a series of cascades instead

self doThis.
self doThatWith: anObject.
self doSomeOtherThing.

becomes:

self
	doThis;
	doThatWith: anObject;
	doSomeOtherThing.

  • The converse - change cascades into statements.
  • Extract and push to super

initialize
   status := #started.
   responses := OrderedCollection new.
   objects := Dictionary new.
   running := true

Select the lines from "status:=" to the end of "Dictionary new." and select "Extract to super". Then, you get:

in Superclass:
initialize
   status := #started.
   responses := OrderedCollection new.
   objects := Dictionary new.

in original class:
initialize
   super initialize.
   running := true.

  • Move class between namespaces changing all references (this has been mentioned before)
  • Enclose selected code in "true ifTrue: [...original code...]". This allows you to change the condition later.
  • Invert logic

   (a not and: [b not]) ifTrue: [...]

Select the expression in the parentheses, and select "Invert logic". It changes to:

   (a or: [b]) not ifTrue: [...]

  • Change non-short-circuiting expressions to short-circuiting and back (possibly by doing it one message at time)

   (a & (b | c))

becomes:

   (a and: [b or: [c]])

  • Change "foo not ifTrue:" to "foo ifFalse:" and vice versa
  • Switch order of ifFalse:ifTrue to be ifTrue:ifFalse: and vice versa
  • Extract to class method

Those are a few ideas. If I think of others, I'll blog them.

Read: New Refactorings for Smalltalk

Topic: How To Create A Custom Widget - Starting The MacOSX Look Version Previous Topic   Next Topic Topic: Script vs. Script

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use