3 ms·
> How does this work for constructors? There's always static factory methods, for when constructors just can't do what you need.
by tsewlliw 15y ago
> How does this work for constructors?
There's always static factory methods, for when constructors just can't do what you need.
- virmundi 15y agoBut doesn't this basically mean that my constructor has to allow for invalid states? Also, doesn't that mean that another object has the rules for what makes the first object valid? Isn't that a violation of separation of concerns?
- tsewlliw 15y agoI'm coming at this with Java semantics, apologies if that just doesn't work for you :) I'd make the constructor private, and move the validation into a public static factory method on the same class that returns an Either.