Home > Software Design > WCP: The Worst Case Principle

WCP: The Worst Case Principle

Thursday, September 8, 2011 Leave a comment Go to comments

My last article, Whatever Happened to the Worst Case?, was a bit of a rant but it promised further articles on the subject. This is the first of these, which does no more than describe what I mean by the “Worst Case Principle”, or WCP. I am using WCP as both a label in the title and as a tag to identify each of the articles. The series is intended to provoke thought, not to be a complete treatise on designing robust software. That would fill a whole book – at least!

In the previous introductory article, I said that it is theoretically possible to design and build perfect software. That is because, unlike the hardware upon which it runs, a software program is immune to degradation over time. If we make no mistakes in designing and implementing the program, it will function perfectly forever. If the entire system (hardware and perfect software) does fail, it’s a hardware problem! Perfection is hard to achieve, of course, but it is still the only worthwhile goal and we are very unlikely to achieve it unless we apply the Worst Case Principle at every stage.

To establish the Worst Cases, at various points in our design, we must answer questions like:

  • What is the maximum number of events of type E which can occur within any M milliseconds?
  • What is the maximum allowable execution time for this action?
  • How much dynamic memory will I need to support the specified maximum number of calls through this PBX, while the system is also performing all other possible concurrent activities?

The Worst Case Principle, though, is all about asking such questions, as a matter of habit. To do that effectively, we must look for trouble all the time. I have often thought that an engineer is an optimist by nature – (s)he has to be! – but a pessimist by training. The necessary attitude of mind can be maintained throughout the design process by adopting Finagle’s Law (more comprehensive than Murphy’s Law) as a silent mantra:

  • Anything that can go wrong, will—at the worst possible moment

In other words, when it fails it won’t be during testing, so prevention is much better than attempted cure.

Next time, I’ll take a look at programming defensively against unpredictable timings.

Categories: Software Design Tags: ,
  1. No comments yet.
  1. Tuesday, September 20, 2011 at 18:00

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: