Author Topic: Interfaces in UML2 and EA 4.0  (Read 8349 times)

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Interfaces in UML2 and EA 4.0
« on: March 15, 2004, 10:21:34 am »
Hi,

as I understand the Socket Symbol "---(" in UML2 it is a kind of Assoziation to a Lollipop.

But when I use the assembly connector I have no possibility to declare, to which interface the socket is connected.  :-/

Why there is no sperate "---(" Connecter to connect to a Lollipop of a class?  ???

bye
Andreas
bye
Andreas

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Interfaces in UML2 and EA 4.0
« Reply #1 on: March 15, 2004, 03:01:55 pm »
The Assembly connector is used at the component level, not the Class level.

UML 2.0 Superstructure is, lets just say, a "little obscure" on this topic, but it shows no examples using an Assembly between classes or class interfaces.  On the other hand, it gives good treatment to the use of Assemblies at the component level.

However, in terms of resolving the obscurity (or perhaps perpetuating it!)  The UML 2 spec does specifically say that components can have (differentiated) provided and required interfaces.  (Lollipops and sockets) whereas classes do not have such associations specifically stated as being available, just "interfaces".  At section 7.15.3 on the other hand, does say that intefaces can be either provided or required.  ???
They then futher the problem in diagrams 59 thru 61 by showing classifiers with all 3 types of association!!!

In short, I think that Assemblies will quickly go the way of the extend/include problem! and that EA is "politically" correct in not showing sockets as available interfaces for a class element.

hth
Bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Interfaces in UML2 and EA 4.0
« Reply #2 on: March 15, 2004, 04:14:20 pm »
On further reflection it seems to me that ...

The "assembly connection" is either
  • behavioral rather than structural, or
  • it is a conceptual level item rather than a physical level item.


If it is behavioral, then why is it in a structural diagram?

If its conceptual, then the only use I can see for it is for the "alternative implementation/execution" where a component may request a service that is provided by a possible set of providers and the connection is only realized at run time
Quote
The execution time semantics for an assembly connector are that signals travel along an instance of a connector, originating in a required port and delivered to a provided port.
Multiple connectors directed from a single required interface or port to provided interfaces on different components indicates that the instance that will handle the signal will be determined at execution time
or
Quote
The interface compatibility between provided and required ports that are connected enables an existing component in a system to be replaced by one that (minimally) offers the same set of services. Also, in contexts where components are used to extend a system by offering existing services, but also adding new functionality, assembly connectors can be used to link in the new component definition. That is, by adding the new component type that offers the same set of services as existing types, and defining new assembly connectors to link up its provided and required ports to existing ports in an assembly.”


???Damned if I know.
B
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
YOUR ANSWER!
« Reply #3 on: March 15, 2004, 05:10:32 pm »
Curioser and curioser!

You can construct a required interface for a class in EA4.  

1) create an interface using the o-O toolbar item
2) create a dependency relationship from the requiror class to the new inteface
3) in the class context menu select "Insert Embedded Element", then "Show Dependent Interfaces"

or, more simply, but with less control
1) create a dependency relationship from the requiror class to the provider class
2) turn on "Show Dependent Interfaces" as above.
This will create a socket with the name of the Provider class.

Even better,
1) create a dependency relationship from the requiror to a provided interface (lollipop) on the provider.
The requiror now shows a required interface with the "correct" name, but the dependency link is shown from the requiror class to the provider interface, NOT from the requestor interface to the provider interface.

Interestingly, the same action from a class to a component or a component to a component doesn't create a socket.


So you can create sockets - but as a final word of caution beware - if you create dependencies between
classes in different diagrams they will all show up when you turn on "Show Required Interfaces". There is no way to be selective about which sockets are shown.  It is better (IMHO) to use the port feature which you can control in terms of individual visibility.

hope this (finally) helped
Bruce

p.s. If your dependency links "disappear" when re-opening a diagram you need to so something to get EA to regen the diagram.  One way is to select "Synchronize" on an element and then cancel it.
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: Interfaces in UML2 and EA 4.0
« Reply #4 on: March 16, 2004, 01:07:12 am »
Hi Bruce,

thanx a lot for your fast help. I'm very happy to hear that I'm not totaly silly in using UML2. Because that interface stuff in connection with classes is described in 2 sentences in my UML2 book and it sounds very trivial. And as you told: It is not trival.  >:(

All the told ways to handle interfaces I allready tested.
And I think the best way is to create a direct assoziation to the lollipop of a class and not using the "socket feature".

bye
Andreas
bye
Andreas

Javier

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
  • Necessity is the mother of email
    • View Profile
Re: Interfaces in UML2 and EA 4.0
« Reply #5 on: April 01, 2004, 12:38:22 pm »
Bruce,

Regarding your quotes:

Quote
The execution time semantics for an assembly connector are that signals travel along an instance of a connector, originating in a required port and delivered to a provided port.  


Perhaps an example would clarify this quote:

In COM, a component willing to provide events needs to provide an interface marked as a [source] interface.  A component willing to listen for those events needs to:
a) implement the interface in question (design time)
b) query the providing component for IConnectionXxx--basically, "registering" as a listener (runtime)
c) tear down the connection later on (runtime)

This corresponds to "signals travel along an instance of a connector, originating in a required port and delivered to a provided port. "

I believe that the second paragraph of the quote falls in nicely after this explanation.

In C# the mechanism is delegates.  In Java the mechanism is the DEM --Delegation Event Model.  In C++ is a DEM-like mechanism or using a signals libraries--boost.signals, or libsig++

Now, regarding your comment as whether it should be in a structural diagram, even though it looks like a behavioral element, I believe it should be.  To me, the icon can be used both at a component and at a class level, and it tells me that:
a) The interface must be implemented
b) There's a connection/disconnection mechanism--at runtime.

This connector is richer than the notation existing in previous versions of UML, where there's a bidirectional association and one of the sides states the role and the interface that it implements.

Quote
Multiple connectors directed from a single required interface or port to provided interfaces on different components indicates that the instance that will handle the signal will be determined at execution time


This next paragraph of your original quote simply means that if I have M components that provide interface I, and a component C that implements I as a required interface, at runtime, a user should be able able to create n instances of C, where instance Cn will be connected to component Mn

Regards,

Javier Estrada
We must become the change we want to see.
- Ghandi

manfred

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
  • I love UML
    • View Profile
Some clarifications on UML-2 Interfaces
« Reply #6 on: April 14, 2004, 08:01:08 pm »
To clarify the confusion about interfaces of classes and components:

Components are not "normal" classes. In the UML-2 metamodel, components inherit from StructuredClassifier or EncapsulatedClassifier, dependig if they have just required and/or provided interfaces, or if they have ports which carry these interfaces.

On the other hand, "normal" classes do not have the capabilities of StructuredClassifiers, henc not required/provided interfaces.

Manfred

thomaskilian

  • Guest
Re: Interfaces in UML2 and EA 4.0
« Reply #7 on: September 17, 2004, 06:48:35 am »
Hi all,
I just started working with interfaces. My simple question: if I  use the assembly connector between objects, why isn't there a relation to the interfaces/ports of the related components? This seems quite confusing. I have also seen examples (http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.cgi?board=UMLPRO;action=display;num=1094774376) where lollipop/socket are connected via associations to show some kind of assembly. What to prefer?

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Interfaces in UML2 and EA 4.0
« Reply #8 on: September 19, 2004, 05:16:20 pm »
TK,

Well, I've been using extensively for weeks and let me tell you I am no less confused han when kex started this thread  :)

I thonk though we (the forum we) need to be very clear in explaining which d ;Dn interfaces, lollipops and models we are talking about.

I reckon....

1. Assembly's only belong in component level models and then only at the component to component level of discussion - as help etc says "to discuss the wiring of components together". They dont seem to have a detail level semantic of use.  Further they can be conveniently used to model any type of "wiring" be it transport level or logical data flow.  However, their directionality is poor!

2. Their seems to me to be too many interface elements,  all with very similar (read "sometimes, exactly the same") representation.
Let's talk at the class level.
We have:
a class stereotyped as an interface
an interface element based on a class element
two embedded elements representing interfaces of the type "provided" and "required"
and
two "exposed" interface elements that are not the same as the above provided/required interfaces but look exactly the same.

Try this exercise and see if it helps.

1. Create a class model with 7 classes - c1 to c7.
2. Add an o-O interface - i1 - an make it use circle notation
3. Add another class - i2 - just leave it for the minute

4. Create a dependency from c1 to i1, then use Insert  Embedded Element/Show Dependent Interfaces on c1.
Now change the line color for c1 - note the line color of the lollipop socket changes.  Also, you can double click on the lollipop socket and get the class details form.  Note also that double clicking on i1 gets you a detail form that does not include a "Details" tab.  However, you can add BOTH operations and attributes to i1 using the Current Element toolbar. Finally, you can generate code (C#) for i1 but any attributes (correctly) are ignored.

5. Lets attack c3, open it up and sets its stereotype to "interface".  Add an attribute and a couple of  operations, say "int voltage" and "bool connect" and "bool disconnect".  You can generate code for this that looks exactly like an implementable class - coz it is.
Go back to i1 and using the toolbar add the same attribute and operations. Now change the visual representaiton of i1 from circle to normal.  Now both the class and the interface have the same representation!  Change i1 back to circle notation before we get too confused.  Now change the name of c3 to i1.  Now quickly change it back to c3 ....  :-/
Create a dependency fom c2 to c3 and switch on Show Dependent Interfaces for c2 - OK it acts the same as the c1 to i1 dependency, change colors etc to check.
Now create a realisation link from c2 to i1, dont override anything - and turn on Show Realised Interfaces for c2, now we have a realised lollipop for c2 that acts (as in diagram wise) the same as the dependent interface.  If you generate code for this it will include the skels for i1's operations as it should. Now delete the realisation link - note the interface stereotype on c2 remains! - then re-add it, this time overriding the operations. Add an attribute "float voltage".  Now we have an interface sterotyped class that generates implementation class code with a decendancy on i1 which implements i1 and "overrides" both the attribute and the operations.

I guess I'd better get to this meeting, so I'll explain c3 to c7 later  :)

Bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

thomaskilian

  • Guest
Re: Interfaces in UML2 and EA 4.0
« Reply #9 on: September 20, 2004, 03:14:03 am »
Hi Bruce,
Quote
Now delete the realisation link - note the interface stereotype on c2 remains!
Do you mean the lollipop? It vanishes also.

However, I'm now a bit more clear about where to use lollipop and socket. My reading so far was not exact since for example "Required Interface" does not tell whether this is from the components or the outer worlds view. Obviously this is meant from the components view.

I'm curios about the other classes in your model...
« Last Edit: September 20, 2004, 05:30:06 am by thomaskilian »

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Interfaces in UML2 and EA 4.0
« Reply #10 on: September 20, 2004, 04:23:19 pm »
Yep, the lollipop goes - as you have deleted the realisation - the point is though, the stereotype created on the realising class sticks! Even though all the rest concurs with UML specs - this <<interface>> stereotype seems to be a bug.

B

More later.... BTW the previous post was all about "realised" and "dependant" interfaces, the next set is about "required" and "provided" interfaces, and the last is about mixing them up.  
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

thomaskilian

  • Guest
Re: Interfaces in UML2 and EA 4.0
« Reply #11 on: October 19, 2004, 10:06:33 am »
Hi Bruce,
a curious reader is waiting for the continuation  :)

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Interfaces in UML2 and EA 4.0
« Reply #12 on: October 19, 2004, 04:29:16 pm »
Sorry matey - bit busy at the moment.....
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.