Timeline for What is a good design for a method that can return several logically different results?
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 21, 2014 at 20:49 | comment | added | Euphoric | .. But that makes it hard to add new results. I guess it is not that good idea. | |
| Jul 21, 2014 at 20:43 | comment | added | Euphoric | @NikolaAnusev If you want to be really precise about it, you could define a factory interface, that creates the "results" and then inject the implementation of that factory that returns "results" that can update UI. That way you maintain the separation, but you just added 2 more entities and bunch of coupling to solve this problem. | |
| Jul 21, 2014 at 20:39 | comment | added | Nikola Anusev |
You are right, there is a different action for each outcome. However, in this particular case, both actions have something to do with updating UI and I wouldn't like putting UI code to those Result classes.
|
|
| Jul 21, 2014 at 6:19 | history | answered | Euphoric | CC BY-SA 3.0 |