Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5963445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:15:18+00:00 2026-05-22T19:15:18+00:00

I have been reading a lot of posts on this site regarding the usage

  • 0

I have been reading a lot of posts on this site regarding the usage of constants.

Question:
When should I use Enums for constants, vs using classes or interfaces.

I see 2 key situations I am looking to address.

1. Global Constants used in a applications by multiple projects.

Example:

  • Common logging strings
  • Container references like a database mapping reference used in
    WebSphere EAR’s

2. Object Specific Constants

Example:

  • Employee pay rates for an Employee Object

From everything I have read this is what I think I have a grasp on and what I am looking for an opinion on.

For situation 1:
Design Approach: Use a final class and a static import.
Seen here: What is the use of interface constants?

For Situation 2:
Design Approach: Apply the use of Enums to represent those constants as a object.

Additional points to remember:

  • If the constant string belongs to the class and you only need the string value keep in the class that uses it
  • Don’t use an Interface for situation 1. As mentioned in the link above as Constant Interface Anti-pattern.
    .

Thanks in advance for thoughts and opinions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:15:19+00:00Added an answer on May 22, 2026 at 7:15 pm

    Global constants as you put it should actually be in a properties file as it allows each application to configure them individually without a code modification. For object specific constants my general rule of thumb on Enum versus static final I typically lean towards how many elements there are to have and how related those elements are. If there is a big relation between them such as Suits in a deck of Cards then I would go for the enum. If it is default age for a user, then this becomes a final as there is no purpose to making it an enum as it would not need to be referenced in many areas. These are just some thoughts on each of the ways I have approached it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading a lot on MVC/MVP patterns.... I have a simple question....If
I have been reading a lot about this - I feel like I'm very
I have been reading a LOT of google posts and StackOverflow questions about how
I have been reading a lot of the posts on here and surfing the
i've been reading a lot and have been trying to get this done for
These days, I have been reading a lot the C++ F.A.Q and especially this
I have been reading a lot about QR codes and how the code itself
I have been reading a lot on design patterns lately and some of them
I have been reading a lot of Javascript lately and I have been noticing
I have been reading a lot about C++ casting and I am starting to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.