1

How to indicate that an interface is a part of class? Let's take this case as an example.

public class Function
{
     public interface Function2D
     {
            double GetValue(double x);
     }

     ...

}

Talking more precisely - I need to show the relationship between Function and Function2D in an UML class diagram.

0x6B6F77616C74
  • 2,559
  • 7
  • 38
  • 65

1 Answers1

2

This UML Quick Reference gives an indication of how to represent an Inner class in a UML diagram:

Inner Class diagram element

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
femtoRgon
  • 32,893
  • 7
  • 60
  • 87
  • How would an inner *static* class (that isn't used) be represented? Interfaces are like [static nested classes](http://stackoverflow.com/a/70358/2246674) (not to be confused with inner classes) in that they do not imply a binding with the parent type. – user2246674 May 02 '13 at 21:43
  • They're bound to parent class, not parent class object instance. – Jean Waghetti May 02 '13 at 21:47
  • @JeanWaghetti Why are they "bound"? What happens if the only creation/usage of such (interface type) happens from *outside* the class they are nested in? Is it accurate to still view such having any meaningful relationship? I feel that the relationships in the presented code cannot be sensibly stated. Perhaps the outer class could be viewed as a container (e.g. a package), if such UML diagram is simply showing relationships between naming containers. – user2246674 May 02 '13 at 21:47
  • The question is about inner interface. Should the lines be dashed? – 0x6B6F77616C74 May 02 '13 at 21:55
  • Well, it can not make sense. The same way a static inner class could not make sense. But it exists and have it's usage. (I'm not saying an inner static class does not make sense to me. It does. But when's was introduced to them, it took a while to understand them). – Jean Waghetti May 03 '13 at 02:52
  • @0x6B6F77616C74: The lines should not be dashed. The dashed line is only for interface realizations. This is a containment edge. – Carsten May 03 '13 at 08:16
  • 1
    @user2246674: That's exactly what the containment signifies here - the inner class uses the outer class as its namespace, much like another class has a package as its namespace. – Carsten May 03 '13 at 08:19