The Volvo of calling functions: A lesson in defensive coding.

if (is_object($x) && is_object($y)){
    if (method_exists($x, "isValid") && method_exists($y, "isValid")) {
        if ($x->isValid() && $y->isValid()){
            doSomething($x, $y);
        }
    }
}
Advertisements

One Comment on “The Volvo of calling functions: A lesson in defensive coding.”

  1. To all developers:
    Don’t do this.


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s