Yonatan Zunger (zunger) wrote,
Yonatan Zunger
zunger

  • Mood:

heterosexuality.Test()

A friend recently mentioned events that caused people to "question the security and reliability of their heterosexuality." This got me thinking: Good maintenance should prevent this from ever happening. If you ever end up questioning the reliability of your heterosexuality, this is a clear sign of inadequate unit testing.


First of all, we need to work out an API for sexual orientation. Orientation is really part of the broader partner selection system, which should expose something on the lines of
  class PartnerSelector {
    ....
    void AddInteraction(const Person &other, const Interaction &data);
    bool Schtupp(const Person &other);
  };

or something like that. Internally, Schtupp() should be computing some sort of score and comparing it against a threshold; this could be done using schmancy machine-learning techniques, but I suspect that the best approach is simply an old-fashioned scoring function, where various things give and remove points. A sexual orientation would then be implemented as a module which cuts scores down to zero (or at least, something small) when genders are incompatible. It would be part of the interaction-independent (i.e., only person-based) part of the score.

For maximum flexibility, it should be possible to switch the various scoring components on and off with mutators to the PartnerSelector. This can then be used for a detailed regression test.

So now, how does one test one's sexuality? If the scoring function isn't completely modular (which it probably couldn't be, given the complexity of the interaction of the various components) a unittest is more or less out of the question, and a regression test is needed. The general protocol would be to set the PartnerSelector to various modes (heterosexual, drunk, sleep-deprived, etc.), run a known set of interactions through it, and evaluate what it actually ends up doing. Tests obviously shouldn't be run in production mode, so a simulator is needed: elaborate fantasies, virtual girlfriends, IRC, and so forth. (Except for commissioning testing: see below)

A good test suite should try all of the basic modes, at least some of the combinations, and the modes that are going to be running in production. The test cases should be fairly straightforward, and for best results should be kept simple. For example, a good test for one's hetero/homosexuality is to set just that to being active, then run various interactions with a member of the inappropriate sex. Since the expected result is simple, the interactions should be as complicated as possible so as to beat on the system; for example, dinner, complex conversations about science or philosophy, making out, being shot at, going for a long drive, and lighting a bonfire. (The combination is meant to be varied as well as increasing the stress on the system)

And so on; the design of the full test suite is a straightforward exercise, and this regtest should be run at least every few days, to make certain that other changes in the system haven't suddenly broken one's sexual orientation. (You might switch the one you're running in production, but that had better be an intentional switch, and probably in its own changelist. But if getting a neat new hat causes your sexual preference to change, there is something seriously wrong going on here. Or it's a really good hat.)

The last thing needed is full-scale commissioning testing, which a major system like this needs before it comes on-line. This means bringing up a full production system in a sandbox environment, where failures are anticipated and expected, and banging on it as thoroughly as possible. (Most people call this "college.") This requires, for example, heavy load tests ("Full moon on the quad" is part of Stanford's famous test suite), tests under impaired conditions (system performance should be very close to baseline no matter how much alcohol is imbibed, up to the point where other systems like unconsciousness kick in. If your tastes shift too much when you're drunk, this is a sign to start debugging quickly) and destruction testing. (Start with the system running normally and under heavy load. Then suddenly disconnect the SO, move to a different town and change majors. Does your orientation change? Again, if so it's time to examine the matter further) For best results, these tests should be repeated every few years or so, to make sure that performance hasn't degraded in a way that (by random chance) production hasn't triggered lately.

Properly followed, these instructions should keep one's {hetero,homo}sexuality safe and sound for years to come.
Tags: computer science, humor
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 19 comments