What are the possible designs for DCI architecture?

What are the possible options for implementing the DCI architecture (data, contexts, interactions) in different OOP languages? I was thinking of policy-based development (Andrei Alexandrescu) for C ++, DI, and AOP for Java. However, I also thought about using a state design template to represent roles and a kind of template method for interacting ... What are the other options?

+4
source share
2 answers

In Java, without generating byte code, I would use the Decorator template for contexts, but instead of classes, I will decorate interfaces that will be more flexible. Data to be represented through classes that implement interfaces. Interactions will be performed using manual dependency injection in template methods.

+2
source

Running pure DCI is tough in most languages, and you usually run into one of two problems. Statically typed languages, such as Java, usually end up with some kind of wrapping solution that creates a problem for self schizofrenia . Dynamic languages, which allow you to attach new instance methods of your choice at runtime, often suffer from problems with defining scope. RoleMethods functions are still available when the object no longer plays a role.

The best option I know for different languages

  • Marvin: Design for DCI and, as such, has full support.
  • Cut with the help of Maroon. If you use maroon gem (or similar), then there is full DCI support in Ruby.
  • Java: Qi4J
  • C # Extension methods (constraint problem and overload problem), possibly together with dynamic ones. I had a Clay based implementation, but this creates an authentication problem
  • Native Ruby: injection method. Oscillogram with methods available when the object no longer plays a role.
  • C ++: Templates. The lifespan of the method for determining the scale coincides with the lifespan

if you look at fullOO you will find examples in several languages. Including in my own project Marvin, which is a language specifically designed to support DCI. Currently, most of Marvin is identical to C #, so you can say that the extension to C # is more than its own language.

+6
source

Source: https://habr.com/ru/post/1306025/


All Articles