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.

3
  • (It may also be reasonable for user.changePassword(newPassword) to throw an Exception to say that it won't set a weak password at that level, so that one could maybe stay...) Commented Aug 19, 2021 at 7:27
  • I see. So, the "alternative" is to let the client with more code - do all the checking. And then I guess, the exceptions can remain as unchecked. Commented Aug 19, 2021 at 11:15
  • 1
    Your implementation violates the Tell, Don't Ask principle [1,2]. I believe you also have a misconception about what a responsibility is. There's nothing fundamentally wrong with OP's code (and your implementation may be acceptable in some contexts as well, even if it violates the principle). Commented Aug 19, 2021 at 12:29