Re: Where do you keep contants in Interfaces or in classes?



Royan wrote:
So, I'm changing my previous decision to use interfaces as the place
to keep constants. Instead I will use the following approach:

package org.megaware.constants;

public final class Constants {
public final static int GENERIC_INT = 0;
// some other generic consts here
public final static class Network {
// some other Network consts here
public final static int DEFAULT_PORT = 55888;
}

public final static class Gui {
// some other GUI consts here
public final static String APP_TITLE = "Megaware";
}
}

You'll probably find it easier to maintain this code if you push your 'Network' and 'Gui' classes to top level instead of nesting them.

--
Lew
.