June 30th, 2006, 4:29 pm
Mayl brings us to a valid point.Is there a whole page of code in that book which you'd not be embarassed to have written ?I can imagine adopting a style that makes it clear to the reader that you are using a floating point value, not an integer. I have been personally bitten by the fact that VB and C++ treat constant literal arithmetic expressions differently.But in straight C++ code it's not clear why he did this unless he somehow feels that the compiler needs the extra zeroes to make sure that it gets the message ?Which of the voices in his head do you think picked 5 zeroes. Why not 6 ? Also what I find a little bizarre is why he writes things like (0.00000 - ( 1.00000/3.00000)) in so many places ?Not wrong as such of course, but it feels like he translated it from some other language. But I don't know of any that makes you do this, pssibly a defective dialect of SQL ?Does his next book contain ideas on how to do Monte Carlo in SQL or REXX ?He initialises constant though as if he knew what he doing.double x=0;Also what do you think he believesdouble B[20][20] = {0.0}; does ?Note the different number of decimal places.Also browsing this "code", I find he gives the impression of not knowing about references, and thus uses pointers more than people have done since the mid 90s.Again this is not wrong, though would get embarassing at a code review. Sometimes it means that he uses the slightly lessreadable XX-> syntax which is a bad choice for a book which is explaining how to do code.But it also impacts performance.On page 531 and other places he passes an vector by value, not reference, though it does hold pointers to an underyling object.The implication is that the voice in his head that screams "efficiency" in a bad Austin Power imitation genuinely thinks that it's fast because he's passing pointers, not the actual objects.Look at the udm function on p 528, (but not if you've just eaten).How redundant is that code ?Yet again it's (probably) not wrong but this time volume of code makes the routing harder to read. A decent optimiser would reduce it by about 50%, but that doesn't help the student.Of course I could be wrong, and he simply doesn't care how fast the code goes, but forcing the pointless creation and destruction of many vectors is not the sort of thing that you want to encourage.