andrewmcdonagh wrote :
By using the enum in this way and having code spread throughout your
app which checks which enum is being referenced to decide what to do,
it sounds like your design needs to be 'normalised' in an OO way
I can see that, except that I have delibrately de-normalized between
use cases. The use cases are pretty well separated from each other.
I can delete a use case without affecting any other use case. Except of
course that that functionality has gone, which may mean that the user
can no longer maintain helper tables. But it will run OK.
Everything else is in a framework. Those classes cannot be removed as
they are used everywhere.
So if an enum is in the framework, then it should NOT know about any
business logic which uses it.
For instance (putting on fire-proof-coat)
----------------
public class Value
{
// these are column IDs which we store in the database
// - do NOT change them, only add new ones
// - they must be unique
private static int LOGIC_AND_ID = 0;
private static int LOGIC_OR_ID = 1;
// these are column IDs which we store in the database
// - do NOT change them, only add new ones
public static enum Logic
{
/**
* All values must return true
*/
AND(LOGIC_AND_ID),
/**
* Any value can be true
*/
OR(LOGIC_OR_ID);
private Logic( int databaseID )
{
ivDatabaseID = databaseID;
}
private int ivDatabaseID;
public int getDatabaseID()
{
return ivDatabaseID;
}
/**
* Returns the Logic for a given database id number<br><br>
* Used to find a Logic from a Web page field or database column
*/
public static Logic getLogic( int databaseID )
throws EnumNotFoundException
{
for (Logic logic : Logic.values())
if (logic.getDatabaseID() == databaseID)
return logic;
throw new EnumNotFoundException( Logic.class.getName() + "(id: " +
databaseID + ")" );
}
}
// .. other universal values, such a number of milli-seconds in a
// second, minute, hour, day, and so forth
}