What descriptive variable name can I use here?

I create my own Java Struts tag, which is designed to create and format the html selection window in a standard way (part of our usability recommendations).

Each selection window has an additional / initial value that describes the requirement of the value returned by the selection element, that is:

  • Required - labeled "Please select",
  • Optional - "None Selected"
  • Select All - Select All

The custom tag will have a property that will control which ones will be used.

So the problem is that I need to think about a variable name that can adequately explain that there is one of these three values!
I will comment on the code anyway, but I would prefer that employees do not have to look for the source code in order to remember what the tag variable assignment is.

Edit: In order to apply some context to this problem, the usability strategy that I implement here is that if you can select more than 5 elements, the parameters should appear as the selected box. 5 or less items will appear as radio buttons.
When radio buttons are used, a mandatory label will not be displayed (form validation will complain if no value is selected in any case).

+3
4

. . EDIT , .

requirementConstraint?

<my:customSelect requirementConstraint="Mandatory">
   <option value="1">A</option>
   <option value="2">B</option>
   <option value="3">C</option>
</my:customSelect>

. , : required ("yes" | "no") selectAll ("yes" | "no"), .


EDIT. , , - , . - mustSelect one (), any () all ( ). , " " - , , customSelect . mustSelect:

( )

<my:customSelect mustSelect="one">
   <option value="1">A</option>
   <option value="2">B</option>
   <option value="3">C</option>
</my:customSelect>

( )

<my:customSelect mustSelect="any">
   <option value="1">A</option>
   <option value="2">B</option>
   <option value="3">C</option>
</my:customSelect>

<my:customSelect mustSelect="all">
   <option value="1">A</option>
   <option value="2">B</option>
   <option value="3">C</option>
</my:customSelect>
+6

'', , .

, :

: 1 : 0+ : n

+3

. , , , .

, (, -) , (---). , "", , , "" .

KISS *, "ZeroOneOrMany" .


[*] , !

+1

/ , .

.

0

Source: https://habr.com/ru/post/1698233/


All Articles