in reply to Re^2: confusing constructor code
in thread confusing constructor code

Corion is right that this code isn't sufficient. The goal isn't to avoid warnings; it's the avoid the situations that bring about warnings. Plus, your method will, in most cases, cause the object to be useless. Returning useless things is worse than dying loudly.

In this case, the situation is where the wrong arguments are coming in. Thus, we should probably look at more situations than just the wrong number of arguments. So, we probably want to be looking at the argument names, too. And, maybe even look at validating the values. Maybe we want to allow foo and -foo. In other words, stop hand-rolling and just use Params::Validate.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?