Are we done yet?

If you have worked with progress indicators in the past you might have had the same thought that always makes you wonder.

Should I write:

php
  1. if ($done == $total) {
  2.     // We are done, move on
  3. }

or should I write:

php
  1. if ($done >= $total) {
  2.     // We are done, move on
  3. }

that is the question!

Today I went for the '==' route because the $done variable should never be bigger than the $total one.

I think this comes right down to your development philosophy: Should weird conditions in your application that seem "harmless" be silently ignored or should they cause a crash?

I guess I'm the fail often fail early type.

What type are you?

-- Felix Geisendörfer aka the_undefined