合理的默认配置
我最近开始使用 Ruby on Rails,它更倾向于约定而不是配置,并依赖合理的默认值将应用程序的各个方面联系在一起。
我在想,如果在各种框架的通用配置中使用这种合理的默认配置的概念,那么它可能会很有用,那么它可能会节省一些开发麻烦。
例如,在 .net 应用程序中,我通常希望使用企业库异常处理块在 Windows 事件日志中记录异常,但如果我没有在配置文件中明确说明我想要的行为,那么 EL 会抱怨。 我认为,如果它找不到自定义配置,那么它应该恢复到合理的默认配置,例如在事件日志中记录我的异常。
对于框架在其配置中采用的概念来说,这是一个好还是坏的概念?
I've recently started to play with Ruby on Rails which favours convention over configuration and relies on sensible defaults to tie various aspects of the application together.
I was thinking that it might be useful if this concept of sensible default configuration was used in general configation for various frameworks then it might save some development headache.
For example, in a .net app I usually want to log an exception in the windows event log using enterprise library exception handling block but if I don't explicity state the behaviour I want in a config file then EL will complain. I think that instead, if it can't find custom configuration then it should revert to a sensible default configuration, like logging my exception in the event log.
Would this be a good or bad concept for frameworks to adopt for their configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我经常使用一个可以完成这件事的框架。 我对这种工作方式的麻烦在于:
当忘记设置配置值时,我宁愿让软件告诉我,而不是假设我可能根本不追求的某种形式的行为。
我更喜欢一个“模板”配置文件,在其中我可以更改我想要的内容,并将未更改的设置作为默认设置。
弄清楚软件在调试时选择哪种约定也可能会浪费大量时间。
I work a lot with a framework that does this exact thing. My trouble with this way of working is that:
When forgetting to set a configuration value I rather have the software tell me, instead of assuming some form of behavior that I might not at all be after.
I'd prefer a 'template' configuration file in which I change what I want and have the unchanged settings serve as the default.
Figuring which out which convention the software picked when debugging can be a lot of time wasted also.