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

  • Home
  • SEARCH
  • 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 6770349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:18:06+00:00 2026-05-26T15:18:06+00:00

I have a software setup with 2 layers, a core layer and a customer

  • 0

I have a software setup with 2 layers, a core layer and a customer specific layer. The core layer has defined constants which the customer specific layer should be able to extend. More specific:

public class CoreConstants
{ 
  public static long CORE_CONSTANT_1 = 1;
  public static long CORE_CONSTANT_2 = 2;
}

The customer specific layer should be able to add constants which are only used in the customer specific layer. Idea:

public class CustomerConstants extends CoreConstants
{
  public static long CUSTOMER_CONSTANT_1 = 1000; // starting range = 1000
}

Is there a more common way to handle this?

More info: The reason for inheritance is to define the starting range of the customer specific constants. In the CoreConstants class I could set the starting value for customer specific constants. Customer specific constants could then be defined like:

public static long CUSTOMER_CONSTANT_1 = customStartValue + 1;
public static long CUSTOMER_CONSTANT_2 = customStartValue + 2;
  • 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-26T15:18:07+00:00Added an answer on May 26, 2026 at 3:18 pm

    Integer constants are generally better replaced with enums, and you can achieve what you want using interfaces on enums.

    interface CoreConstant {
        int intValue();
    }
    
    enum CoreConstants implements CoreConstant {
        CORE_CONSTANT_1(1),
        CORE_CONSTANT_2(2);
        private final int intValue;
        public CoreConstants(int intValue) { this.intValue = intValue; }
        public int intValue() { return intValue; }
    }
    
    interface CustomerConstant extends CoreConstant {}
    
    enum CustomerConstants implements CustomerConstant {
        CUSTOMER_CONSTANT_1(1000);
        private final int intValue;
        public CustomerConstants(int intValue) { this.intValue = intValue; }
        public int intValue() { return intValue; }    
    }
    

    You could perhaps improve the design by using delegation within the enums, using an IntConstant class. Unfortunately for your case, you cannot extend an enum. The result is a bit of code duplication in the enum classes.

    Otherwise, if you want to stay with the public static int model, then use an interface instead of a class, and finalize the constants.

    interface CoreConstants {
        public static final int CORE_CONSTANT_1 = 1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a software diagnostic page on which I would like to list the
We have some software we use internally which is released via ClickOnce from VS
We have some software which relied on certain behavior from another ( very commonly
We have this software that has a webservices component. Now, the administrator of this
We have 3 software products which use the same .net dlls(code + legacy). All
We have a bit of an odd setup, which comes from the fact we
We have a suite of software solutions developed by a third party which are
I have setup PostgreSQL on a VPS I own - the software that accesses
So we have a bit of an unusual setup in our software. On a
I currently have Git setup with a central bare repository which is accessed by

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.