I said earlier that constructors must be code-free and do nothing aside from attribute initialization. Since then, the most frequently asked question is: What about validation of arguments? If they are "broken," what is the point of creating an object in an "invalid" state? Such an object will fail later, at an unexpected moment. Isn't it better to throw an exception at the very moment of instantiation? To fail fast, so to speak? Here is what I think.
[image error]Punching the Cl...
Published on May 28, 2018 17:00