Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Paolo F Cantoni

Pages: 1 ... 353 354 [355] 356 357 ... 409
5311
Uml Process / Re: Lozenge (tm) & OCL
« on: March 05, 2006, 07:48:10 pm »
I received an off-line question which might be of interest to EAers.  Here's the question and the (slightly) amended response...

Quote
Would you use an association class or a ternary association to model a legal contract between two parties?
Personally, I like the association class approach best; the contract defines the relationship between the two parties.

Unfortunately it's at least a ternary:

A contract between First Party and Second Party under a Jurisdiction.  If one (incorrectly) assumes that all contracts will be written under the same jurisdiction then one can use the binary relation (and thus the AssociationClass).

However, you can try to get the best of both worlds by using the AssociationClass to model the Parties and use a single (additional) AssociationEnd (an EA Association - stereotyped «end») to add the Jurisdiction link.

This is the beauty of the AssociationClass is just a binary Lozenge approach!  8)  

However, since EA doesn't really provide access to all the Ends in the same way under this approach, I prefer a ternary Lozenge.

Paolo

5312
Uml Process / Re: Lozenge (tm) & OCL
« on: November 04, 2005, 03:21:12 pm »
Quote
[size=13][SNIP][/size]
EDIT: On thinking things through, you are free to model all associations as AssociationClass if you wish - it is, after all, adding extra information to the model not subtracting, and if you need the extra info then why not? So to answer your original point, Sparx don't "need to understand that the lozenge shape is merely a rendering of the AssociationClass" but we need to allow you to understand that. I think.

Neil

PS "KP" is pronounced the same as my surname and is easier to type. I've always used it on message boards. In the UK it's also a brand of nut  :-/
Hi Neil,

Thanks for the edit.  There's hope for you yet. ;D

You're half way there...  The problem with the Association Class is that as manifest (on OMG Diagrams etc) it appears to apply only to a binary relation.  This can't possibly be the case!  We have a continuum of (outbound, N-ary) AssociationEnds for an AssociationClass from 2 upward.  Similarly, we have a continuum of AssociationClass Features from N (one attribute for each (N-ary) AssociationEnd) upward.  

Accordingly, If I can represent a binary Association as either:
  • a single Association line (which is composed of the two AssociationEnds) between the two Associated Classes
  • or a line with the (rendered) attached AssociationClass
  • or the Association lozenge and the two AssociationEnds
then it is obvious (at least to me on a few minutes thought) that the lozenge IS the AssociationClass!

If this is so, the we have an elegant proof that is then extensible to the N-ary case!  In short, it works!

Now all we need is for Sparx to provide the additional context menu item on the AssociationClass (which IS the Lozenge) ("Use Lozenge Notation") (similar to the "Use Circle Notation" for an Interface) to allow us to switch between renderings and we're sweet!).

BTW: I don't know how many of you have been bothered by the question "What makes an AssociationClass different from an ordinary Class?"

Do you (the reader - not just Neil!) know?  Have you thought about it?  Will it come up as a question on the OMG Certification Exam?

An AssociationClass is a Class that represents an Association and thus has one required attribute referencing the associated Class for each arity of the N-ary Association it represents.  Add/Remove an AssociationEnd and the attribute is accordingly added/removed.

It all works!

So, Neil, when do we get the "Use Lozenge Notation" context menu Item?  Or at a minimum, the ability to change the Type of the Lozenge from Association to Class and back; as I think has been requested before in the forum?

Pleadingly,
Paolo

BTW: The UML specifications are either somewhat compressed and potentially confusing or, in at least one place, downright incorrect on the subject of the N-ary Association.  In particular, Figure 74 of the the UML 2 [size=13]Infrastructure[/size] Specification showing Binary and ternary Association is incorrect in the placement of the multiplicities.  The multiplicity of the each AssociationEnd with respect to the associated Class is one!  The N-ary Association is defined as a Tuple and therefore the multiplicity MUST be one!  As far as I can tell, constraints on the number of Tuples for a given associated Class can only be handled by Class level constraints on the AssociationClass.  For example, "a Player can only be a goalie on no more than two team in a season".
[size=0]©2005 Paolo Cantoni, -Semantica-[/size]

5313
Uml Process / Re: Lozenge (tm) & OCL
« on: November 03, 2005, 03:23:20 pm »
Quote
KP, could you post diagram? ;)

I have read this superstructure sentence, but without example and explanation it doesn't help a lot
BTW, if you choose other ends, you can get not classA with the left classes, but classC with the rest (classC-classA, classC-classB & etc)
Hi SF_lt (can we have a more human moniker for you? :) ),

If you are familiar with ERD or DB design, the best way to think about the Lozenge (in my view) is as an Intersector Table, with a mandatory, singular, foreign key to each of the associated Classes (as Tables).  Therefore the UML statement KP (another non-human? :) ) quoted merely states that if you run a query over the lozenge where you supply values for each of the foreign keys but one, you'll get the set of rows where the value of the remaining foreign key varies.  The quote goes on to say that if the end is ordered or unique, this will apply the same constraints on the set of values returned by the query.  Does that help?
Quote
Also, one little specification on constraints: what I miss, I miss feature to add constraint for the dotted line from association class to association line - there is no way to attach constraint or smth else to this part of association. Maybe UML2 metamodel prohibits it...
The dotted line is not a real connector.  It is merely trying to reinforce the idea that the Association Class IS the Association line.  It is a rendering artifact, not a real UML element.  Therefore you can't attach any metadata to it.  That's why Thomas said use the Constraints tab on the AssociationClass or Lozenge.

FWIW, I can't reinforce enough that Sparx needs to understand that the lozenge shape is merely a rendering of the AssociationClass (like say the Boundary, Control and Entity shapes from the Analysis toolkit).  Also, that the AssociationClass defined by UML is merely binary example of the N-ary Association.  So a binary Association may be depicted by an Association line by itself, an Association line with associated AssociationClass or an Association lozenge with two AssociationEnds - they are all the same thing!

Accordingly, you should be able to do everything you can do to a Class to the Lozenge!

Quote
jeshaw, I agree, that road doesn't need to know, what cars use it (what about women? :-D )
in my example, channel passes signals from sender to receivers, also signals travel through the channel to reach their's destination. Also not all signals use one or other channel - there may be many channels.
But still, thanks for your point
By Signal here, do you mean Signal Type?  If you mean Signal, what is the domain identifier that allows you to specify which signal instance you are associating.  From my intersector table example above, you'll see you need to provide the foreign key to identify each AssociationEnd.  IF you can't find one, then it's an indication the model is wrong.

It strikes me that this would be a good example to work through for AssociationClasses and lozenges etc.  Like Jim, I'm not so sure there is an N-ary relationship here.

To determine how to model the rules, we need to know the rules.  Could you give us a short definition of each of the Classes involved:  Sender, Receiver, Channel and Signal?  Without them, we can't really provide the direction you are seeking.  Nothing fancy (as they say in the competitions - 25 words or less ;D)

If you've been following some of my postings, you'll see I strongly favour a technique called "Verbalisation" - where you "speak out" the model.  If the words sound wrong, the model is wrong!

HTH,

Paolo
[size=0]©2005 Paolo Cantoni, -Semantica-[/size]

5314
Uml Process / Re: Navigability
« on: February 24, 2006, 05:40:00 pm »
Quote
Thanks for the diagram Paolo, helps a lot.
Hi nif,
Before I (attempt to) answer your questions a few words about the diagram (and EA).  Firstly, this is MY modelling methodology - so, apologies if I have confused anyone.  The AssociationEnds and their adornments are created using the facilities that EA has to support these concepts (which like almost all UML tools are close to zero).

The connectors between the lozenge and the associated classes are AssociationEnds - not full (binary) Associations. That is, they are the half-line from where the AssociationClass dotted connector meet the Association back to the Class.  Thus the Association from Class T to Class U contains 2 AssociationEnds.

I needed to distinguish these AssociationEnd lines from the normal ones, I colour them deep purple (Great Band!) and by attaching the Composition marker makes it look weird enough.

I guess that I should also mention that while an AssociationClass is a real Class, an ordinary class can't do the same job.  An AssociationClass is an ordinary Class plus an Attribute for each AssociationEnd.  These attributes need to be distinguished from the other attributes (as the «end» stereotype does for the AssociationEnd).  Strangely enough,I use the «end» stereotype for this purpose.

Quote
I am confused however (there's a surprise) the UML Reference Manual 2nd edition states that "Aggregation (including composition) is only meaningful for binary associations. An n-ary association may not contain an aggregation or composition marker on any role." It doesn't state why.

I ran an n-ary and aggregation search in the draft version of the UML2 superstructure document that I have and this also states that "only binary associations can be aggregations."
Since the (normal) Aggregation describes the meronymic relationship between the holonym (say Class T) and the meronyms (say Class U).  This requires a differentiation between the two classes (one the holonym, one the meronym).  In an N-ary Association this isn't possible.  All the classes have the same (notional) weight.  (Try to "speak" any N-ary Association to give one associated Class more weight than another)

The AssociationClass (if any) on the Association doesn't have any bearing on the Aggregation/Composition.

Quote
If EA allows you to model aggregations or compositions on an n-ary associations then it would appear that this conflicts with the UML superstructure document.  I have tried it and EA allows you to place an composite/aggregation marker on either end of the association.

Any thoughts on this.

nif
As I mentioned above, support for N-Ary associations is lacking in (all?) UML tools.  EA does NOT see the connector between the Lozenge and the associated Class as an AssociationEnd.  Thus it allows the Composition marker at either end.

Admittedly, placing the Composition maker at the associated Class end is MY methodology, but I feel it IS consistent with both UML and Set theory.  My preference would be for a different line style for Association Ends.

HTH,
Paolo

5315
Uml Process / Re: Navigability
« on: February 23, 2006, 02:46:35 pm »
I just remembered I have his model that might help...  Let me know if you need more...



HTH,
Paolo

5316
Uml Process / Re: Navigability
« on: February 23, 2006, 06:50:27 am »
Quote
Paolo, could you also provide class diagram (using lozenge) for this example and textual representation of it (how to read diagram)...
And, if not hard, example's diagram using associations (not lozenge notation) - hope that's for all cases :P

Isn't DoughFormulation the lozenge in your example?


when N=2, there is an association class case, so n-association when n=2 is an association class

when N>2, isn't lozenge a class? if so, it can have methods/attributes and so on
Diagrams will have to wait a bit.  Very busy at present.

However... Yes, DoughFormulation is the AssociationClass/Lozenge.

Therefore it can have its own attributes and methods.  But as an AssociationClass, it also has special attributes that act as the AssociationEnds.  I distinguish those with the «end» stereotype.

HTH,
Paolo

5317
Uml Process / Re: Navigability
« on: February 15, 2006, 02:00:20 pm »
Quote
Thanks for all the replies.

I think I am closer to understanding this aspect of navigability. I will work through the C# example.

Paolo do I understand your analogy of the link table correctly.

Table X

col1 col2 col3
FKA  FKB  FKC  {unique combination = PK}
FKA  FKB  FKC  {unique combination = PK}
.....   ...     etc

Where FKA FKB & FKC hold some FK value of table A, B & C
Nif,  

I should have made it clearer that if you have more than one domain column in the PK, then the equivalent N-Ary PK is created by adding the extra columns to the PK.  For example if I am using a time period then the PK might be:
FKA  FKB  FKC  commencement termination {unique combination = PK}

and thus the same combination of FKA, FKB and FKC could appear more than once.

Sorry for being inexact.  
Quote
SELECT DISTINCT A FROM X, A being some FK value of Table A.

The navigability statement I originally posted indicated that this was only possible if you had all the values except  one.

"Navigability means that given values for all but one of the association ends, the tuples containing all those values can be obtained; the result is usually stated as the set of values for the remaining association end."

Resulting in the select statement becoming

SELECT DISTINCT A FROM X WHERE B = ? AND C = ?

The select is based on knowing a value for two of the foreign key values, tying up with the statement.

Is this what you meant?

nif

Yes, but recognising that in the limit case, you have
SELECT DISTINCT A FROM X
whose semantics are:
Give me the As that have ANY relationship to either Bs or Cs.

Hopefully closure...  8)

Paolo

5318
Uml Process / Re: Navigability
« on: February 15, 2006, 01:49:31 pm »
Quote
Nice way to create n-tuples. Funny that I still have the feeling you don't really need such constructs. A practical use (that comes to my mind) is a sort of statistics where you want to bind results to the bread/baker/dough-tuples (e.g. subjective taste). Stand-alone above n-tuples have no semantic, do they? I'd prefer to use a matrix instead. Maybe I'm too old-fashioned/stupid?

Thomas,

they have the same semantics as an N-Ary intersector table in the relation model (or your matrix).  The links mean what you define them to mean.  In the case of a binary Association because, by definition, if B = f(A), then A = f-1(B) (that is, the inverse access function can be used to determine the the the other end) you appear to have more control over the semantics.  Example, if you are my child, then I'm your parent.  With an N-ary relationship, I haven't found a useful way to name the actual AssociationEnd (as opposed to the Role identified by that AssociationEnd).

The matrix (versus lattice) is just an implementation decision.

Paolo

5319
Uml Process / Re: Navigability
« on: February 15, 2006, 06:12:29 am »
Quote
Paolo,
I was afraid you would point me to this thread (your link above is incorrect). I don't see any n-ary association with n>2 there. So I'm still unillumined.
Thomas,

(fixed the link - Thanx)

here's an amended ternary (3-Ary) AssociationClass example...

Below is the required code for C# to create and manage this relationship.  (BIG NOTE: I don't have a C# compiler to hand to verify this amended code will work...)

First the Class definitions...   [Note for simplicity's sake, I've made all the attributes public.]

public class BreadProduct
{
   public ArrayList _DoughFormulations = new ArrayList();    //because the Association is optional manifold
   public int Value;    //Just to show we got here...
   public BreadProduct()
   {
   }

   public void AddDoughFormulation(DoughFormulation associatedDoughFormulation)
   {
       _DoughFormulations.Add(associatedDoughFormulation);
   }
}

public class BreadDough
{
   public ArrayList _DoughFormulations = new ArrayList();    //because the Association is optional manifold
   public int Value;    //Just to show we got here...

   public BreadDough()
   {
   }

   public void AddDoughFormulation(DoughFormulation associatedDoughFormulation)
   {
       _DoughFormulations.Add(associatedDoughFormulation);
   }
}

public class BreadBaker
{
   public ArrayList _DoughFormulations = new ArrayList();    //because the Association is optional manifold
   public int Value;    //Just to show we got here...

   public BreadBaker()
   {
   }

   public void AddDoughFormulation(DoughFormulation associatedDoughFormulation)
   {
       _DoughFormulations.Add(associatedDoughFormulation);
   }
}


public class DoughFormulation
{
   public BreadDough _BreadDough;
//AssociationEnd
   public BreadProduct _BreadProduct;
//AssociationEnd
   public BreadBaker _BreadBaker;
//AssociationEnd

   private DoughFormulation()
//Remove parameterless constructor from public view...
   {
   }

   public DoughFormulation(BreadProduct BreadProduct, BreadDough BreadDough, BreadBaker BreadBaker, int BreadType, int Yield)
   {
       _BreadProduct = BreadProduct;    //set reference to AssociationEnd
       _BreadDough = BreadDough;    //set reference to AssociationEnd
       _BreadBaker = BreadBaker;    //set reference to AssociationEnd

       _BreadType = BreadType;        //set AssociationClass Attribute
       _Yield = Yield;        //set AssociationClass Attribute

       _BreadProduct.AddDoughFormulation(this);    //Inject reference to AssociationClass
       _BreadDough.AddDoughFormulation(this);    //Inject reference to AssociationClass
       _BreadBaker.AddDoughFormulation(this);    //Inject reference to AssociationClass
   }
   public int _BreadType;
   public int _Yield;
}



Next, the code to test and verify the structures...

   BreadProduct oBreadProduct = new BreadProduct();
   oBreadProduct.Value = 23;
   BreadDough oBreadDough = new BreadDough();
   oBreadDough.Value = 77;
   BreadBaker oBreadBaker = new BreadBaker();
   oBreadDough.Value = 92;

   DoughFormulation oDoughFormulation = new DoughFormulation(oBreadProduct, oBreadDough, oBreadBaker, 1, 5);
   oDoughFormulation = new DoughFormulation(oBreadProduct, oBreadDough, oBreadBaker, 2, 7);

   System.Collections.IEnumerator oIterator = oBreadProduct._DoughFormulations.GetEnumerator();
   while ( oIterator.MoveNext() )
   {
       DoughFormulation oIteratedDoughFormulation = (DoughFormulation)oIterator.Current;
       Trace.WriteLine(oIteratedDoughFormulation._BreadType + "->" +  oIteratedDoughFormulation._BreadDough.Value + ", " +  oIteratedDoughFormulation._BreadBaker.Value);
   }

   oIterator = oBreadDough._DoughFormulations.GetEnumerator();
   while ( oIterator.MoveNext() )
   {
       DoughFormulation oIteratedDoughFormulation = (DoughFormulation)oIterator.Current;
       Trace.WriteLine(oIteratedDoughFormulation._BreadType + "->" +  oIteratedDoughFormulation._BreadProduct.Value + ", " +  oIteratedDoughFormulation._BreadBaker.Value);
   }

   oIterator = oBreadBaker._DoughFormulations.GetEnumerator();
   while ( oIterator.MoveNext() )
   {
       DoughFormulation oIteratedDoughFormulation = (DoughFormulation)oIterator.Current;
       Trace.WriteLine(oIteratedDoughFormulation._BreadType + "->" +  oIteratedDoughFormulation._BreadProduct.Value + ", " +  oIteratedDoughFormulation._BreadDough.Value);
   }


See how we use the DoughFormulation to traverse to the BreadDough and BreadBaker, BreadBaker and BreadProduct, BreadDough and BreadProduct

Lastly, the output...

1->77,92
//Bread type 1 was baked by Baker 92 using Dough 77
2->77,92
//Bread type 2 was baked by Baker 92 using Dough 77
1->23,92
//Bread type 1 was baked by Baker 92 yielding Product 23
2->23,92
//Bread type 2 was baked by Baker 92 yielding Product 23
1->23,77
//Bread type 1 was baked using Dough 77 yielding Product 23
2->23,77
//Bread type 2 was baked using Dough 77 yielding Product 23



5320
Uml Process / Re: Navigability
« on: February 15, 2006, 04:36:53 am »
Quote
Paolo,
I have no problem in understanding the abstraction. What I simply miss is a REAL example. The Venusian Bruce has a need for that, but us Earthlings?
Thomas,
can you clarify what you are after?  If you want to see the use of an AssociationClass using C# and (what James E Shaw and I now call) Slot Injection, then look at:
Collections, Containers, Composites & Nest .

If that's not sufficient, then let me know...

Paolo

5321
Uml Process / Re: Navigability
« on: February 14, 2006, 05:11:10 pm »
Quote
Not to us Venusians.

bruce  ;)
I know how many OO programmers haven't a clue about how databases work so I tried the easier explanation.  The harder explanation is to think of the classes A, B and C and Relational Tables and X as a three way intersector with foreign keys to each of the other three tables.  Unique values for the foreign keys constitute a uniqueness constraint on X.  This corresponds to X = (A, B, C)

XA corresponds to SELECT DISTINCT A FROM X
(where A is the FK column referencing Table A)

Happy now? :-X

Paolo

BTW: bruce, I know Venusians understand RDBs but for the Martians out there...

5322
Uml Process / Re: Navigability
« on: February 14, 2006, 10:52:51 am »
Quote
when N>=3, how to read lozenge notation? is it means, that every participating classifier is associated with rest classifiers?

For example, N=3, classes A, B and C connected with lozenge. Is this means, that A at the same time is associated with B and C? the same should be for the B and C
Yes,

All three classes (A, B & C) are connected together by the AssociationClass (say X).  You'll remember in my ramblings I assert that the Lozenge is just the rendering of an N-Ary AssociationClass.  Now, an instance of the Lozenge Xn will associate a specific set of (A, B & C) instances, say Ap, Bq, Cr.  Each instance of X represents a fact concerning the relationship of A, B & C, under X.  Thus a different fact might be that: Xm will associate  say Ad, Bq, Cf.  Thus X = (A, B, C) and X = (B, C, A) and X = (A, C, B).

Notice that now Bq is related (under X) both to Ap and Ad and to Cr and Cf!

We can create aggregate functions that will traverse X and yield the facts about how each instance in one class is related to instances in the other classes (such as the facts about Bq above).  Notice that each aggregate function requires 1 Class as the source and N-1 classes as the set of resultant tuples.  You could say: XA = (B, C) and XB = (A, C) etc

This is the: "Navigability means that given values for all but one of the association ends, the tuples containing all those values can be obtained; the result is usually stated as the set of values for the remaining association ends".  Each class in the tuple is attached to an AssociationEnd that connects the Class to the AssociationClass (Lozenge).  Thus if we aggregate over (B, C) we get the set of As that correspond to XA.

Does that clarify matters?

Paolo


5323
Uml Process / Re: Navigability
« on: February 13, 2006, 10:09:44 am »
Quote

I remember great thread on this, but till now have some doubts for lozerge when more than 2 ends ???
Why?  A binary Association is only a special case for rendering purposes...  They're all N-ary Associations... (N>=2)

Can you share your doubts?

Paolo

5324
Uml Process / Re: Navigability
« on: February 13, 2006, 04:53:45 am »
Quote
So I guess these constructs are just useful for aliens?
Only, Thomas, if UML stands for Universal Modelling Language! ;D

5325
Uml Process / Re: Navigability
« on: February 11, 2006, 05:35:17 pm »
Hi,

Search the forum for AssociationClass and Lozenge.

You'll find some ramblings that should explain some of it.  If they don't, come back here with questions and I'll try to help.

HTH,
Paolo

Pages: 1 ... 353 354 [355] 356 357 ... 409