在类中组织的某些进程的配置与单个类的比较
在我的应用程序中,我使用一个类来保存某些进程的配置。现在,我试图将其分解为更小的和平,正如您在下面的类图中看到的那样:
- 你觉得这个设计模式可以吗?
- FilterOnOff 类怎么样?
- 我应该使用结构吗?在这种情况下,我将无法从 FilterOnOff 派生来获取“活动”状态。
In my app I'm using a single class that holds the configuration for some process. Now, I'm trying to break it in smaller peaces, as you can see in the class diagram below:
- Do you think this design pattern is ok?
- What about the FilterOnOff class?
- Should I use structs? In this case I will not be able to derive from FilterOnOff to get the "Acttive" state.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是猜测,您将配置的类管理器分割成更小的部分,以便能够保留某些特定实体的一小部分配置,而不是所有信息,这可能与该实体不相关。
在这种情况下:
没有看到严重的问题,也因为很难说一些真正有用的东西,因为这取决于你的应用程序的结构。
如果您认为您的案例中属性的共享域由单个
Active
属性组成,那就没问题。不,不要使用结构。例如,结构在某些情况下可以用来提高性能,因为堆栈分配非常快。对于配置管理来说,情况并非如此。使用 C# 中的引用类型为您提供的充分灵活性。
希望这有帮助。
Just guess, that you split class manager of configuration into smaller pieces, in order to be able to persist a smaller piece of configuration of some specific entity, and not all information, which is probably not relevant to that entity.
In this case:
Don't see serious problems, also cause it's difficult to say something really useful, cause depends how your app is structured.
If you think that the shared domain of the properties in your case consist of single
Active
property, it's ok.No, do not use structs. Structs can be useful, for example, to boost a performance in several cases, as stack allocation is really fast. For configuration management it's not a case. Use full flexibility which given to you by reference types in C#.
Hope this helps.