是什么域对象,波苏斯和实体之间的区别? [英] What is the difference between domain objects, POCOs and entities?

查看:241
本文介绍了是什么域对象,波苏斯和实体之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是IM pression下,他们都基本相同。是模型对象也一样吗?

I was under the impression they are all basically the same. Are model objects also the same?

现在,在我的建筑,我有:

Right now, in my architecture, I have:

class Person 
{

    public string PersonId;        
    public string Name;
    public string Email;

    public static bool IsValidName() { //logic here}
    public static bool IsValidEmail() { //logic here }
}


class PersonService
{
    private PersonRepository pRepository;

    PersonService()
    {
        pRepository = new PersonRepository();
    }

    public bool IsExistingEmail(string email)
    {
        //calls repo method to see if email is in db
    }


    public Person GetPerson(email)
    {
        return pRepository.Get(email);
    }


    public void SavePerson(Person p)
    {
        if (Person.IsValidEmail(p.Email) && !IsExistingEmail(p.Email)
        {
            pRepository.Save(p);
        }
    }

}


class PersonRepository
{
    public void Save(Person p)
    {
        //save to db
    }

    public Person Get(string email)
    {
        //get from db
    }

    public bool IsExistingEmail(string email)
    {
        //see if email in db
    }

}

因此​​,这上面的类都是POCO,域对象,Model对象,实体?

So which of the above classes are POCO, Domain Object, Model object, entity?

推荐答案

这些是主要是在使用术语(分布式)领域驱动设计。它们是不相同的。术语的模型对象的可作为的代名词到的域对象

These are terms that are largely used in (Distributed) Domain Driven Design. They are not the same. The term model Object can be used as a synonym to the domain object.

域对象。从重新present一些有意义的事领域专家的业务特定区域的对象。域对象大多是由重实体和值对象psented $ P $。 Generaly来说,生活在领域层的大多数对象模型有贡献,而且域对象。

Domain Objects. Objects from the business specific area that represent something meaningful to the domain expert. Domain objects are mostly represented by entities and value objects. Generaly speaking, most objects that live in domain layer contribute to the model and are domain objects.

实体。的对象从根本上由其属性来定义,而是由连续性和身份的线索。的(这意味着它必须有无编号

Entity. An object fundamentally defined not by its attributes, but by a thread of continuity and identity. (Meaning it must have Id)

POCO。无需复杂的逻辑简单的对象,它不需要被识别的,通常它只有几个属性,并用于与ORM或数据传输对象

POCO. A simple object without complicated logic which doesn't require to be identifiable, usually it has just a few properties and is used with ORM or as a Data Transfer Object

更新

类人 - 实体与POCO,这个类的一个实例是域对象

类PersonService - 服务

类PersonRepository - 库

UPDATE
class Person - Entity and POCO, instance of this class is Domain Object
class PersonService - Service
class PersonRepository - Repository

这篇关于是什么域对象,波苏斯和实体之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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