请问关于c的具体应用场景有哪些?

2026-04-29 01:162阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计449个文字,预计阅读时间需要2分钟。

请问关于c的具体应用场景有哪些?

在创业层解决方案时,我更倾向于使用DTO而非直接公开业务对象。一方面,我不愿直接双重定义对象和编写重复代码。现在,我的想法是编写包含所有必要字段和属性的DTO包,但尚未实现逻辑。

在创建n层解决方案时,我不想公开我的业务对象,而是使用DTO而不是这个.另一方面,我不想一直双重定义对象和编写复制代码.

现在我的想法是编写包含所有必要字段和属性的DTO,但没有逻辑(只有状态).

然后我将从这些DTO派生我的业务对象,使用我的业务逻辑扩展它们,处理DTO基类属性.这些对象也将是所使用的ORM中持久存在的对象(NHibernate).

使用这种方法,在服务器端,我可以处理业务对象并将它们直接传递给客户端(它们是派生的,因此可以向下转换).我不会被迫以这种方式暴露我的业务逻辑并节省大量代码.

你认为这种做法是明智的吗?

问候,

塞巴斯蒂安

您可能需要考虑以下事项:

请问关于c的具体应用场景有哪些?

“…,
because keeping the DTO unaware of the
domain objects enables you to reuse
the DTO in different contexts.

Likewise, you do not want the domain
objects to know about the DTO because
that may mean that changing the DTO
would require changing code in the
domain logic
, which would lead to a
maintenance nightmare.

The best solution is to use the Assembler pattern, which creates DTOs from business objects and vice versa. Assembler is a specialized instance of the Mapper pattern also mentioned in Patterns of Enterprise Application Architecture….”

从Pattern and Practice: Data Transfer Object

另外,我自己没有使用它,但你也可以查看AutoMapper.

本文共计449个文字,预计阅读时间需要2分钟。

请问关于c的具体应用场景有哪些?

在创业层解决方案时,我更倾向于使用DTO而非直接公开业务对象。一方面,我不愿直接双重定义对象和编写重复代码。现在,我的想法是编写包含所有必要字段和属性的DTO包,但尚未实现逻辑。

在创建n层解决方案时,我不想公开我的业务对象,而是使用DTO而不是这个.另一方面,我不想一直双重定义对象和编写复制代码.

现在我的想法是编写包含所有必要字段和属性的DTO,但没有逻辑(只有状态).

然后我将从这些DTO派生我的业务对象,使用我的业务逻辑扩展它们,处理DTO基类属性.这些对象也将是所使用的ORM中持久存在的对象(NHibernate).

使用这种方法,在服务器端,我可以处理业务对象并将它们直接传递给客户端(它们是派生的,因此可以向下转换).我不会被迫以这种方式暴露我的业务逻辑并节省大量代码.

你认为这种做法是明智的吗?

问候,

塞巴斯蒂安

您可能需要考虑以下事项:

请问关于c的具体应用场景有哪些?

“…,
because keeping the DTO unaware of the
domain objects enables you to reuse
the DTO in different contexts.

Likewise, you do not want the domain
objects to know about the DTO because
that may mean that changing the DTO
would require changing code in the
domain logic
, which would lead to a
maintenance nightmare.

The best solution is to use the Assembler pattern, which creates DTOs from business objects and vice versa. Assembler is a specialized instance of the Mapper pattern also mentioned in Patterns of Enterprise Application Architecture….”

从Pattern and Practice: Data Transfer Object

另外,我自己没有使用它,但你也可以查看AutoMapper.