Author Topic: Inheritance of template parameters  (Read 840 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1773
  • Karma: +122/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Inheritance of template parameters
« on: July 10, 2020, 09:33:23 pm »
Hello knowledgeable people,


Is there a way in EA to create reusable sets of template parameters, either by way of specialization (doesn't seem to work) or by stereotyping (haven't tried, but not mentioned in documentation so doesn't seem possible either).

If not, is this a standard limitation imposed by the UML or an arbitrary one imposed by the manufacturer?

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 7411
  • Karma: +176/-120
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritance of template parameters
« Reply #1 on: July 11, 2020, 10:44:49 am »
Hello knowledgeable people,


Is there a way in EA to create reusable sets of template parameters, either by way of specialization (doesn't seem to work) or by stereotyping (haven't tried, but not mentioned in documentation so doesn't seem possible either).

If not, is this a standard limitation imposed by the UML or an arbitrary one imposed by the manufacturer?

Cheers,


/Uffe
Hi Uffe,

Can you provide some worked examples of what's you're after?

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

Uffe

  • EA Practitioner
  • ***
  • Posts: 1773
  • Karma: +122/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Inheritance of template parameters
« Reply #2 on: July 11, 2020, 05:50:22 pm »
Can you provide some worked examples of what's you're after?

Sure can! :)
Well, an abstract one at least.

Let's say class AbstractStorage has one template parameter contentType.
Let's say class List specializes AbstractStorage and has a template parameter sortAlgorithm.

If I now create a class QuickSortList and draw a template binding from that to List, EA only lets me specify an actual parameter for the formal parameter sortAlgorithm.

Shouldn't I also be able to specify an actual parameter for contentType? Aren't template parameters inherited?

I'm aware that EA's template parameters are a(nother) hack. There's no separate table for them, and they're not treated as a special category of attribute; instead they're in t_xref (which should really be renamed t_hackhacketyhackhackkludge at this point). But what does the standard say? And if the standard says EA is wrong, is there a workaround?

I can, of course, just add contentType as a template parameter to List. But then List::contentType is not a consequence of List being a specialization of AbstractStorage -- it's a design decision. That feels wrong.
Furthermore, if I do this then the relationship between List and AbstractStorage must instead be a template binding, since List must now bind AbstractStorage::contentType which generalization can't do. But template binding is a type of realization, so if I do that the attributes and operations aren't inherited.

As a designer, it makes sense to me that template parameters would be inherited just like attributes and operations. It makes less sense that they wouldn't be.

In fact, I think the functionality should be more or less the reverse of what EA has implemented now: if I want to "close off" a template parameter in an abstract class, then I do a template binding.
If I have a class AbstractList<contentType, sortAlgorithm> and I want a class AbstractIntegerList<sortAlgorithm> I draw a template binding from AbstractIntegerList to AbstractList and specify contentType = Integer. I don't draw a generalization.

But again, if the current behaviour is what the standard says then fine. Well not fine, then the standard is wrong. But that's a mighty big windmill for my cracked old lance.


/Uffe
My theories are always correct, just apply them to the right reality.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 7411
  • Karma: +176/-120
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritance of template parameters
« Reply #3 on: July 12, 2020, 09:37:35 am »
t_hackhacketyhackhackkludge - I like it!   Have you started a new meme?

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

qwerty

  • EA Guru
  • *****
  • Posts: 11388
  • Karma: +295/-262
  • I'm no guru at all
    • View Profile
Re: Inheritance of template parameters
« Reply #4 on: July 12, 2020, 06:55:59 pm »
Ekke Ekke Ekke Ekke Ptang Zoo Boing!

q.