Skip to main content
added 2 characters in body
Source Link

I would make the class in option #3 static. So instead of

//create SomeCl Foo f = new Foo(); f.setConfigInst(cfg); ... ... //Inside Foo public void setConfig(MyAppConfig c) { localCfg = c; } ... //somewhere else: x = localCfg.getConfigForX(); 

You can just have:

//Inside Foo x = MyAppConfig.getConfigForX(); 

Let the details of loading/saving configuration data happen inside MyAppConfig class. And of course you could have more complex variations, such as different classes for different purposes.

The only case where this approach would be a problem would be if youyou for some reason needed to work on multiple instances of different configurations at the same time, although I have yet to come across such a situation.

I would make the class in option #3 static. So instead of

//create SomeCl Foo f = new Foo(); f.setConfigInst(cfg); ... ... //Inside Foo public void setConfig(MyAppConfig c) { localCfg = c; } ... //somewhere else: x = localCfg.getConfigForX(); 

You can just have:

//Inside Foo x = MyAppConfig.getConfigForX(); 

Let the details of loading/saving configuration data happen inside MyAppConfig class. And of course you could have more complex variations, such as different classes for different purposes.

The only case where this approach would be a problem would if you for some reason needed to work on multiple instances of different configurations at the same time, although I have yet to come across such a situation.

I would make the class in option #3 static. So instead of

//create SomeCl Foo f = new Foo(); f.setConfigInst(cfg); ... ... //Inside Foo public void setConfig(MyAppConfig c) { localCfg = c; } ... //somewhere else: x = localCfg.getConfigForX(); 

You can just have:

//Inside Foo x = MyAppConfig.getConfigForX(); 

Let the details of loading/saving configuration data happen inside MyAppConfig class. And of course you could have more complex variations, such as different classes for different purposes.

The only case where this approach would be a problem would be if you for some reason needed to work on multiple instances of different configurations at the same time, although I have yet to come across such a situation.

added 53 characters in body
Source Link

I would make the class in option #3 static. So instead of

//create SomeCl Foo f = new Foo(); f.setConfigInst(cfg); ... ... //Inside Foo public void setConfig(MyAppConfig c) { localCfg = c; } ... //somewhere else: x = localCfg.getConfigForX(); 

You can just have:

//Inside Foo x = MyAppConfig.getConfigForX(); 

Let the details of loading/saving configuration data happen inside MyAppConfig class. And of course you could have more complex variations, such as different classes for different purposes.

The only case where this approach would be a problem would if you for some reason needed to work on multiple instances of different configurations at the same time, although I have yet to come across such a situation.

I would make the class in option #3 static. So instead of

//create SomeCl Foo f = new Foo(); f.setConfigInst(cfg); ... ... //Inside Foo public void setConfig(MyAppConfig c) { localCfg = c; } ... //somewhere else: x = localCfg.getConfigForX(); 

You can just have:

//Inside Foo x = MyAppConfig.getConfigForX(); 

Let the details of loading/saving configuration data happen inside MyAppConfig class. The only case where this approach would be a problem would if you for some reason needed to work on multiple instances of different configurations at the same time.

I would make the class in option #3 static. So instead of

//create SomeCl Foo f = new Foo(); f.setConfigInst(cfg); ... ... //Inside Foo public void setConfig(MyAppConfig c) { localCfg = c; } ... //somewhere else: x = localCfg.getConfigForX(); 

You can just have:

//Inside Foo x = MyAppConfig.getConfigForX(); 

Let the details of loading/saving configuration data happen inside MyAppConfig class. And of course you could have more complex variations, such as different classes for different purposes.

The only case where this approach would be a problem would if you for some reason needed to work on multiple instances of different configurations at the same time, although I have yet to come across such a situation.

Source Link

I would make the class in option #3 static. So instead of

//create SomeCl Foo f = new Foo(); f.setConfigInst(cfg); ... ... //Inside Foo public void setConfig(MyAppConfig c) { localCfg = c; } ... //somewhere else: x = localCfg.getConfigForX(); 

You can just have:

//Inside Foo x = MyAppConfig.getConfigForX(); 

Let the details of loading/saving configuration data happen inside MyAppConfig class. The only case where this approach would be a problem would if you for some reason needed to work on multiple instances of different configurations at the same time.