Visual Studio UML Class Diagram & Modeling of Generic Types

荒凉一梦 提交于 2019-12-13 11:34:12

问题


I need to model a concrete generic class inheriting from a base generic class. First, see below:

ActivityFacade should be implemented this way:

public class ActivityFacade : BaseFacade<Activity, int>
{
}

How can I model this in a VS2012 UML class diagram? Looking at the diagram, it is obvious that ActivityFacade inherits from BaseFacade, but what's not obvious is the generic type parameters that it is passing in, namely: Activity and int.


回答1:


You need to add a new binding class (BaseFacade <Activity, int>) connect it to your parameterized class (BaseFacade<T, TKey>) with a template binding connector and then specialize your child class (ActivityFacade) from the binding class.

From the OMG UML specification

"A template is a parameterized element ... used to generate other model elements using TemplateBinding relationships. The template parameters for the template signature specify the formal parameters that will be substituted by actual parameters (or the default) in a binding."

UPDATE:

The diagram I included is drawn using EA. The same concept can be modeled in Visual Studio UML tool. See the section "Template types: To use a template type" in msdn.



来源:https://stackoverflow.com/questions/15330957/visual-studio-uml-class-diagram-modeling-of-generic-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!