DCI 架构有哪些可能的设计?
在不同的 OOP 语言中实现 DCI(数据、上下文、交互)架构的可能设计是什么?我想到了针对 C++、DI 和针对 Java 的 AOP 的基于策略的设计 (Andrei Alexandrescu)。然而,我也考虑过使用状态设计模式来表示角色和某种模板方法来进行交互......还有什么其他可能性?
What are possibles designs for implementation of the DCI (data, contexts, interactions) architecture in different OOP languages? I thought of Policy based design (Andrei Alexandrescu) for C++, DI and AOP for Java. However, I also thought about using State design pattern for representing roles and some sort of Template method for the interactions... What are the other possibilities?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在大多数语言中,进行纯 DCI 都很困难,您通常会遇到两个问题之一。静态类型语言(例如 Java)通常最终会产生某种包装解决方案,该解决方案创建 自我精神分裂症问题。允许您在运行时随意附加新实例方法的动态语言通常会遇到范围问题。当对象不再扮演角色时,RoleMethods 仍然可用。
据我所知,最适合不同语言的
如果您查看fullOO,您会找到示例用几种语言。包括我自己的项目 Marvin,这是一种专门为支持 DCI 而设计的语言。目前,Marvin 的大部分内容与 C# 相同,因此您可以说它是 C# 的扩展,而不是它本身的语言。
Doing pure DCI is tough in most language you usually run into one of two problems. Statically typed languages such as Java usually ends up with some kind of wrapper solution which creates a self schizofrenia problem. Dynamic languages that let you attach new instance methods at will at run time often suffers from a scoping issue. The RoleMethods are still available when the object is no longer playing the role.
Best fits I know of for different languages
if you take a look at fullOO you will find examples in a few languages. Including in my own project Marvin which is a language specifically designed to support DCI. At present most of Marvin is identical to C# so you could say it's an extension to C# more than a language of it's own right.
在Java中,如果没有字节码生成,我将使用装饰器模式作为上下文,但是我将代替类来装饰接口,这将更加灵活。数据将通过实现接口的类来表示。交互将通过手动依赖项注入模板方法来完成。
In Java, without byte-code generation, I would use Decorator pattern for contexts, however I will instead of classes decorate interfaces, which will be more flexible. Data than will be represented through classes implementing the interfaces. The interactions will be done using manual dependency injection into Template methods.