I have recently started working on a server software in Java and wanted to add a configuration option to the program.  I have gone through a few revisions of this class because I never liked what I came up with.  I finally made something that I'm somewhat happy about and it works better than past versions.  I'm just curious if anything can be done better or if this class should be rewritten again in a different?FYI: some methods are not done yet. I'm not worried about those methods, I'm asking about what is there so far.import java.io.File;import java.util.HashMap;import java.util.Map;import org.yaml.snakeyaml.DumperOptions;import org.yaml.snakeyaml.Yaml;public class Config{public static final String SERVER_NAME = serverName;public static final String MOTD = motd;public static final String SERVER_PORT = serverPort;private static final File file = new File(config.yaml);private Map<String, Object> config = new HashMap<String, Object>();private DumperOptions yamlOptions = new DumperOptions();private Yaml yaml;private void setDefaults(){    config.clear();    config.put(SERVER_NAME,     Server);    config.put(MOTD,            Welcome to the server!);    config.put(SERVER_PORT,     21020);}public void generate(){    setDefaults();    save();}public void load(){        //To-do}public void save(){    //To-do }public Object getObject(String key){    return config.get(key);}public String getString(String key){    return (String) getObject(key);}public int getInt(String key){    return (int) getObject(key);}public double getDouble(String key){    return (double) getObject(key);}}Example of usage:Config.getInt(Config.SERVER_PORT);
YAML Configuration file
java;yaml
So far it's looking quite good, but I have a few comments:Which file to load?private static final File file = new File(config.yaml);In my opinion it would be better to pass the File to load in to the constructor of this Config class, for flexibility. Now perhaps you only need to load a specific file, but in the future you might want to support multiple files. Who says that you always want to load config.yaml? Sometimes you might want to try different configurations, and instead of making backups of your config file and renaming files like crazy, you could instead load config-withsomespecials.yamlprivate final File file;public Config(File file) {    this.file = file;}Speaking of flexibility, your setDefaults class works fine for your server, but you could make your Config class an abstract class, setDefaults as an abstract method and use a ServerConfig as a subclass in which you override this method:// In your `Config` class:protected abstract void setDefaults();// In your `ServerConfig` class:@Overrideprotected void setDefaults() {    config.clear();    config.put(SERVER_NAME,     Server);    config.put(MOTD,            Welcome to the server!);    config.put(SERVER_PORT,     21020);}These are only suggestions, if you don't want to make it that flexible, that's up to you.<personal-opinion> As for the choice of using YAML.... it isn't exactly my favorite format. Let me guess, you're a Minecraft / Bukkit player? The Minecraft / Bukkit world is about the only place I've come across this format. If you have the ability to choose, I would personally recommend using Jackson, which is primarily used for JSON, although it has support for XML and even support for YAML. Jackson is wildly used, very flexible, and I think it is more well-documented than Snakeyaml.</personal-opinion>