The code!!! It doesn't compile!!!

So I was looking at my latest book on Amazon and noticed it had a review.. Only 1 star.. Apparently 'Phoenix Guy' can't get the code to compile, and really there's nothing else to say.. (Although, if you read this 'Phoenix Guy', please stop using all caps..)

Now, I had a 1 star review on my last book too, so I'm not overly worried about that.  What I *am* worried about is the code not compiling for this guy..  Naturally, when I tried it, everything compiled (and worked) just fine for me.  Has anyone else who has my second book had an issue with it not compiling?  If so, where?  Unfortunately this guys 'review' doesn't give me any type of information I could use to try to 'fix' the issues (if they exist)..

Published 21 February 05 02:41 by tmiller
Filed under:

Comments

# Ian Smith said on February 21, 2005 3:33 PM:
Well I'm afraid I haven't read your book Tom but "code doesn't compile" is a pretty standard problem with most developer books these days, I've always assumed it's been because some poor typist has been trying to transcribe some listing she doesn't understand.

A certain publisher (their books were widely re(a)d ;-) used to be notorious for publishing code-based books full of errata that made "reading" them tortuous to say the least (which is partly why they went bust I guess!) One particularly expensive but slim "enterprise" book had so many errors in the code segments that I had a major whinge on Amazon about it. That whinge got me an ongoing correspondence with the author trying to sort out one problem after another before he admitted that problems I was getting were because of a "bug" in .Net that hadn't been there in the beta version of .Net the book had been written to (a fact not mentioned anywhere in the book itself). Funny thing is nobody offered me a refund for a book that was totally "type in the code" based and useless in the form it was released in. The eventual result of all my "free" advice and discussions was I was asked to be a technical reviewer for one of their other books (the second edition of a big fat book on C#) and as a result I soon realised why so many of these books were such a mess and why Amazon were giving these books great reviews when my experience indicated they were poor value-for-money.

As a "technical reviewer" I was given three chapters (all referring back to other chapters which I didn't have access to) to review! They were full of typo's (a real annoyance of mine because they indicate the general quality of the work put in) but was told NOT to submit any corrections because the publishing company had their own proof readers (riiiiiight! That's why all your books have so many illegible sentences in Mr Publisher!) I'm afraid I ignored that advice! I think I did a good job on the three chapters I had to review and caught a lot of errors - many of them technical errors.

When the book was published I got a "form letter" with my payment (Paid on a "per page" basis) which basically said I should feel I'd contributed to the high quality of the book and should therefore feel free to praise the book on Amazon if I felt proud of my work.

Needless to say I'm very wary of any Amazon reviews these days!

I'm impressed by your stance on the code though. Sounds like you care about your book and getting things right. Hopefully somebody who's read your book will give a more accurate review soon.
# Robert said on February 21, 2005 3:42 PM:
Too funny, "Phoenix Guy" has done several reviews, all are either one star or five stars. Never took caps lock off in any of them. Idiot.
# Fleeb said on February 21, 2005 5:31 PM:
Maybe he didn't have dxsdk installed?! Hehehe could be :D
# ISB said on February 21, 2005 6:32 PM:
mmh, well, i am kind of new on this MDX stuff, but what happened to me was that the code from the first book didn't compile with the newer SDKs, Summer 2003 SDK worked fine, but with December 2004 SDK I had to make some minor changes. Now I don't know if the examples from the second book don't compile with older MDX SDKs (Summer 2003). What I am trying to say, is that everything worked like a charm.
# Mr eZ said on February 21, 2005 11:27 PM:
I noticed errors as well with the december update, but anybody using the VS IDE and a little C# knowledge would pick up the changes that need to be made.
# Sandor Korozsi said on February 22, 2005 4:21 AM:
I think he has not read the instructions about which DXSDK version to use... It is a very idiotic and unhelpful review!
[I ordered two of your books from Amazon two weeks ago. One of them is your last book, the other is "Managed DirectX 9 Kick Start : Graphics and Game Programming". I really love that book. I had the honour to read some chapters from the kicks start book, and it was very helpful for me, so I decided to order your books. It should arrive in a couple of days. I'll check if it compiling or not, I promise. :) It would be helpful if somebody ports the samples for an other DXSDK version to compile, then could uploads it somewhere so other people can download it and try it on other SDK versions if they would like to. e.g. I have changed a couple of samples to compile on SDK which was released in december. But I had problems with one of the advanced mesh examples in chapter 7 which I didn't manage to port because I always get an exception if I execute it. :( It is possible (I hope) somebody else managed to do this, so we could help each other.]
# John Morales said on February 22, 2005 9:13 AM:
ISB, it's a bit more complicated. The book says it ships with the Summer SDK release, but the cd has the October release.

I was using the December release and it only failed on me when I got to the Frame.LoadHierarchyFromMesh (or whatever that method is, I'm not at home right now).

I had to back up to the October release.

Tom, what changed with this method? Is it a bug or a usage thing? I'm not worried if it's a bug, these things happen, but if the usage of this method is changing, that's something I would like to be aware of.
# Kasper said on February 22, 2005 9:45 AM:
Just ordered the book on amazon a few days ago, so i hope you are right :)

Anway, what I read in a review somewhere (sorry dont remember where, but i think it might be gamedev.net) is that some of the code has issues after one of the newer releases... guess December 2004 would be it as ISB wrote above. That seems likely, as the tutorials following that release had simmilar issues, the "Lights" tutorial amont others wouldnt compile.

Anyway, looking forward to reading the book and get my hands dirty.
- Kasper
# Glenn wilson (Mykre) said on February 22, 2005 12:17 PM:
I have the book, and it all compiles with out a problem. I have even started using the frame work for the second project in the book as a base for a project I am working on... The one thing that I did find though is that there are some diagrams that are missing, and in there place are the previous diagrams.
# hl said on February 22, 2005 4:07 PM:
I have both books and with Feb 2005 SDK installed. No problems with the second book's codes. The codes in the first book need to modify a little to work with new SDK, it's not hard to figure it out except the codes relate to the part of AllocateHierarchy derived class from chapter13.
# Russ C. said on February 23, 2005 3:28 AM:
I've not had a problem with the code either, but I retype all the examples from the book - for me using the CD for source code is cheating :)

Tom, can I direct your attention to this post I made on my blog ? (sorry to hijack :P )

http://dotnetjunkies.com/WebLog/russc/archive/2005/02/02/50264.aspx
# Nathan said on February 23, 2005 9:53 AM:
I have the book as well as Tom's previous one and have posted reviews for both of them. I've never had any trouble with the new book's code, but the previous one had a few issues b/c of changes made in DX9 after it was published. The majority of the changes were as easy as commenting out Lights.Commit() though, so it was not a big issue.
# Jeff said on February 24, 2005 6:48 PM:
Just wanted to say keep writing. Your books are the best MDX books out there (out of the few that exist), and the more we have, the better.
# Ernest said on February 24, 2005 9:24 PM:
Waiting for this book from Amazon for 4 weeks now !!! I am in Australia, I guess its like on another planet or something :)
# t at workoutNOSPAMPLEASEgenius.com said on February 28, 2005 6:03 AM:
Ian Smith, interesting comments.

Tom, the teapot example in chapter 2 does not compile with the SDK on the cd.

You use a "device" variable of type Device without it being defined in OnCreateDevice and OnResetDevice().

The other use of "device", in OnFrameRender(), refers to an object passed as a parameter, and so doesn't need to be changed.

For anyone with the book wondering how to fix this problem, the solution is to wrap the offending code like this.

In OnResetDevice:

using (Device device = e.Device)
{
// Setup lights
device.Lights[0].DiffuseColor = new ColorValue(1.0f,1.0f,1.0f, 1.0f);

/* ... */
device.Lights[0].Enabled = true;
}

In OnCreateDevice:

using (Device device = e.Device)
{
teapotMesh = Mesh.Teapot(device);
/* ... (only the above line strictly needs to be within the block) */

}

I think it would be a good idea to create an errata page somewhere, even if no entries are needed in it. (If such a page already exists, please let me know where it is.)
# Tenacious Me said on February 28, 2005 8:21 AM:
Well, when I started reading the book I thought that the CD would contain the code in C# as well as in VB.NET. On page 7 it even says: "The text of the book will cover the C# code, but the accompanying CD will include the code in each language". However, the CD that came with my book only contains C# code. I don´t own Visual C# so this was kind of a problem to me. Anyway, I managed to compile the sample framework into a DLL using sharpdevelop that I can use in my projects. Currently I am working on the GUI part and have not had any problems translating the code in the book into VB.NET, however, I am dissapointed since the CD should contain VB code too...
# Jaime said on March 1, 2005 3:54 AM:
yeah the teapot example was the first snag I hit but if you read some of the dx documentation and install the managed dx tutorials that come with it you can figure it out.
# Greg said on March 2, 2005 2:36 PM:
Hi Tom, I've had some problems as well. All pretty minor. The only major one I've run into is the CD doesn't seem to have the ".x" files (such as road.x) for the sample game. Is there somewhere I can go get them?

GregTilford@email.com
# Chordless said on March 8, 2005 10:45 AM:
I got the book a couple of weeks ago, and today i finally started reading, typing in all code along the way.

"t" has already pointed out the e.Device error, but i noticed that figure 2.1(page 27) is the same as figure 1.5(page 19 - modeling a spaceship in maya), while the text suggests that figure 2.1 should be a high-level object diagram for the blockers game.

Is there someplace else we can report such errors, or do you want us to keep filling your feedback with errata? =)
# Jo Mama said on March 9, 2005 10:00 AM:
I haven't had any problems compiling the code. But when I run (for example) the Go Kart racing example in release mode, The background sprite (or possibly the texture) doesn't render. In debug mode, it works fine. I tried this with October release and now have December and still no luck. I thought it was perhaps the GC collecting something early (this can be why debug and release are different), but I display the IsDesposed (or whatever it is) property of the sprite and texture and they both say false. I am trying to use this framework for a game of mine but if I can't get a background to display, I'm hosed. Anyone?

By the way Tom, best books out there. Have them both and love them.
# Travis Owens said on March 10, 2005 10:09 AM:
I don't know what's worse... people who never comment on things they find wrong or annoying, or the people who comment (flame) without making a point or example.

When you really sit down and think about it, the people who make a short flame with no points or examples are worse than the people who keep their mouth shut because now you (Tom) is spenting human cycles wondering if there is a mistake, fingering through his book trying to find a mistake, and posting to his blog and all of us are commenting on it. That's a lot of man hours.

My best advice:

1. Nod your head and smile at compliments but realize they will only make your head swell so it's best to ignore them
2. Totally ignore flames that bash you without backing them up with facts or logic
3. Embrace those who tell you you're doing it all wrong, find out why they think so, and figure out if their difference is because their way is better, or it's because it's the way they have been doing it for X years.

Number 3 leads to a saying I tell people that I feel applies to everything I do.

"There are 3 ways to do something, the wrong way, the way that works, and the right way."

Most people do the 2nd because it works and it's quick, but if mankind did everything the way that "works", we would never advance as a race. It's those rare few that do things the right way that moves mankind forward.
# Huh said on March 10, 2005 12:15 PM:
It is unfortunate that this book doesn’t have the source code on the CD that you are supposed to type in. For a newbie, it really stinks to have to put up with stuff that doesn’t compile. And the book doesn’t have all the code in one place, it is spread out over many pages. And where is the errata? This is needed. Otherwise a lot of people are going to waste a lot of time, and some will burn out, and of course the blame for that will be at the author’s or publisher’s feet. Without all the source code on the CD, if you seem to be missing something you can try to figure out what it is, or try to read and read and see if it is in a sentence you missed.

I am still trying to figure out where the code for the definition of blockersEngine is. Does anyone know?
# Reece said on March 10, 2005 4:59 PM:
I was having a couple of problems with Chapter 4. The "Render Method" it refers to on page 59-60 actually means the "OnFrameRender method". I found blockersEngine definition by searching through the Sams Publishing folder in the Program Files folder for the text "blockersEngine". This didn't work for me yesterday and today. But then I did a test, and searched for the very common word for a .cs file, "void", and it also returned nothing. Then I searched the internet and found this:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;309173

and used regedit to fix XP so I could search .cs files

It turns out that in the Blockers folder in the above Sams Publishing directory is a file gameEngine.cs which is what I have needed all along to fill in what I could not get easily from the text.

Back on track.
# Nathan said on March 13, 2005 10:42 AM:
Tom,

Just to update you as i've played around with the book's source code some more and have run into some errors but not until you start using Shaders in the later chapters. Apparently in the most recent DX SDK update, Effect.FromFile's method signature was changed and they added another string to what is required as input on all 3 variations of the method. All you have to do is put "null" for that new string and it works fine. The new string is located directly before the ShaderFlags parameter. Perhaps this is what the guy was having trouble with?
# dj said on March 14, 2005 5:02 AM:
General comment, not specific to Tom's new book which I just got but haven't seriously started to work through. I've had problems with redefinition of the Effects method (noted elsewhere) and (this is new to me) a difference in the arguments between December and February 2005 for Effect.FromStream () which caused old code which worked to generate a compile error. Shouldn't method overloading allow new features to be added without breaking old code?
# JOhn said on March 14, 2005 8:31 PM:
i have tried dec.2004 and feb.2005 sdk's.

I can't get the Simplified and Progressive Mesh examples to work It says reference to null pointer when i use the simplified mesh class, and suspect that before that where the mesh is cleaned may be where the problem is at.

Please help.

Then Chapter 13 animation demo won't work at the line of code application.run(frm1) says null variable

John,
norland@charter.net
# nelson laquet said on March 15, 2005 10:41 PM:
hey, i am having probs with the Tanker game... when i try and start a new game, it throws an exeption at line 97 on tank.cs... i dont know were to post this, so i will post it in this one becuse it was rather annoying when i tryed to play the coolest looking game, and it crashed ;(

besids that, great book!
# dj said on March 20, 2005 3:58 PM:
Book website on SAMS needs an errata, such as the correct Figure 2.1 on page 27 (for which a second copy of Figure 1.5 was mistakenly substituted).

Hope this isn't a bad omen. I'm only on page 28!
# Ezines and Web Magaizines » Tom Miller’s Blog : The code!!! It doesn’t compile!!! said on April 30, 2008 6:45 AM:

PingBack from http://ezinefrontpageblog.info/tom-millers-blog-the-code-it-doesnt-compile/

New Comments to this post are disabled
Page view tracker