So this marks the mid-way point for the book. 26 chapters, and I suppose, ideally, six months worth of programming. I’m going for broke and doing this in a much shorter time frame (partly because I have to, I need to be finished with Exercise 30 by the end of November. Remember when I first started talking about doing this? I made the ultimate in “bold boasts”; I tied my completion of this book to my annual performance review. What did we agree to? My completing up to Exercises 30 by the end of November and my completing the entire book by the end of January. Yes, it’s actually spelled out exactly like that in my review goals… and you thought blogging about it was pressure (LOL!).
I have mixed emotions about posting these entries. In part, I feel like I might be “cheating” others by giving a blow by blow of all this; they may just use my answers and say “Oh, cool, that’s how that works”, and miss the whole point of going through all of these steps and actually learning the material. Still, my point with the Practicum series is to show the techniques, critique the exercises, and give my own take on these materials as though I were teaching them to someone else. Thus, I guess I will need to leave it up to the reader as to how they want to work with this, and if they want to actually do things “The Hard Way” or cheat and do what they think is an “easy” approach to learning this stuff. “Thems will be that thems will be” (or something like that). Also, I try my best to put the code and my changes into pictures, not into text that can be copied and pasted, so I guess if they want my answer, they will have to type it out anyway :).
So for this section, we are asked to work through a quiz. the quiz is to fix someone else’s code and make it work. It’s common to deal with other programmers’ code. It’s also common to deal with their insularity and their belief that their code is “just fine”.
Exercises 24 and 25 have been cobbled together and errors have been introduced. Our job is to find the errors, fix the mistakes, and get the program to run correctly… without looking at the previous exercises to do it.
The “broken” file is here.
My “fixes” are here.
What this shows us is that many of the errors we might put into our own code may seem blindingly obvious, but often they are subtle little misses, typos, or otherwise small things that can be infuriatingly difficult to find. There’s still one area of the test I’m not sure I did right, and that has to do with the output of the “sorted sentence”. I get that it’s doing what it’s supposed to do, but the repeated word and out of order with the pop is what has me scratching my head at the moment. If anyone else can tell me what I’m doing that’s totally dumb, hey, I’ll welcome the comments :).