DDD和SOA真的可以很好地发挥作用吗? [英] Do DDD and SOA really play well together?

查看:233
本文介绍了DDD和SOA真的可以很好地发挥作用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请让我知道,如果我完全搞砸了DDD概念,但这是我的难题。

Please let me know, ever so gently, if I am totally mangling the DDD concept, but here is my dilemma.

假设我具有以下域模型:

Let's say I have the following domain model:

Teacher
  IList<Class>

Class
  Teacher
  IList<Student>

Student
  Class

现在,从DDD的角度来看,看来老师是我的根源,实际上,在一个简单的应用程序中,我可能会随老师和她的班级和学生一起学习,并根据需要对他们采取行动。但是,在SOA情况下,假设我出于展示目的(例如dto)撤消了我的老师,她的班级和学生,并且她想添加一名学生。当然,我不会将整个对象图发送到服务器并从数据库中检索域对象只是为了添加新学生,对吗?

Now, from a DDD perspective, it seems like the Teacher is my root, and indeed, in a simple app, I might carry around my Teacher with her classes and students and act on them as needed. But in an SOA situation, let's say I've pulled down my Teacher, her classes and students for display purposes (as dtos), and she wants to add a student. Surely I am not going to send the whole object graph up to the server and retrieve the domain objects from the database just so that I can add a new student, right?

这里最甜蜜的地方在哪里,还是我完全想念小船?

Where is the sweet spot here, or am I totally missing the boat?

谢谢!

后期更新:也许我正在回答自己的问题,但是我猜一种方法是让我的Teacher服务具有各种学生管理方法(AddStudent,UpdateStudent),这样我的根是仍然管理一切,而不是为每个对象提供一项服务。

Late Upate: Maybe I'm answering my own question, but I guess one approach is to have my Teacher service have various student management methods (AddStudent, UpdateStudent) such that my root is still managing everything instead of having one service per object.

推荐答案

您正在考虑性能,但是您会感到惊讶。在我的SOA Web服务中,我使用了这样的完整对象图,并且性能在可接受的范围内。我建议使用业务对象和业务Web方法,例如 SaveTeacher(Teacher t),除非出于性能原因而绝对需要使用DTO以及相关的CRUD Web方法,例如 AddStudent(长教员ID,学生)

但是,即使以后使用,也可以通过从持久性存储中加载给定TeacherID的教师来应用DDD概念,并附加学生并将老师保存到持久性存储中。

You are thinking about performance, but you will be surprised. In my SOA web services I use such complete object graphs and performance is well within acceptable limits. I would suggest to use business objects and business web methods like SaveTeacher(Teacher t) unless absolutely required to use DTOs for performance reason and associated CRUD web methods like AddStudent(long teacherId, Student student)
But even if using the later you can apply the DDD concept by loading the teacher from your persistence store given the teacherId, attaching the student and saving the teacher back to persistence store.

这篇关于DDD和SOA真的可以很好地发挥作用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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