Topics

Note Selector

Return to Single Attribute Class

Monday, October 25, 2021

Is there a clear way that you can make an Attribute class that works with a single value by default, but can also work with multiple state-value pairs?

Your original Attribute class did this, but users of the attribute class still needed to call the different functions depending on if their attribute had multiple values or not. You decided that this differentiation wasn't clear and split the Attribute class into two with each containing the different representations.

While this split might have made knowing which functions to call clearer, it also has introduced more code clutter. There is more typing involved when working with attributes because instead of just referring to an 'attribute', you now have to refer to 'stateless_attribute' or 'stateful_attribute'.

How are stateful attributes used in other contexts?

  • CustomizePanel::add_attribute_widget() checks whether the AttributeWidget is associated with a stateful attribute or not so that it can link the state combobox item change signal to the AttributeWidget's controls' set_current_editting_state() slot.
    • Why not just not check at all, link the state combobox anyways, and if setting a stateless attribute's state did not break anything, there would be no problem. It just might not be clear that it is a stateless attribute being called on.
  • Many other contexts check for statehood to know whether or not to supply a state when setting an attribute's value
    • What if the attribute being changed is stateless, but during setting, a state is supplied anyways? Can the state just be ignored, or is that not clear either?