How to write misunderstandable code
oNodeFrom = oXMLDoc.SelectSingleNode("Accounts/Account[AccountNumber = '" & drpFromAccount.SelectedItem.Value.ToString & "']")
If CDbl(Regex.Replace(oGlobal.FindTag(oNodeFrom, "Amount", "0"), "\s+", "", RegexOptions.IgnoreCase)) < dAmount Then
...
End If
Just having to select a node in an XML document (a web page in this case), clean it up using a regular expression and then casting it to a double to get the disposable amount on the selected account makes me ill. What about something as simple as:
If accountBalance < amountToWithdraw Then
...
End If
which may be refactored to:
If account.Balance < accountTransfer.Amount Then
...
End If
and later on:
account.AddTransfer(...)
etc
etc
etc.
Sigh.








0 Comments:
Post a Comment
<< Home