3 ms·
The entire example is contrived to talk about testing. Not much about UserRepository is ideal. I think out and ref are pretty horrible. I understand that the p
by latch 16y ago
The entire example is contrived to talk about testing. Not much about UserRepository is ideal.
I think out and ref are pretty horrible. I understand that the pattern is convenient for the BLC *.TryParse methods, but it should really stick there. Your signature tells me that you'd likely return false rather than throw an exception. I'd agree that returning null isn't the best, but I'd favor returning a NullObject that true/false with a out parameter.
- MartinCron 16y agoI think out and ref are pretty horrible. I agree wholeheartedly, though I'm not sure why. I often find myself creating small "data bunch" types with names like ValidationResult that consist of a bool & a set of messages to use as responses to the question "is this input OK, and if not, why not?"