views:

31

answers:

1

what is the best way to use Application Constants ? What i usually do is create a separate table in database of constants and reference them as foreign key in other table. In Java i use enum.

But how to keep a single place of authority for constants in application and what are the different ways i can do that(like table or enum).

+1  A: 

What you described is a usual approach. You keep "constants" in the database layer and you mirror them in the application using enumerations. The only trouble is keeping them in sync. Following a strict process can help here. For example, you always update values on both levels immediately one after another, not interrupting the process for any purspose and checking in the changes immediately after it's done.

Another idea would to oly keep constants in the database. You also assign names to them. Whenever you use a constant in your application (by name) it is transparently loaded from the database. This way any change you introduce will immediately be seen by any user connecting to the database. The only error may be caused by an update happening in the middle of a transaction.

Developer Art