Book a Demo

Author Topic: About Interface behaviour in EA  (Read 4211 times)

Emilio

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
About Interface behaviour in EA
« on: January 29, 2009, 03:44:24 am »
I have a slight problem with depicting interfaces in Enterprise Architect v7.1.831.

Basically there are two ways to paint an interface object on the UML diagram using the toolbox:

  • Drop a class and change its prototype field to 'interface'
  • Drop an interface

In both cases you see the same figure, so far so good but there are differences that are annoying and inconsistent:

  • If you use a class prototyped as 'interface' you can make use of generics (template parameters) as supported by some languages like C#. This means in the class properties a "Details" tab appears where you can add Parameterized items.
  • If you use an interface you cannot use template parameters as described above which limits the usability of this toolbox item.
  • When using a class prototyped as 'interface' the icon on the project browser is that of a class and not of an interface.
  • If you dropped an interface from the toolbox the project browser will show an interface icon for the object (as expected).

Have these been solved in a newer release? and if not, any plans to solve those inconsitencies?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: About Interface behaviour in EA
« Reply #1 on: January 29, 2009, 05:28:22 am »
I seem to be able to get this working, but have not done it for a while. If memory serves [it could happen...] you need to either use a different toolbox item for the interface element, or to use rectangle notation, or both.
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: About Interface behaviour in EA
« Reply #2 on: January 29, 2009, 08:30:54 am »
Basically, EA does not yet support generics/templates on interfaces.

A class with the stereotype of interface is NOT an interface, and code engineering will not treat it as an interface.

Emilio

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: About Interface behaviour in EA
« Reply #3 on: January 29, 2009, 06:23:26 pm »
Well, it seems like a valid construct:

a) Select the CLASS tool box item and drop it on the canvas (diagram)
b) Give the object the name of the intended interface, i.e. IAdministration
c) In the properties select in the drop down box Stereotype: Interface
d) Create a method for the interface that returns type T
e) Go to the Details tab and add the parameter name 'descriptor' with type 'T'

You now have an interface (not a class), in C# this would translate to:

   public interface IAdministration<T> {
           T Method1();
   }

there you have it, it is a valid construct and interpretation. Only EA can't handle such thing.

HOWEVER, what this post was about was that EVEN when you select an 'interface' as stereotype the class' icon on the Project Browser is not changed to that of an interface (as indicated by the stereotype). That is inconsistent because it has been marked as interface.

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: About Interface behaviour in EA
« Reply #4 on: January 29, 2009, 11:18:33 pm »
Quote
Well, it seems like a valid construct:

Again, Simon´s point is valid. UML clearly defines an interface as a type of its own. In modern programming languages (and even before) an interface is completly different from a class.

Think of JAVA:

Code: [Select]
public interface A
{
    public void method(int param);
}

public class classA implements A
{
   public void method (int param)
{
    ....
}
}

The interface element enforces the implementation of the method(s) it defines (rather similar to an abstract class) without having a class identity.
Therefore class features like parameterising and templating are not applicable to an interface.

If you want this then you have to operate with abstract classes (which of courses compromises the purpose of interfaces as a general "gateway" between different components). For code generation purposes this would not automatically transform into an interface element type but a class element.

An interface therefore is in no way a stereotyped class and in this regard EA is 100% UML compliant.

Oliver
« Last Edit: January 29, 2009, 11:19:52 pm by ofels »

Emilio

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: About Interface behaviour in EA
« Reply #5 on: January 29, 2009, 11:26:44 pm »
Well, I was thinking more along the lines of "A class stereotyped as interface is an interface" rather than what you say.

You can have parameterized interfaces to define template parameters for the methods and properties exposed by the interface and it still remains an interface.