Book a Demo

Author Topic: Describing Parameterized Interfaces  (Read 2838 times)

Emilio

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Describing Parameterized Interfaces
« on: November 08, 2008, 12:32:08 am »
In UML & EA there is a way to specify parameterized classes which in C# would translate to something like this:

      class ClassName <T> {
      {
              T data;
                 :
      }

As far as I know one can also define parameterized interfaces in UML which in C# would be something like this:

      interface IInterfaceName <T> {
      {
              T operation1();
              void operation2(T data);
                 :
      }

Unfortunately I don't see a way to do that using EA :-( I am currently doing a design where we want to define parameterized interfaces (instead of a class with generics) but can't find a way to specify this in UML.

Am I missing something?

Emilio

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: Describing Parameterized Interfaces
« Reply #1 on: November 08, 2008, 02:03:35 am »
Found a work around... If you choose the Interface icon from the toolbox you won't get the Details tab where you can add Parameterized template parameters.

Instead (workaround) choose the Class icon from the toolbox, change its stereotype to "interface" and subsequently go to the Details tab and add the necessary template parameters.

jjyoung

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Describing Parameterized Interfaces
« Reply #2 on: November 09, 2008, 01:01:26 am »
Here's code that I generated from a parameterized class constructed similar to what you were asking about (extra blank lines removed to protect the innocent) :

public class ClassName<T> {
      private T data;
      public ClassName(){
      }

      ~ClassName(){
      }

      public virtual void Dispose(){
      }

      public T operation1(){
            return null;
      }

      ///
      /// <param name="data"></param>
      public void operation2(T data){
      }
}//end ClassName

This can be done using Parameterised classes.  I just create a post on them in the Bugs form.  Check this post out on how to do it:
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1219999918

EDIT: I tried your method for the 2nd part of your question and it doesn't appear to work for generating paramterized interfaces.  This is the code I generated using a parameterized class with an <<interface>> stereotype:

public class IfClassName2<T> {
      public IfClassName2(){
      }
      ~IfClassName2(){
      }

                public virtual void Dispose(){
      }
}//end IfClassName2
« Last Edit: November 09, 2008, 01:22:11 am by jjyoung »