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*

8
  • If variant C would expose IsLoggedIn as getter, it would be variant B effectively, because IsLoggedIn is readonly in all variants. Do you really think it would break the LSP? I edited my post with an idea of a decorator implementation. In my opinion the decorator cares for fulfilling the LSP in systems where resets alter the state, and the original implementation fulfills the LSP in systems where resets doesn't matter. Regarding your first alternative: Wouldn't that break the LSP by throwing an exception? Your second variant would indeed be a possibility, I have to think about it. Commented Sep 15, 2018 at 6:47
  • 1
    @Creepin Good catch. I think I have misinterpreted your explanation of variant B. So I've edited my answer and elaborated on the problems with LSP. Hope it's clearer now :-) Commented Sep 15, 2018 at 9:42
  • First, thanks for your edits, sounds much better. I am not sure if the decorator would violate the history constraint. The decorator does not expose any further possibility to change the state in comparison to what the super type (interface) already exposes. .... Commented Sep 15, 2018 at 15:37
  • But if we assume it would violate the history constraint, then why doesn't your second variant violate it? It also listens internally to an event that notifies on login status impacts. This is similar to what my decorator example does. So in both cases the state is changed internally. I thought of adding an event LoginStateChanged to the interface to give clients the chance to register on internal state changes. Commented Sep 15, 2018 at 15:38
  • @Creepin my point is that the potential change of status due to external situation has to be designed into the interface from the start and not via decorator. Because it's the only way not to violate history constraint. My two alternatives are only variants of how to change the interface. By making clear that outside events could change the status (especially 2nd option) there's no history constraint anymore Commented Sep 15, 2018 at 16:15