Wrox Home  

Topic: Visual Basic

Professional Refactoring in Visual Basic (0470179791) cover image

Professional Refactoring in Visual Basic

Danijel Arsenovski
ISBN: 978-0-470-17979-6
517 pages
April 2008
This title is out-of-print and not currently available for purchase from this site.

Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.

ChapterPageDetailsDatePrint Run
274 Error in Image
Image is not correct. It shows an object model, not a refactoring at work.
294 Error in Image
Image is not correct. It shows an app design, not a CRC card.
11 311-313 Error in Code Listing 11-5
ViewAccountDetails_Click routine in ViewAccount class should say:

Private Sub ViewAccountDetails_Click(ByVal sender As System.Object,_

ByVal e As System.EventArgs) Handles ViewAccountDetails.Click

Dim accountData As AccountData = New AccountData()

Dim account As Account = accountData.GetAccount(Me.Number.Text)

Me.Name.Text = account.Name

Me.Type.Text = account.Type.TypeName

If Not account.Blocked Then

Me.Balance.Text = account.Balance


Me.Balance.Text = "Blocked"

End If

End Sub

GetAccount routine in AccountData class should say:

Public Function GetAccount(ByVal number As String) As Account

Dim connection As IDbConnection = _

New SqlConnection(ConnectionString)

Dim adapter As IDbDataAdapter = New SqlDataAdapter

Dim accountDataSet As New DataSet

Dim command As IDbCommand = New SqlCommand

Dim strSql As String = "Select * from Accounts " + _

"where Name = " + number


command.Connection = connection

command.CommandText = strSql

adapter.SelectCommand = command



accountTable = accountDataSet.Tables.Item(0)

Dim accountRow As DataRow = _


Dim account As New Account( _

accountRow.Item("Number").ToString(), _

accountRow.Item("Name").ToString(), _

New AccountType(accountRow.Item("Type").ToString()), _

CDec(accountRow.Item("Balance")), _


Return account

End Function
15 447 Error in Code Listing 11-5
Sidebar ?Refactoring: Replace Complex VB Queries with LINQ? Before and After code sections should say:


Dim authorWithMostBooks As Author = Nothing

For Each author In authors

If authorWithMostBooks Is Nothing OrElse _

author.Books.Count > authorWithMostBooks.Books.Count Then

authorWithMostBooks = author

End If



Dim authorWithMostBooks = (From author In authors _

Order By author.Books.Count Descending _

Select author).First
Printer-Ready Version   Share This
With you wherever you go: pdf + ePub + kindle -- DRM-free