Skip to content. | Skip to navigation

Personal tools


You are here: Home / weblog / Microsoft Press - hall of shame

Microsoft Press - hall of shame

Posted by Dominic Cronin at Mar 14, 2007 10:45 PM |

Tomorrow I'm doing the last exam for Microsoft Certified Application Developer (MCAD). I've been using the official training pack from Microsoft Press, and frankly, it's appalling. Examining people's programming ability via the medium of multiple choice is dubious enough to start with, but if you're going to do it, at least make sure the answers are correct even under the most pedantic interpretation possible. To be fair, my experience of the actual exams has been that this is the case, but this little example from the sample exam in the training kit should give you the flavour of what I've found myself up against.

You create a Web custom control named Toggle that users can turn on and off. 
The Toggle Control includes a Button control named toggleButton. You write an event handler named toggleButton_Click for the toggleButton.Click event. This event adjusts the BorderStyle property to signify whether the Button is toggled on or off. You want to add code to the Toggle class so that when the toggleButton is clicked, pages that contain instances of Toggle can process custom event handling code. You add the following code to the Toggle class:
public delegate void ChangedValue(object sender, EventArgs e);
public event ChangedValue Changed; protected virtual void OnChanged(EventArgs e) {     if (Changed != null)         Changed(this, e); }
You need to add code to toggleButton_Click so that pages conaining instances of Toggle can handle the ChangedValue event and process custom event handling code. Which of the following enable you to do so? (Choose the correct answer.)
*    OnChangedValue(EventArgs.Empty)
*    Changed(sender, e); *    OnChanged(this, e);
*    ChangedValue(this, e);

The answer given as correct is the first one, but as far as I can see, it should be something like:


I don't write events and wire them up with delegates every day. It took me a little while to figure out that all the anwsers were wrong. (Personally I find some of the conventions here a little alien. I'm used to a world in which event handlers have names like OnThingHappened. With the .NET framework, OnThingHappened is part of the event raising mechanism: Something happens, so your class calls its OnThingHappened member, which raises the event, which some other code will have subscribed to.)

It's not just an isolated example either. One of the programming labs for ASP.NET begins with a "Switchboard" page, with links to the other pages. In the switchboard page, various DataSets are populated and stored in the Cache. In the other pages, these values are unceremoniously whipped out and used, regardless of the fact that there's no guarantee they'll be there. Bear in mind that half the reason anyone would be studying this stuff is that they probably aren't yet an expert. By the time I'd dug into the subject a little, it turned out that you can only use the web application cache for what it says on the box - caching. It's a performance tweak, and you shouldn't be using it to get data from one page to another. There are probably thousands of applications in production right now based on this fundamentally flawed technique.


Microsoft Press... hall of shame!