Don’t use global state to manage a local problem

Raymond Chen

We’ve seen a few instances where people have used a global setting to solve a local problem. For example, people who use the LockWindowUpdate function to prevent a window from redrawing, toggle a global setting to see what its value is, or who change the system time zone as part of an internal calculation. To this, I’ll add as an example a program which figures that if you don’t want the program’s feature, you don’t want that feature in any competing products either.

The first service pack of Windows XP introduced the Set Program Access and Defaults control panel. Among other things, media players can register here to allow users to choose them as the default media player, to enable access to the media player, or to remove access. The guidelines for the use of this control panel recommend that in response to the Remove access command, media players should remove their user interface entry points (such as shortcuts on the Start menu and notification icons), disable their autoplay feature, and generally act as if they weren’t there.

One media player decided that if the user instructed it to remove its access points and disable its autoplay, it would dutifully remove its user interface entry points, and it would also go into the configuration manager and disable media insertion detection on the CD drive. “If you don’t want me to autoplay your CDs, then fine, and I’ll make sure nobody else can autoplay your CDs either.” They also disabled autorun, a related but separate feature.

This program addresses a local problem (disable autoplay for Program X) by applying a global solution (disable all media insertion detection). Whether media insertion detection is enabled or disabled, and which programs should be notified when it occurs, is the decision of the computer user. Programs should not be altering hardware configuration unless the user specifically requested it. The correct thing for Program X to do is to remove its autoplay registration, leaving intact the behavior of other programs.

It turns out that Program X was not disabling media insertion detection out of spite. The people responsible for Program X simply followed the description literally without understanding the big picture. “The documentation says that we should disable our autoplay feature. Well, I guess if we disable media insertion detection, that’ll disable our autoplay feature.”

I wonder if their uninstaller reformats the hard drive.

Moral of the story: Don’t use global state to manage a local problem.

0 comments

Discussion is closed.

Feedback usabilla icon