Book a Demo

Author Topic: Parameterized Interfaces  (Read 6258 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Parameterized Interfaces
« on: July 08, 2005, 01:24:36 am »
Today,  I had occasion to want to create a Parameterized Interface.

My reasoning was:  I use Parameterized Classes to enable me to define a set of Classes with identical characteristics but different instantiations.  Parameterised Interfaces would allow me to do the analogous thing...

EA won't let me create a Parameterized Interface, because it doesn't allow you access to the Detail tab of the Classifier.  That's no problem, says I, I'll just change the element to a Class, pop in the parameters and switch it back to an Interface - just like I have to do if I want to add a linked diagram or add a feature (by the scenic route). ::)

Imagine my frustration when, having added the parameters, the the parameters disappeared when I switched the element back to an Interface! :'(

Before I submit a formal bug report to Sparx, is there any reason why I shouldn't be able to create Parameterized Interfaces?

Cheerz,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

lex_cz

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Parameterized Interfaces
« Reply #1 on: July 08, 2005, 07:56:22 am »
Hi Paolo,
just to be sure I understood your question. Do you want to model something like "templates" in C++ ?

Regards Martin

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Parameterized Interfaces
« Reply #2 on: July 08, 2005, 08:53:30 am »
Quote
Hi Paolo,
just to be sure I understood your question. Do you want to model something like "templates" in C++ ?

Regards Martin
Yes, Martin more or less...  I really want to create UML 2 templates, but the closest EA comes to them at present is Parameterized Classes.

The problem is compounded by the fact that C++ doesn't actually have Interfaces (say like Java and C# do).  We simulate an Interface by using a pure virtual Class.

Anyway, I want to be able to template Interfaces...

Paolo

Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

alexander

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Parameterized Interfaces
« Reply #3 on: July 11, 2005, 02:49:08 pm »
I agree with you.
From the superstructure:

"
17.5.7 Classifier (from Templates)
Classifier is defined to be a kind of templateable element so that a classifier can be parameterized, and as a kind of
parameterable element so that a classifier that can be exposed as a formal template parameter, and provided as an actual
parameter in a binding of a template.
Issue 7367 - add superclass pointers
Generalizations
• “ParameterableElement (from Templates)” on page 679
• “TemplateableElement (from Templates)” on page 681
• “Classifier (from Kernel, Dependencies, PowerTypes)” on page 50 (merge increment)
Description
Classifier specializes Kernel::Classifier TemplateableElement and ParameterableElement to specify that a classifier can be
parameterized, be exposed as a formal template parameter, and can be specified as an actual parameter in a binding of a
template.
Issue 7623 - remove redundant generalization
Figure 429 - Classifier templates
TemplateableElement
TemplateSignature
ParameterableElement
RedefinableElement
(from Kernel )
TemplateParameter
RedefinableTemplateSignature
*
*
+e xt ende dSi gnatur* e
{subsets redefinedElement}
*
+/inheritedParameter
{subsets parameter}
ClassifierTemplateParameter
allowSubstitutable : Boolean = true
Classifier 1
+ownedSignature
0..1
{subsets ownedElement}
+cl assifier
{su bse ts rede finitionCont ext}
1
0..1
+ param et er
+parameteredElement
690 UML Superstructure 2.0 Draft Adopted Specification
A classifier with template parameters is often called a template classifier, while a classifier with a binding is often called
a bound classifier.
Issue 5744 - spelling of the word Use Case
By virtue of Classifier being defined here, all subclasses of Classifier (such as Class, Collaboration, Component,
Datatype, Interface, Signal and UseCases) can be parameterized, bound and used as template parameters. The same holds
for Behavior as a subclass of Class, and thereby all subclasses of Behavior (such as Activity, Interaction, StateMachine).
"

According to this, interface is a classifier, and all classifiers are templeateable elements, so you should be able to define a template for an interface and to define parameters for that template.