Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    Please see this webpage: enterprisecraftsmanship.com/2016/09/13/validation-and-ddd. Would you suggest something like: Execute / CanExecute pattern for the validation? Commented Jun 27, 2017 at 13:18
  • I have also injected RulesOfferCalculator into this class. What do you think of that? I believe it follows the open close principle. Commented Jun 27, 2017 at 13:19
  • 1
    "Would you suggest something like: Execute / CanExecute pattern for the validation?". No! Non-atomic "test then set" operations like this are an anti-pattern as, unless you have exactly one copy of the application, operating on a single thread, then the state can change between the "test" and the "set". So use either an "execute and throw" pattern or a "try execute" pattern that returns success or the error result. Commented Jun 27, 2017 at 15:19
  • @David Arno, thanks. The author of the article states that: TryExecute is problematic because it breaks the CQS principle. Do you not agree? Also do you mean return the word: "success" as a string? Commented Jun 29, 2017 at 12:52
  • 1
    @w0051977, it probably won't surprise you to discover that I have as little time for CQS as for RDM. CQS creates unnecessary complexity and is generally a nightmare in multi-threaded situations. I prefer my commands to return a success or an error result. Commented Jun 29, 2017 at 16:10