3

Suppose I have an aggregate type and I want to use it in conjunction with a template iterator. The following C# code gives an exact example of my model:

public interface Iterable<T>
{
    Iterator<T> iterator();
}

public abstract class Letter
{
}

public abstract class Alphabet : Iterable<Letter>
{
    public abstract Iterator<Letter> iterator();
}

public abstract class Iterator<T>
{
    public abstract void first();
    public abstract void next();
    public abstract bool done();
    public abstract T get();
}

But I have a little problem when capturing this in UML. The problem is that I'm not sure how to combine two relationships between Alphabet and Iterable: Template Binding and Realisation. I ended up in depicting them separetly but for that I had to introduce two intermediate entities for that and this looks a bit clumsy.

enter image description here

You see these new interface AlphabetIterable (binds Iterable with Letter) and class AlphabetIterator (binds Iterator with Letter).

Is there a way to make an equivalent UML model without these two intermediates?

  • Thanks, @Snowman. I considered erasing the watermark, but my OCD gene wasn't activated this morning. – Robert Harvey Feb 22 '15 at 17:32
  • @RobertHarvey I thought about that too, but a quick pass did not work very well due to jpeg compression adding fuzz around the edges of the text. – user22815 Feb 22 '15 at 18:12
1

The picture below shows how Sparx Systems Enterprise Architect's code reverse engineering visualizes the relationship between Alphabet and Iterable when fed with your code snippet.

enter image description here

I've added the «bind» stereotype manually to make it compatible with

www.omg.org/spec/UML/2.5/Beta27.3.4 Common Structure → Templates → Notation

...

A TemplateBinding is shown as a dashed arrow with the tail on the bound element and the arrowhead on the template and the keyword «bind». The binding information may be displayed as a comma-separated list of template parameter substitutions:

<template-param-substitution> ::= <template-param-name> ‘->’ <actual-template-parameter>

...

See also:

| improve this answer | |
  • 1
    That was as easy as falling off a log. :-) I'm only starting learning UML and using Enterprise Architect and haven't tried this feature yet. Thank you, @xmojmr! – krokoziabla Feb 22 '15 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.