问题描述
我有一个问题,下面理解的UML:
I have a problem understanding an UML below:
具体是什么关系 PersistentSet
和 ThirdPartyPersistentSet
?
是什么持久性对象
之间的关系和 ThirdPartyPersistentSet
?
Specifically, what is the relationship between PersistentSet
and ThirdPartyPersistentSet
?What is the relationship between PersistentObject
and ThirdPartyPersistentSet
?
请注意,UML是敏捷原则,模式和做法在C#
到C.马丁罗伯特·马丁2006年弥迦第10章
Please note that the UML is from Agile Principles, Patterns, and Practices in C#By Martin C. Robert, Martin Micah 2006. Chapter 10
提前感谢!
推荐答案
PersistentSet和ThirdPartyPersistentSet之间的关系是一种聚合,这意味着PersistentSet包含一个或多个ThridPartyPersistenSet实例。这是一个弱的关系,这意味着ThirdPartyPersistentSet的实例可以存在PersistentSet之外。
The relationship between PersistentSet and ThirdPartyPersistentSet is an Aggregation, which means the PersistentSet contains one or more ThridPartyPersistenSet instances. This is a "weak" relationship, meaning the instances of ThirdPartyPersistentSet can exist outside of the PersistentSet.
持久性对象和ThirdPartyPersistentSet之间的关系是一个依赖,这意味着基本上ThirdPartyPersistentSet需要。持久性对象做的工作。
The relationship between PersistentObject and ThirdPartyPersistentSet is a Dependency, meaning basically ThirdPartyPersistentSet needs a PersistentObject to do it's work.
那么,把这种代码,您PersistentSet将包含这样的:
So, to translate this to code, your PersistentSet would contain something like this:
public class PersistentSet
{
public List<ThirdPartyPersistentSet> Items { get; }
...
}
和您的ThirdPartyPersistentSet会是这个样子
And your ThirdPartyPersistentSet would look something like this:
public class ThirdPartyPersistentSet
{
private PersistentObject _object;
public ThirdPartyPersistentSet(PersistentObject obj)
{
_object = obj;
}
...
}
这篇关于UML帮助C#设计原则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!