Discussion Board
There are no previous messagesGo to the following message
Current Forum: Homework 4 General Forum
Date: Tue Oct 2 2001 9:41 am
Author: Cipriani, Jason A. <jac4@andrew.cmu.edu>
Subject: where to put constants?

do you recommend that we define some constant to be 256 (the size of the ascii character set)? or can we just hard code 256 in to our program.

also, where is the best place to put a constant field that you will need to use throughout the entire program? is it bad practice to say, make a class called "MyConstants" with nothing but a bunch of "public static final" variables and then just do stuff (all throughout the program) like:

for (i = 0; i < MyConstants.ASCII_CHARSET_SIZE; i ++) {
    ...
};

would referencing a constant member of a class have any impact on speed, or is the java compiler smart enough to optimize that?

is there any way to declare a bunch of global constants that aren't a member of any class in a file?

thanks,
jason

Post response

There are no previous messagesGo to the following message
Current Thread Detail:
where to put constants?      Cipriani, Jason A.      Tue Oct 2 2001 9:41 am       
Re: where to put constants?      Lee, Peter      Tue Oct 2 2001 11:31 am       

Back to previous screen