简体   繁体   English

如何在UML中将业务层映射到模型对象?

[英]How to map Business layer to Model objects in UML?

Just started with Star UML to draw a class diagram . 刚开始使用Star UML绘制class diagram

As with any application, MyBLL (business layer) creates an instance of Model after interacting with the DAO (database layer). 与任何应用程序一样, MyBLL (业务层)在与DAO (数据库层)进行交互之后创建Model的实例。

More or less, the simplified (for clarity) class diagram looks like this: 或多或少,简化的(为清楚起见)类图如下所示:

在此处输入图片说明

It is obvious that the model class will no longer be used after BLL is done. 显然,完成BLL之后将不再使用模型类。

  1. What should I use here? 我应该在这里使用什么? aggregation or composition while mapping MyBLL to MyModel . MyBLL映射到MyModel时进行aggregationcomposition

  2. I have used a composition relationship from MyBLL to MyDAO . 我使用了从MyBLLMyDAOcomposition关系。 My logic is after the BLL layer exists, MyDAO will no longer exist because it is referenced in MyBLL . 我的逻辑是在BLL层存在之后, MyDAO将不再存在,因为在MyBLL对其进行了引用。 Is this correct? 这个对吗?

Note: This is for a WebAPI project that I am creating using C#. 注意:这是针对我使用C#创建的WebAPI项目。

Aggregate means that the child CAN exist without the parent. 聚合意味着子代可以不存在父代而存在。 So, Classroom (parent) and Student (child) is the most common example. 因此,“ Classroom (父母)和“ Student (孩子)是最常见的例子。 Where you can have classrooms and students independently. 在这里您可以独立拥有教室和学生。

Composite means that the child CANNOT exist without the parent. 复合意味着子代不能不存在父代而存在。 So, House (parent) and Room (child) is the most common example. 因此, House (父母)和Room (孩子)是最常见的例子。 Where you cannot have a room without it being inside a house. 没有房间就不能在房间里的房间。

Without seeing exactly how you are coding this I am guessing that you will have this: 在没有确切看到您如何编码的情况下,我猜测您将拥有以下代码:

1) MyModel is probably a composite relationship because it is contained (with other models) within your MyBLL for its whole life. 1)MyModel可能是一个复合关系,因为它一生都包含在MyBLL中(与其他模型一起)。 When MyBLL goes out of scope so too does MyModel. 当MyBLL超出范围时,MyModel也将超出范围。

2) MyDAO is probably an aggregate because it can exist without MyBLL as it is used by other components? 2)MyDAO可能是一个聚合,因为它可以不存在MyBLL而存在,因为它被其他组件使用了吗? Ie It is probably created outside of your MyBLL by the host and injected into your BLL? 即它可能是由主机在您的MyBLL外部创建的,并已注入到您的BLL中?

Both of these statements may not be true based on the actual way your have architected your system. 根据您设计系统的实际方式,这两种说法可能都不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 业务对象和数据层 - Business Objects and Data Layer 如何在n层体系结构中将Entity Framework模型类与Business Layer类映射 - ASP.NET-MVC - How to map Entity Framework model classes with Business Layer class in n-tier architecture - ASP.NET-MVC 如何在业务逻辑层中设计数据传输对象 - How to Design Data Transfer Objects in Business Logic Layer 如何使我的业务对象层在其方法中使用管理层? - How can I get my business objects layer to use the management layer in their methods? 如何将实体框架中的数据访问映射到业务逻辑对象 - How to map Data Access to Business Logic objects in Entity Framework mvvm confustion与模型和业务层连接 - mvvm confustion with the model and business layer connection 简单的数据操作:在实体模型还是业务层? - Simple data manipulation: in Entity Model or Business layer? 我应该在业务层还是数据访问层新建数据库 model - Should i new database model in business layer or data access layer 如何改进映射到数据库的业务层对象? 是时候使用 O/R 映射器了吗? - How can I improve my business layer objects mapping into a database? Is it time for a O/R mapper? 在您的体系结构中,如何将URL与数据库层和业务对象层分离 - In your architecture, how do you decouple a url from the database layer & business objects layers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM