Updates
Latest Tweet
What's New?
Check out for latest innovation, a computer based training video collection
Like this Page
Microsoft ASP.NET Programming with Microsoft Visual C# .NET Version 2003 Step By Step Review by Brett W. Rogers
Someone should have proofread this book
As an ASP developer who has not used Visual Studio, I found the first chapters of this book very insightful. The author does a good job explaining ASP.NET and its differences with ASP coding.
But if there's one thing that I can't stand in a programming book, it's a lack of proofreading of the code given in the book and poor programming practices displayed. This book, unfortunately, has a lot of that.
An example (from page 216):
Label6.Text = "Final Balance: $" + CalcBalance(Convert.ToInt32(TextBox1.Text),
Convert.ToInt32(TextBox2.Text) / 100,
Convert.ToInt32(TextBox3.Text),
Convert.ToInt16(DropDownList1.SelectedItem.Value)).ToString();
private string CalculateBalance(int Principal, double Rate, int Years, int Period)
{
double result;
double NumToBeRaised = (1 + Rate + Period);
result = Principal * System.Math.Pow(NumToBeRaised, (Years * Period));
return(result.ToString("C"));
}
This is to be a Compound Interest Calculator.
If you enter this code, as given in the book, it won't run. There are several errors:
Error 1) In the calling procedure, it's CalcBalance. In the function, it's CalculateBalance.
Error 2) If you fix that oversight and run it, your result is the same as the given Principal. Why? Because the function calls for a double Rate variable, and yet the calling routine converts the Rate to an int variable. If you change "Convert.ToInt32(TextBox2.Text) / 100" to "Convert.ToDouble(TextBox2.Text) / 100", the result is correct - sort of...
Error 3) The result will be displayed as "$$67,537.12" instead of "$67,537.12". The reason for the double-$ is that the function converts the result to a currency string, but then the calling procedure adds an extra "$".
Fixing these three errors will solve the problems, but obviously no one tried this code before the book was published.
And a couple of picky points just because I'm so irritated with something so glaring as these errors.
Error 4) Since the function returns as a string, why then convert the result to a string in the calling procedure?? It's unnecessary.
Error 5) The code uses default naming of objects instead of taking 1 minute to give some meaningful names, like txtPrincipal instead of TextBox1.
Two stars for having no thought to the simplest details.