可以使用单身人士表示糟糕的项目设计吗?

编程入门 行业动态 更新时间:2024-10-09 09:13:20
本文介绍了可以使用单身人士表示糟糕的项目设计吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在从事一个大项目(从头开始)。该程序基本上是一个数据文件处理器,总体上是这样的: 数据文件被读入,验证并存储在内存结构中 类似于数据库或XML表示。将执行修改存储的 数据的规则,然后将数据转换为输出 格式。 Think与FormatA类似的东西 - > XML - >操纵XML - > FormatB 项目规模很大,但到目前为止,我已经能够保持它非常好的模块化使用OO设计。但是我对我在程序的某些方面使用 单身人士有疑问。 * 我已经发现使用单例对象相当不错的各个方面 这个程序,我喜欢有能力使用单例类 使用Class :: Instance( )语法,因此无需在我的所有函数调用中传递 实例。同样非常有用的是 能够使用一个guarenteed单个实例,只需包含含有我的单身的 标题。 现在我使用它们for: 登录服务器:中央消息存储和分发到N号 报告/日志) 计划状态:再次成为跟踪计划状态的中心点。 中央数据表示 我不知道是否使用多个单身人士可以代表一个 设计缺陷,并想在一个项目中使用或使用 多个单身人士的一些意见。 我知道它含糊不清,但是没有进入冗长的写作,我不会知道还有什么可能是有价值的。如果我能提供一些 的信息,请问。 谢谢, JF

解决方案

John Fly写道:

我没有知道多个单身人士的使用是否代表了一个设计缺陷,并希望在一个项目中对他们的使用或使用多个单身人士提出一些意见。

www-128.ibm /developerwork...co-single.html

[X-posted to comp.object and followups set] John Fly写道:

我发现使用单例对象非常适合这个程序的各个方面,我喜欢拥有通过使用Class :: Instance()语法来使用单例类的能力,从而删除了nee d在我的所有函数调用中传递实例。通过简单地包含包含我的单身的标题,使用保护单个实例的能力也非常有用。 最重要的设计特性是可测试性。课程必须严格按照相互分离才能提交到具有非常精细的b / b 粒度的测试用例。 (你做_have_ test案件,不是吗?) 现在我将它们用于: 记录服务器:中央消息存储和分发到N号报告/ logs)程序状态:再次成为跟踪程序状态的中心点。中央数据表示

将伪数据传递给使用这些系统的模块,你会将假数据推入单例,让模块使用吗? 这种情况​​可以改善。一般来说,如果申报单身的原因是因为只有其中一个,那么测试用例总是违反这个先决条件因为那个'总是很多人! - Phlip www.greencheese/ZeekLand < - 不是博客!!!

On Fri,2006年2月24日11:17:18 -0800,John Fly写道: < snip>

现在我将它们用于: 记录服务器:中央消息存储和分发到N号报告/日志)程序状态:再次成为跟踪程序的中心点状态。中央数据表示 我不知道多个单身人士的使用是否代表了设计缺陷,并希望对他们的使用或使用单个项目中的多个单身人士t。

答案一如既往地是它取决于。但是既然你提到了日志记录,那么你可能想要看一下面向方面的编程。一个站点是: http://www.aspectprogramming。 com / aop.html - Jay

I''m working on a large project(from scratch). The program is essentially a data file processor, the overall view is this: A data file is read in, validated and stored in a memory structure similar to a database or XML representation. Rules to modify the stored data will be executed, then the data will be transformed into an output format. Think something similar to FormatA -> XML -> Manipulate XML -> FormatB The project is large but so far I have been able to keep it very modular using OO design. I do however have questions about my use of singletons for certain aspects of the program. * I''ve found the use of singleton objects quite nice for various aspects of this program, I do enjoy having the ability to use a singleton class by using the Class::Instance() syntax, thus removing the need to pass instances around in all my function calls. Also very useful is the ability to use a guarenteed single instance by simply including the header containing my singleton. Right now I use them for : Logging server : A central message storage and distribution to N number of reports/logs) Program State : Again a central point to keep track of program status. Central Data representation I didn''t know if the use of multiple singletons could represent a design flaw and would like some opinions on their use or the use of multiple singletons in a single project. I know its vague, but without going into a verbose write-up I don''t know what else might be of value here. If there is a bit of information I can provide, just ask. Thank you, JF

解决方案

John Fly wrote:

I didn''t know if the use of multiple singletons could represent a design flaw and would like some opinions on their use or the use of multiple singletons in a single project.

www-128.ibm/developerwork...co-single.html

[X-posted to comp.object and followups set] John Fly wrote:

I''ve found the use of singleton objects quite nice for various aspects of this program, I do enjoy having the ability to use a singleton class by using the Class::Instance() syntax, thus removing the need to pass instances around in all my function calls. Also very useful is the ability to use a guarenteed single instance by simply including the header containing my singleton. The most important design feature is testability. Classes must rigorously decouple from each other to submit to test cases with very fine granularity. (You do _have_ test cases, don''t you?) Right now I use them for : Logging server : A central message storage and distribution to N number of reports/logs) Program State : Again a central point to keep track of program status. Central Data representation

To pass fake data into the modules that use those systems, would you push the fake data into the singleton, and let the modules use it? That situation could be improved. In general, if the reason to declare a Singleton is "because there''s only one of them", then test cases always violate this prerequisite because there''s always many of them! -- Phlip www.greencheese/ZeekLand <-- NOT a blog!!!

On Fri, 24 Feb 2006 11:17:18 -0800, John Fly wrote: <snip>

Right now I use them for : Logging server : A central message storage and distribution to N number of reports/logs) Program State : Again a central point to keep track of program status. Central Data representation I didn''t know if the use of multiple singletons could represent a design flaw and would like some opinions on their use or the use of multiple singletons in a single project.

The answer, as always, is "it depends". But since you mentioned logging, you may want to look at "aspect-oriented programming". One site is: www.aspectprogramming/aop.html - Jay

更多推荐

可以使用单身人士表示糟糕的项目设计吗?

本文发布于:2023-10-26 18:02:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530922.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   糟糕   单身   人士   项目

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!