Enterprise Architect 8 > Displaying Inheritance Chain for a Class
Asked Answered
H

2

1

I have imported a PHP source folder into Enterprise Architect. Now, I'd like to see the inheritance chain of any specific class. In other words, I'd like to see one big diagram displaying all relations of a class. Most classes are in folders separate from the parent/child class. How can I do that..?

This was my reason for installing Enterprise Architect: I get confused within a lengthy and branched inheritance chain. It would be very disappointing if such a powerful tool that recognizes all relationships could not give an overview of these relationships.

For example, I can see a class diagram in the root of one folder, illustrating aggregation. However, the aggregated classes listed are only those located in the same folder as the parent class.

Thank you in advance.

Hypogeal answered 25/9, 2012 at 14:20 Comment(5)
You could try with Phpstorm, it has some class diagrams as well: jetbrains.com/phpstorm/webhelp/working-with-diagrams.htmlMendicant
Ok, so I used PHP_UML to generate a XMI file. I also tried the HTML format, but it includes the documentation. I need an overview class diagram. Simple.Hypogeal
I started a parallel, more generic thread hereHypogeal
Please do not duplicate questions. Also keep your question precise, there is no need to generalize the topic, in fact I'd say that is counter-productive.Mendicant
hakra, agreed that generalization of topic is counter-productive. However, I do not see a way to make the question more specific, as at this point the title illustrates exactly what I am trying to achieve. Since I do not know how, I cannot ask about any specific method. Should you see a better way to ask this question, please don't hesitate to suggest.Hypogeal
A
3

This answer applies to EA 9.3. I don't have an old EA 8 lying around but EA is eminently backwards-compatible, so you should upgrade in any case.

There are a couple of ways to follow inheritance chains in EA.

Method 1: add classes to the same diagram.

In a diagram containing the root class of your inheritance hierarchy, right-click the root class and select Add - Related Elements. In the "Insert Related Elements" dialog, select the length of chain ("levels") you want, up to a maximum of 5. Specify "link type" Generalization. You can leave the other options as they are, or play around with them if you like.

This will cause EA to add those classes to the diagram which inherit from the root class in up to 5 steps/levels. You don't have to start from a root class; the option "link direction" in the dialog controls whether relationships should be followed in one or both directions.

You can use this same function to add classes related through other relationships, such as aggregations.

Method 2: Use the Traceability window.

In the main menu, select View - Traceability. This opens the Traceability window, which is a tree view with the currenty selected element at the top, and nodes for all related elements in a hierarchy.

Select the root class and violà, all its inheriting classes are shown as child nodes in the Traceability window, and you can expand them in turn to follow the chains further.

Method 1 puts the information in diagrams, where it is kept and needs to be updated. Method 2 is dynamic and more usefu when you need to check a specific relationship chain.

The relationships in a diagram are automatically updated if the underlying model changes, so if for instance you change the code and reimport it, this will be reflected in the diagram. To be on the safe side, always work with manually created diagrams in a separate package from the source package.

Ashantiashbaugh answered 26/9, 2012 at 3:51 Comment(1)
Thank you, this seems to be almost exactly what I want. However, if possible, I would like to see the whole inheritance chain. In other words, I would like to see more (all) than the 5 levels in any direction. The traceability window is doing that, but not in the form of a diagram. If that would be possible, this would be exactly what I want.Hypogeal
M
0

Am not sure if there is existing solution but is something you can easily implement using ReflectionClass and Google Graph

Example

class A {
}
class B extends A {
}
class C extends B {
}
class D extends C {
}
class E extends D {
}
class F extends E {
}

function getPath($className) {
    $class = new ReflectionClass($className);
    $name = $class->getParentClass();
    if ($name) {
        echo $class->getName(), " extends ";
        getPath($name->getName());
    } else {
        echo $class->getName();
    }
}

getPath("C");
getPath("F");

Output

C extends B extends A
F extends E extends D extends C extends B extends A
Multifoliate answered 25/9, 2012 at 15:0 Comment(3)
Baba, I don't need to know this programmatically. I need a visual representation so that I can be better oriented in what I'm doing.Hypogeal
What is "Google Graph"? Care to share a link?Mendicant
I imagine that this is what is meant by Google Graph. Looks very cool. This is a JavaScript API for the graph service.Hypogeal

© 2022 - 2024 — McMap. All rights reserved.