Monday, December 20, 2004

Refactoring VB code

Refactoring in Smalltalk is very easy, especially since most Smalltalk
systems have a RefactoringBrowser included. Currently doing some work
in VisualBasic I had to refactor some VB code today.

Reorganizing a program in VB is really a pain:

1. you dont have simple browsers to see senders or implementors of
a function/sub (method)
2. there are no refactoring tools (except the text editors "Replace")
3. the VB syntax is not very refactoring friendly

Especially when you rename a function you have to take care to rename
the "return assignments" too. So in

Private Function Foo(aParam As Integer) As String
  If aParam = 1 Then
    Foo = "one"
  Else
    Foo = "more"
  End If
End Function

"Foo" has to be replaced three times with "Bar"

Private Function Bar(aParam As Integer) As String
  If aParam = 1 Then
    Bar = "one"
  Else
    Bar = "more"
  End If
End Function


In Smalltalk you just rename the signature of the method and you have
powerfull tools to look at all the senders and implementors. It's time
for BASIC vendors and programmers to look at Smalltalk IDE's.

No comments:

Post a Comment