1

I have a generic class and many classes that uses that generic

public abstract class BaseEntity<Entity> {
    public int id;
    public abstract Entity index();
}

example of two classes

public class ClassA extends BaseEntity<ClassA>{
    public ClassA(int i) {
        id = i;
    }
    @Override
    public String toString() {
        return "I am a ClassA, my id is " + id;
    }

    @Override
    public ClassA index() {
        return this;
    }
}

and the other class

public class ClassB extends BaseEntity<ClassB>{
    public ClassB(int i) {
        id = i;
    }
    @Override
    public String toString() {
        return "I am a ClassB :D, my id is " + id;
    }

    @Override
    public ClassB index() {
        return this;
    }
}

Now how would I go about representing this in uml? right now I put the BaseEntity class as apstract, and added a small rectangle in top with dotted border and Entity inside it. My problem is the line between ClassA and BaseEntity. I looked around and found people putting a dotted line with <bind Entity > ClassA>. This seems logical to me but why is the line dotted as if it was an interface? wouldn't it be continuous?

my current implementation: enter image description here

RRR
  • 513
  • 2
  • 6
  • 14
  • 2
    If you want to understand how to make a UML Class Diagram, better don't "look around" for what "people are putting" on their diagram, but look up a good UML textbook or the UML specification. Your "bind Entity > ClassA" doesn't have any general meaning. – Gerd Wagner Oct 05 '19 at 17:29
  • Thank you! you are probably right. I have taken a class in the bast about UML design but we didn't get into generics at all. By looking around I meant that I looked at UML diagrams close to our project but found it unhelpful. I found the bind sentence in so many resources such as http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Defining_Generics_with_UML_Templates/article.html – RRR Oct 05 '19 at 17:40
  • 1
    The correct notation for a class to be bound to a *template class* (or "parametrized" class) in UML Class Diagrams is shown in https://www.uml-diagrams.org/class.html#class-template. Notice that the relationship between the bound class and the template class is visually expressed with a UML *Realization Dependency* arrow that is stereotyped with «bind». In addition to this stereotype keyword, the binding, in your example ClassA>, is expressed in left/right angles as an annotation to the arrow. However, in your example, you do have a second relationship: ClassA extends Entity. – Gerd Wagner Oct 05 '19 at 20:44

0 Answers0