Wiley.com
Print this page Share

Professional Refactoring in Visual Basic

ISBN: 978-0-470-17979-6
Paperback
517 pages
April 2008
Professional Refactoring in Visual Basic (0470179791) cover image
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.
08/29/08
294 Error in Image
Image is not correct. It shows an app design, not a CRC card.
08/29/08
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

Else

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

connection.Open()

command.Connection = connection

command.CommandText = strSql

adapter.SelectCommand = command

adapter.Fill(accountDataSet)

connection.Close()

accountTable = accountDataSet.Tables.Item(0)

Dim accountRow As DataRow = _

accountTable.Rows(0)

Dim account As New Account( _

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

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

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

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

CBool(accountRow.Item("Blocked")))

Return account

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

Before

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

Next

After

Dim authorWithMostBooks = (From author In authors _

Order By author.Books.Count Descending _

Select author).First
1/26/09

Related Titles

More By This Author

Visual Basic

by Evangelos Petroutsos
by Robert Martin, Ken Puls, Teresa Hennig
by Thearon Willis, Bryan Newsome
Back to Top