have you ever noticed how some applications seem to configure themselves? i dont mean that they auto-detect their settings; rather, the configuration process and tools are so well designed that they are a pleasure to use. like most things in development, this level of functionality didnt appear by accident. "application configuration deserves careful design -- perhaps even more than application code." (halloway, 02) if we want to offer a similar experience to all our users, we need to stop treating configuration as an afterthought.
although this article does not directly discuss auto-detection, i strongly recommend this valuable technique when its possible. there is no benefit in requiring users to supply values that can be programmatically determined. its a nuisance to the user, and presents an opportunity for error. on the other hand, there are limits to auto-detection, especially in a platform-independent environment like java. without belaboring the point, no auto-detected value should ever be treated as more than a default. there needs to be an override available. the easiest way to enable this is to provide a configurable property. auto-detection doesnt do away with properties, it underscores the need for them. 【程序编程相关:Web Services Edge 20】
there are a number of options available to java developers when it comes to implementing configurations. this article begins with the classic properties class and continues on to the new preferences model. it ends with an overview of java management extensions (jmx). along the way, i discuss the various strengths and weaknesses of each option, and attempt to place them in the broader context of a "configuration language." in other words, if there was an ideal configuration model, what attributes and processes would the model have, and how well does each of the existing options address this ideal? 【推荐阅读:Applying Design Issu】
typically, we approach the design of our applications configuration in an ad hoc manner. in other words, we add properties as they occur to us during development. perhaps the primary reason for this is because we can. most java applications handle configuration using the properties class. this class allows us to add properties at will. for instance, the following code shows how we can easily create, set, and save a couple of properties with a minimum of fuss. 【扩展信息:Xdoclet是什么?】
property lines
... 下一页