Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The choice whether to wrap both state flags into their own classes doesn't seem that important to me - any way, that clearly communicates the intent will do (properly naming a flag for example). In your case I would probably go for some simple rule-based solution (like one given by @ejaenv), perhaps beautified by doing it in form of some small DSL.</p> <p>However you can gain even more maintainability from something else IMO. Is the coupling between that two statuses (like- and campaign-) properly justified? For example I can understand, that sometimes you want to prepare some pretty, customized pages dedicated for every single case. On the other hand, often such coupling isn't really necessary as both statuses represent pretty independent concepts. Probably a single page template could include proper elements depending on state of each flag. That way you avoid the problem of choosing the right view entirely.</p> <p>By the way, your proposal isn't really describing the state pattern (as the question could suggest). That pattern is about behavior of an object, that varies from call to call, depending on its state, with some specific use of polymorphism. State pattern would be of little help for you, when you plan to add more conditions. The amount of necessary boilerplate related to this pattern would overshadow all (minor in this case) gains. Besides of that, state pattern is about hiding the state from the clients (they can only infer it indirectly basing on observed behavior). Applying that pattern and then reading the state to take decisions basing on it would be definitely a code smell.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload