Timeline for How do I write this method to adhere to the Single Responsibility Principle?
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 26, 2016 at 12:03 | vote | accept | willem | ||
Feb 25, 2016 at 15:37 | comment | added | Erik Eidt | Seems odd to have a warning "ValueMustBePositive". That sounds more like an error. I'd probably throw an exception. On the other hand, to avoid exceptions, one could introduce a notion of a Report as first-class object and add it as a parameter to the function. That avoids using statics which hamper testability and tightly couples dependencies. | |
Feb 25, 2016 at 12:46 | comment | added | gnat | related (possibly a duplicate): Style for control flow with validation checks. Most blatant violation of SRP here seems to be mixing validation checks with the rest of code | |
Feb 25, 2016 at 12:16 | comment | added | JacquesB | Not directly answering the question, but your method does not do what it says it does. It says it gets a valid double, but actually it might return a null in case of an error. I fear you are using nulls as error codes, which is a bad idea in .net. | |
Feb 25, 2016 at 12:10 | answer | added | Euphoric | timeline score: 2 | |
Feb 25, 2016 at 11:36 | comment | added | NimChimpsky | I'd be more worried about passing nulls around | |
Feb 25, 2016 at 11:23 | comment | added | RubberDuck | With a different title, I think this would be a good question for Code Review SE. | |
Feb 25, 2016 at 11:05 | history | asked | willem | CC BY-SA 3.0 |