views:

362

answers:

11

What parts of your application are not coded? I think one of the most obvious examples would be DB credentials - it's considered bad to have them hard coded. And in most of situations it is easy to decide if you want something to be externalized or coded.For me the rules are simple. Some part of the application should be externalized if:

  1. it can and should be changed by non-developer, but not so often to be included in application settings defined in UI (DB credentials, service URLs, etc)
  2. it does not require programming language and seems unnatural being coded (localization)

Do you have anything to add?

This is a little related to this question about spring cfg. Spring configuration seems less obvious example for me, because in my practice it is never modified by anyone except the developer. And the road of externalizing can take you far away, to the entire project being "configured", not coded - so where to stop?

So please post here some examples from your experience, when you got benefit from having something configured, not coded - like dependency injection configuration in spring, etc. And if you use spring - how often is configuration changed without recompiling?

+2  A: 

paths and server names/addresses come to mind..

DaveJustDave
+5  A: 

Anything that needs to differ between different deployments of your application. That is, anything specific to the environment.

Examples include:

  • Database connection strings
  • URLs for web or WCF services
  • Logging configuration

HTH, Kent

Kent Boogaart
+1  A: 

I agree with your two conditions, which is why I:

  1. Rarely include a config file as part of a Windows or Windows Mobile application (web apps yes).
  2. If I did include a config file meant to be tweaked by end users, it certainly wouldn't be XML.
MusiGenesis
+2  A: 

Besides the obvious changing stuff (paths, servers, ports, and so on), some people argue that you should be able to easily change whatever might reasonably change, for instance, say you have a generic engine which operates on the business logic (a rule engine).

You would then define the rules on a "configuration file" which ends up being is no less than programming in a DSL instead of in the generic purpose language. Benefits being it's closer to the domain so it's easier and more maintainable, and that you can easily change things that otherwise would demand a new build.

The main argument behind this is that things you assumed would never change always end up changing nonetheless, so you better be prepared.

Vinko Vrsalovic
+1  A: 

Employee emails/names since employees can come and go... (you should typically try to keep them out of an application though)

Max Schmeling
This is better handled by use of email aliases (On the email server).i.e. [email protected], rather than [email protected] somebody leaves, just change the alias to point to their replacement - no need for any email config in the application at all.
belugabob
+1  A: 

Configuration files should include:

  • deployment details
    • DB credentials
    • file paths
    • host names
  • anything that is used in many places but that may change
    • contact email addresses
  • options that aren't in the GUI

The last one is a bit open-ended, but very important. I've found it very useful to foresee variables that the client may, in the future, want to change. If changes are infrequent, I or they can edit the config file. If it becomes a frequent thing, it's trivial to add the option to the GUI, which isn't hardcoded.

Lucas Oman
+3  A: 

Any information your application uses that is "data" and that could change depending on where it is installed. Things like:

  • smtp mail server used to send e-mails
  • Database connect strings
  • Paths to file locations / folders used by the app
  • FTP servers & connect info
  • Active Directory servers used for authentication
  • Any links displayed in the application to external information sources
  • Warning limit values
  • I've even put the RegEx filters used to limit the allowable characters for data entry fields.

Ron

Ron Savage
+1  A: 

I would also add encryption keys (which themselves should be encrypted)...

Basically the rule of thumb is information the application needs BEFORE it's regular, functional operation, data that it MUST have on-hand (i.e. local and not networked).
Note that this data should not be dynamically changing or large amounts of it, otherwise it should be in the database.

AviD
+1  A: 

With Spring apps I actually distinguish between two types of configuration:

  1. Items externalized into property files which are "deploy time" concerns or "environment-specific": server IP's / addresses, file system locations, etc etc

  2. Spring XML configuration which can do lots of things, like indicate the overall application structure, apply behavior via AOP, etc.

cliff.meyers
+1  A: 

I use Spring to wire all the beans in a J2SE application that has no GUI (a transactional switch). That way it's very easy for me to have different configurations in each deployment (we have this thing running in different countries), without having to code anything different. Another thing I like to have is to manage all the SQL statements separately from the code, when I use plain JDBC (or Spring JDBC). Like in a properties file or XML or something, sometimes even as String properties in the beans that will use the statement (when there is only one bean that will use the statement, such as a DAO).

Chochos
+1  A: 

I am going to use spring JDBC or vanilla JDBC for data persistence, here we have decided to externalize all the SQL from the Java code, so can be better mangable in terms of SQL query tuning and optimization, we don't need to disturb the java code.