Nonsensical message

dubwai
2007-07-23
2013-04-29
  • dubwai
    dubwai
    2007-07-23

    I just tried using Green UML and the first thing I tried to do was create a composition from a class to an interface.  Green tried to make me pick a concrete type.  I'm not sure where that's coming from but this tool is useless to me if I can't define a composition of objects of an interface type.  That's probably the most common kind of thing people should be doing in a design.  Why this would be restricted is a great mystery.

     
    • Carl Alphonce
      Carl Alphonce
      2008-01-31

      You can do this, but because of the way Green works (it is a live round-tripping tool) it must be able to generate code for the composition when you draw the relationship.  Green (or rather, the semantics of the composition relationship) is smart enough to realize that it cannot instantiate an interface.  If you want to create a composition relationship between class A and interface I, which has as a concrete implementation B, Green will generate in class A:

        an instance variable (field) of type I
        an initialization of that variable to a new B() in A's constructor

      I do notice, however, that there seems to be a problem with this in the 3.0.0 release, which is odd.  We will look into this.