简体   繁体   English

关系图是否正确

[英]Class Diagram if the relationships are correct

I created a Class Diagram. 我创建了一个类图。 This is just a concept but i want to know if the relationship are correct and if i fully understand it. 这只是一个概念,但我想知道这种关系是否正确以及我是否完全理解它。

MainClass 主类

  • CreateClassA(); CreateClassA(); creates ClassA with new ClassA(); 用新的ClassA()创建ClassA;
  • CreateClassB(); CreateClassB(); creates ClassB with new ClassB(); 用新的ClassB()创建ClassB;
  • getConcreteFromCreator(); getConcreteFromCreator(); get the concrete class from creator. 从创建者那里得到具体的课程。 The creator has a switch case to determine which concrete class to return. 创建者有一个转换案例来确定要返回的具体类。
    • After the class is returned then call it for example (Abstract callConcrete = new ConreateA()) 返回该类后,请进行调用(例如,抽象callConcrete = new ConreateA())
  • CreateClassAA(); CreateClassAA(); creates ClassAA with Interface createClassAA = new ClassAA(); 使用接口createClassAA = new ClassAA()创建ClassAA;

ClassAA AA级

  • ClassAA creates classBB with new ClassBB(); ClassAA使用新的ClassBB()创建classBB;

Relationship from ClassAA to ClassBB is this suppose to be a composition? 这是从ClassAA到ClassBB的关系吗? since the classAA is the creator of ClassBB and it depends on it from existing The relation between InterfaceAA and ClassAA is realization. 因为classAA是ClassBB的创建者,并且它依赖于现有的ClassBB,所以InterfaceAA和ClassAA之间的关系是实现。 I wasn't able to draw the line using NClass diagram. 我无法使用NClass图画线。

Class Diagram 类图

  1. Relation between ClassAA and ClassBB is composition only in case the instance of ClassBB created by ClassAA is stored inside ClassAA and not shared with external entities. 仅在由ClassBB创建的ClassAA实例存储在ClassAAClassAA与外部实体共享的情况下, ClassAAClassBB之间的关系才是组合。 In this case it would be good OO practice to hide this implementation detail and perform the necessary initialization inside the ClassAA 's constructor or a dedicated Initialize method. 在这种情况下,最好的做法是隐藏该实现的详细信息,并在ClassAA的构造函数或专用的Initialize方法内执行必要的初始化。
  2. Don't know anything about NClass, but realization is specified by a dashed line with a hollow triangle pointing to interface. 对NClass一无所知,但是实现是通过带有空心三角形指向接口的虚线指定的。 Based on the screenshots on their site, it is supported. 支持基于他们网站上的屏幕截图。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM