Book a Demo

Author Topic: Specifying number of ports  (Read 6695 times)

Matt H

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Specifying number of ports
« on: May 07, 2014, 11:03:36 pm »
What is the correct way to specify that a child instance of a class can contain 0..n ports?  Ports specified on the parent class are (can be) inherited, but it is not possible to add further ports directly to the child (right-click, New Child Element)... any thoughts?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Specifying number of ports
« Reply #1 on: May 08, 2014, 12:39:25 am »
I don't get what you want. Are you after a general description of ports (like described in Superstructures) or after a way to use that inside EA?

q.

Matt H

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Specifying number of ports
« Reply #2 on: May 08, 2014, 12:53:52 am »
Within EA.  For example:

Create a class called Test
Add a port called P to Test
From the project browser drag and drop Test on to a diagram
Choose "paste as instance (object) when prompted
The instance is now created, and has port P as expected

...it is now not possible to add another port to the instance although it is possible to delete the existing port P.  I want to be able to add additional ports and I am hoping/assuming there would be some way of constraining the number of ports at the parent class level.

Paul Lotz

  • EA User
  • **
  • Posts: 248
  • Karma: +1/-0
    • View Profile
Re: Specifying number of ports
« Reply #3 on: May 08, 2014, 02:36:06 am »
Strictly out of curiosity, I followed the steps you describe.  I was able to create a port P2 on the instance (Right click...New Element...Port).  (EA 10.0.1009)
I hadn't actually inspected to be able to do this since this is an instance, not a child, but there you go.  I guess it makes sense.

Matt H

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Specifying number of ports
« Reply #4 on: May 08, 2014, 02:41:16 am »
Thanks for checking.  Does not work under 11.0.1105 so perhaps it's just a bug in this version.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Specifying number of ports
« Reply #5 on: May 08, 2014, 04:24:38 am »
I guess it's not a bug but a feature. Adding new structural elements like a port is not possible for instances but only for classes. That makes perfect sense as what use would make a new structural element that is available to an instance but does not exist in the class?

q.

Matt H

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Specifying number of ports
« Reply #6 on: May 08, 2014, 06:05:47 am »
I think it's quite rational to be able to constrain the number of ports available to an object instance.  For example, an instance might create ports at runtime based on its environment.

There does not seem to be a way to do this in EA.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Specifying number of ports
« Reply #7 on: May 08, 2014, 08:53:34 am »
The intention of UML wouldn't allow creation of ports on an instance. A port is a variable owned by the class that contains it. As with most programming languages, in UML you define what the class looks like statically and that doesn't change. A port, like any property has a multiplicity. That governs the number of values an instance of the class can hold. That seems to be what you are attempting to describe.

Unfortunately, I don't what the UML syntax is for a slot (UML term for the instance of a property) with multiple values.

Matt H

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Specifying number of ports
« Reply #8 on: May 08, 2014, 04:42:09 pm »
I can see that in EA multiplicity can be specified on the port when it is added to the class; this answers my original question so thank you.

Unfortunately this multiplicity is not treated as I hoped when a diagram is created.  E.g. if I add a port to a class and specify a multiplicity of 3, then create an instance (drag & drop) the instance is displayed with a single port of multiplicity 3 (rather than three ports).

Also I note the following behaviour in EA which seems inconsistent:
An arbitrary number of ports can be added to an Object created from the Object toolbox (eg drag & drop an Object from the Object toolbox on to a diagram, and right click then "New Child Element").  
For an instance is created from a class, ports can be deleted but not added.
Citing Paul Lotz below, it was posisble to add ports to an instance in version 10.0.1009.


Paul Lotz

  • EA User
  • **
  • Posts: 248
  • Karma: +1/-0
    • View Profile
Re: Specifying number of ports
« Reply #9 on: May 09, 2014, 02:37:42 am »
What is described as the v11 behavior in this thread is what I would have expected would be the proper behavior, but it is possible I am missing something.  Maybe it would help if you explained what you are trying to express by adding a port to an instance.

Matt H

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Specifying number of ports
« Reply #10 on: May 09, 2014, 09:25:06 pm »
I am modelling (software) systems and their interactions.

I’d planned to define a “system” class, with instances of this class (i.e. objects) representing specific software applications.  Applications would communicate with each other via ports, with each application having a potentially different number of ports.

As a separate point, and regardless of whether or not ports should be used as described above, it does seem there’s a consistency issue with the way ports are treated in EA - for example, it is possible to delete ports from an instance but not add them.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Specifying number of ports
« Reply #11 on: May 09, 2014, 10:26:48 pm »
Maybe someone from Sparx should comment on that. I also think that an instance should have the same number of ports as its classifier and you should not be able to manipulate them. (N.B. similarly as in other regions of Superstructures that might be some strangeness in the definition.)

q.

Paul Lotz

  • EA User
  • **
  • Posts: 248
  • Karma: +1/-0
    • View Profile
Re: Specifying number of ports
« Reply #12 on: May 10, 2014, 02:27:41 am »
Quote
As a separate point, and regardless of whether or not ports should be used as described above, it does seem there’s a consistency issue with the way ports are treated in EA - for example, it is possible to delete ports from an instance but not add them.

I agree.  I also think qwerty's response states it well.  This question certainly does seem to deserve some attention.