| bio | website | |
|---|---|---|
| location | United States | |
| age | ||
| visits | member for | 2 years, 4 months |
| seen | May 14 at 20:53 | |
| stats | profile views | 24 |
|
Jan 29 |
revised |
Gradual approaches to dependency injection added 274 characters in body |
|
Jan 29 |
comment |
Gradual approaches to dependency injection There are a lot of "new X" scattered throughout the code, as well as many uses of static classes and singletons. So when I try to test one class, I'm really testing a whole bunch of them. If I can isolate the dependencies and replace them with fake objects, I'll have more control over the testing. |
|
Jan 29 |
asked | Gradual approaches to dependency injection |
|
Jan 26 |
revised |
Is a single config object a bad idea? added 56 characters in body |
|
Jan 26 |
comment |
Is a single config object a bad idea? Well, no. But there are alternatives: combining multiple settings into objects, or using default values for some settings, with setter methods to override them. I agree that a single config object gives you a lot of convenience; that's why I've been using it all along. My purpose for asking this question was to think about whether it's worth the tradeoffs. |
|
Jan 26 |
awarded | Nice Question |
|
Jan 26 |
comment |
Is a single config object a bad idea? @Anon: I guess the problem is that when I construct an object, I don't know which config settings all its dependencies use. If they were individual parameters, this would be more clear, and I could require them in the constructor. But since the config object is essentially a big hashmap, I can't see which settings are used by which classes. |
|
Jan 26 |
comment |
Is a single config object a bad idea? @AndrewKS: My config class is essentially a big pool of name-value pairs. Any class can use any of them. So when you construct an object X, it might construct an object Y that reads its own config settings. Right now, you can set up the config object with X's settings but not Y's. Obviously this is a problem, but it seems inevitable if everyone can read from the same config object. |
|
Jan 26 |
awarded | Supporter |
|
Jan 26 |
comment |
Is a single config object a bad idea? True. But if I continue using a single pool of settings (with a different pool for testing), then all my tests end up using the same settings. And since I may want to test the behavior with different settings, this isn't ideal. |
|
Jan 26 |
awarded | Editor |
|
Jan 26 |
awarded | Student |
|
Jan 26 |
revised |
Is a single config object a bad idea? added 1 characters in body |
|
Jan 26 |
comment |
Is a single config object a bad idea? That solves the first problem, but not the second. |
|
Jan 26 |
asked | Is a single config object a bad idea? |
|
Oct 13 |
answered | Programmer, not a blogger |