It’s hard to explain my problem so give me a break if it’s not very clear.
I have some ten properties that can be edited in the view. Most of them are booleans. These properties configure a test environment (like one property can be configured to show the solution).
Now, the problem is that some properties can’t be set to true if others are set to false. Nothing would go wrong, but it’s just useless. It’s like one property would be configured not to show the correct button and another to show the solution. In our system, if you can’t click on the correct button, then solution will never be shown.
Does this kind of problem have a name? Do such properties have a name (just like there are immutable properties)? Are there best-practices to implement such a story? We can hard code it in the view, but I would rather have a generic system.
The word you’re looking for is orthogonality. The settings are not orthogonal, as they can’t vary independently.
As to how to handle showing these properties, the completely generic way to do it (and your problem may not warrant the coding cost of this genericicity) would be to give each control an expression that references the other controls, where if the complete expression evaluates to true (or false), the control is disabled in the view.
Easier to code would be a control that exposed an
isDisabled()method, which you could override as necessary. Here’s a short Java example, which leverages Java anonymous classes to do the hard work. It assumes there’s already aControlclass, with abooleanValue()getter that converts it to a boolean, and that sinceAutoDisabledControlis-a Control, it can be used as a drop-in replacement for a Control:Naturally, in the View’s display, it checks each control’s
isDisabled(), and disables the ones that return true; when a Control’s value is changed, the view redisplays. I’m assuming some sort of MVC Pattern.