UML帮助C#设计原则 [英] UML help C# Design Principles

查看:425
本文介绍了UML帮助C#设计原则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,下面理解的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#设计原则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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