Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Typically the ENUM approach involves some sort of a table (array) of states and transitions. Whereas the design pattern achieves the same with objects.</p> <p>If you arent referring to the table approach with ENUMs, then the solution would need to involve a large if/else if block, which is quite unmanageable. Referring to the section below, I think its quite obvious this particular solution is inferior.</p> <p>Here are what I would list as PROs and CONs of each</p> <p><strong>ENUM table</strong></p> <p>PROs:</p> <ul> <li>Easier to see all of the states and transitions since the table is defined in one place</li> </ul> <p>CONs:</p> <ul> <li>States and transitions are more <em>hard-coded</em> and more code changes are needed to extend</li> </ul> <p><strong>Design Pattern</strong></p> <p>PROs:</p> <ul> <li>Easier to extend with new states by adding a new object. (Open/Close Principle)</li> <li>Easier to assure that all signals are treated by the states, since the base class should define the signals as abstract functions.</li> <li>Easier to extend a particular states' behavior by deriving from the state. The state pattern should put a particular state's behavior in one object. </li> </ul> <p>CONs:</p> <ul> <li>More difficult to see all states and their relations by looking at code, since they are dispersed among several different classes.</li> <li>Could end up creating an unmanageable number of objects. But compare this to the corresponding if/else blocks needed with the corresponding ENUM solution.</li> </ul>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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