model -> view tiers and constants

V

VisionSet

In my model tier I often have constants declared like this:

private static final String[] STRING_CONSTANTS = new String[2];
private static final int CONST_A = 0, CONST_B = 1;
static {
STRING_CONSTANTS[CONST_A] = "Eh?";
STRING_CONSTANTS[CONST_B] = "Bee";
}

Then I can give the view tier (jsp) access to the array which it can iterate
over, using the array index to return selected <option>s.
This can then be matched up back in the model tier with simple switch
statement.

switch(myHttpParam) {
case CONST_A: // do A stuff
case CONST_B: // do B stuff
}

I can't see how it can be any simpler than this, but have never seen this
done.

Any views on this?

[Chris Smith, you answered a similar question from me a month or so back,
this is a more concrete example]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top