什么是DCI以及它如何能够适应使用Rails? [英] What is DCI and how can it fit with Rails?

查看:330
本文介绍了什么是DCI以及它如何能够适应使用Rails?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关不同的方法的同事最近的辩论,以设计和code在Rails应用程序模型给我带来跨越的 DCI在Rails的情况下。

A recent debate with a co-worker about different approaches to design and code the models in a Rails application brought me across DCI in the context of Rails.

不过,我好像不能换行我的头周围的整个概念,甚至将超过此示例应用程序后,

However, I just can't seem to wrap my head around that entire concept, even after going over this example application.

目前,我倾向于只是去或多或少的经书写一个Rails应用程序时。

Currently, I tend to just go more or less "by the book" when writing a Rails app.

因此​​,有几件事情我想问问 -

So there are a few things I'd like to ask --


  • 什么是DCI,什么是它的优势,当MVC一起在普通的旧MVC(和Rails的ActiveRecord的香草)?实施

  • 以及它如何在Rails中实现(或者换句话说,什么是与所有的模块的)?

  • What is DCI and what are its advantages when implemented alongside MVC over plain old MVC (and vanilla ActiveRecord in Rails) ?
  • And how can it be implemented in Rails (or in other words, what's with all the modules) ?

修改

我想进一步扩大我在回报率的情况下的问题 - 是模型和Rails的控制器之间的抽象另一个层面建议?如何wides $ P $垫是它在不同规模的应用?

I'd like to even further expand my question in the context of RoR - is another level of abstraction between the models and the controllers in Rails recommended? How widespread is it in different-scale applications?

推荐答案

DCI是一个范例,因此远比一个方法来设计一个应用程序。这是考虑建模方法,以及结构化code。一个DCI的重要组成部分,是保持什么样的系统(域模型)和系统做什么(功能性)分开。 DCI是不是一种不同的方法解决同样的问题MVC让你的第一个问题不能真正回答。您可以同时使用MVC和DCI这不是巧合,因为特里夫Renskaug既MVC和DCI的父亲。最近,他回答了一个<一个href=\"http://groups.google.com/group/object-composition/browse_thread/thread/ce934f6fd3e7cc90/d38ccb6fd523e05f?show_docid=d38ccb6fd523e05f&pli=1\">similar在谷歌集团的对象组成问题了这一点。

DCI is a paradigm and hence much more than a way to design an application. It's a way to think about modelling as well as structuring code. One of the important parts of DCI is keeping what the system is (the domain model) and what the system does (functionality) apart. DCI is not a different approach to solving the same problem as MVC so your first question can't really be answered. You can use MVC and DCI simultaneously which is no coincidence since Trygve Renskaug is the father of both MVC and DCI. He recently answered a similar question to this on the google group 'object-composition'.

您已经联系到的例子违反了一些基本思路如保持角色私有的环境,我不能真正找到一个单一的情况下要么但是这可能是由于消费只有很短的时间浏览code。

The example you've linked to violates some of the basic ideas such as keeping roles private to the contexts and I couldn't actually find a single context either but that could be due to spending only a short time browsing the code.

我不知道回报率我自己,所以我不能给你一个RoR的例子,但如果你去 fullOO 你会发现用不同的语言,包括Ruby和马文专为DCI第一语言的例子。

I don't know RoR my self so I can't give you an RoR example but if you go to fullOO you'll find examples written in different languages including both Ruby and Marvin the first language designed for DCI.

修改有没有简单地回答这个问题:什么是DCIDCI是一个范例,就像OOP是一个范例。它们都具有相同的根和回答上面的问题是回答什么是对象orie​​ntented编程为复杂。事情更加复杂的事实,DCI是面向对象和OOP在所有主要的面向对象语言实际上是类导向,不是面向对象的。 DCI目的在于赢得code其中在运行时间之间的对象的交互是在编译时间和更笼统地试图在code可见mkae更容易推理的运行时间从阅读code行为。该网站我已经联系到上面是解释什么DCI是所有关于并且还列出了一些语言的例子。红宝石是其中之一。

EDIT There's no simply answer to the question "What is DCI" DCI is a paradigm, just like OOP is a paradigm. They both have the same roots and answering the above question is as complicated as answering "What is object orientented programming". Things are even more complicated by the fact that DCI is object oriented and OOP in all the major OO languages is actually class oriented and not object oriented. DCI aims at producing code where the interaction between objects at run time is visible in the code at compile time and in more general terms tries to mkae it easier to reason about the run time behavior from reading the code. The site I've linked to above is devoted to explaining what DCI is all about and also lists examples in a number of languages. Ruby being one of them

修改有一个关于红宝石和DCI一个它的方式。作者是pretty活跃对象的组成和insightfull

EDIT There's a book on ruby and DCI on it's way. The author is pretty active on object-composition and insightfull

这篇关于什么是DCI以及它如何能够适应使用Rails?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆