[英]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之后将不再使用模型类。
What should I use here? 我应该在这里使用什么?
aggregation
or composition
while mapping MyBLL
to MyModel
. 将
MyBLL
映射到MyModel
时进行aggregation
或composition
。
I have used a composition
relationship from MyBLL
to MyDAO
. 我使用了从
MyBLL
到MyDAO
的composition
关系。 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.