Inheritance in Enterprise Architect
I have a class within a package. And I have another class in another package. I would like to link this second class to first. Since the first is a l开发者_运维知识库egacy of the second. I'm not able to make this relationship. We tried, but in neither case are the methods of the second brought the first.
Any help is welcome. Thanks
Class A Class BThe ownership of Class A, should be visible within the class B. Where A and B are in different folders. And B, I put an "Instance" of A.
Apparently, you need to create this relationship in some diagram that contains both classes. Remember, you can have multiple diagrams that link to one and the same class in some (other) package / namespace.
Either create a new diagram that exclusively handles the inheritance (and other relationships) as described in here: http://www.sparxsystems.com/WhitePapers/Version_Control.pdf
Or, you just drag the foreign class onto the diagram you are currently working on, create the relationship and then remove the foreign class afterwards. The relationship will persist. Note that you should not drag/drop/delete the class in the project view as this will lead to changes in the packages.
The first solution has the advantage that there is an actual UML representation of the relationship. On the other hand, adding another bunch of diagrams for just the cross-package relationships might clutter the project view but this is up to you after all :)
What sort of link are you trying to establish (what's the nature of their relationship), and for what purpose?
- If one calls another directly then maybe you're after a dependency.
- If it's inheritance then try a generalization link.
Edit: I haven't yet used EA for any forward-engineering so I'm not sure of the best way to do what you're after, but I did get it to partly work:
- Form a link between to classes by dragging the new path arrow from the child class over the parent class.
- From the context menu that pops up select generalization
- The "Overrides and Implementation" dialog should appear.
- Select the methods you want to bring across.
I tried this and it worked - but only for the methods not for the attributes I'd created.
I've searched for a solution to add the inheritance manually, e.g.: I´ll see the IDisposable - interface
in C#
on my class or interface without I've this interface in my project declared.
You can do this by following: Select the class or interface and press [STRG + I] or select the class/interface in diagram an go over context menu: Advanced -> Parent.
In the following dialogue you can select a class, interface from your project or type an new Name
in the text filed, select the Generalize
or Implements
from drop down and press Add
.
Enterprise Architect 12
精彩评论