DCI 架构有哪些可能的设计?

发布于 2024-08-28 02:17:13 字数 156 浏览 6 评论 0原文

在不同的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最单纯的乌龟 2024-09-04 02:17:13

在大多数语言中,进行纯 DCI 都很困难,您通常会遇到两个问题之一。静态类型语言(例如 Java)通常最终会产生某种包装解决方案,该解决方案创建 自我精神分裂症问题。允许您在运行时随意附加新实例方法的动态语言通常会遇到范围问题。当对象不再扮演角色时,RoleMethods 仍然可用。

据我所知,最适合不同语言的

  • Marvin:为 DCI 设计,因此完全支持
  • 使用 Maroon 的 Ruby。如果您使用 栗色 gem (或类似版本)然后,Ruby 中完全支持 DCI。
  • Java:Qi4J
  • C# 扩展方法(范围问题和重载问题)可能与动态方法一起使用。我有一个基于 Clay 的实现,但这会产生身份问题
  • Native Ruby:方法注入 当对象不再扮演
  • C++:模板角色时,方法可用的范围问题。范围问题方法的生命周期与对象生命周期相同,

如果您查看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

  • Marvin: Design for DCI and as such has full support
  • Ruby using Maroon. If you are using the maroon gem (or similar) then there's full support for DCI in Ruby.
  • Java: Qi4J
  • C# Extension methods (Scoping issue and overload issue) possibly together with dynamic. I've had an implementation based on Clay but that creates an identity problem
  • Native Ruby: Method injection Scoping issue with methods being available when the object no longer plays the role
  • C++: Templates. Scoping issue method life span is the same as the object life span

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.

鹿港巷口少年归 2024-09-04 02:17:13

在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文