Author Topic: class multiplicity  (Read 4586 times)

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
class multiplicity
« on: May 23, 2004, 05:46:51 pm »
This, asked by one of the analysts, stumped me.  :-[

On a class element, in the properties window, in the Advanced section, one can set multiplicity.  And this shows up on the diagram in the class name compartment below the name on the RHS as, for example {1..*}

What does multiplicity on a class "mean"?

tia
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: class multiplicity
« Reply #1 on: May 23, 2004, 05:52:04 pm »
Hi Bruce,
I remeber this question being asked in this or the UML forum. It's something new that came with UML 2.0. Probably you should try to search (I'm too lazy  ;))

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: class multiplicity
« Reply #2 on: May 23, 2004, 06:10:44 pm »
Been there, tried that :(

It goes to great lengths to explain what a mulitplicity is, how to denote it and reams of (...) on OCL'ing it.

But it don't say what it means.  

It appears that you can apply multiplicity to any classifier, which makes sense (sort of) for other types of classifiers.  But I still cant see how a class can be multiple???

I hate mondays
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.

Stephen

  • EA User
  • **
  • Posts: 54
  • Karma: +0/-0
    • View Profile
Re: class multiplicity
« Reply #3 on: May 24, 2004, 02:14:39 am »
Hi Bruce,

Wild stab in the dark here (I don't claim any sort of expertise modelling).

If a class is instantiated as a singleton, would this nomenclature be useful(?) to signify that other linked classes weren't? Does it have any impact on code generated in forward engineering?

Given classes are abstract objects rather than "real" ones, it does seem rather strange.

Other uses for those with great modelling subtlety might be in true parallel execution systems (must dig out that erlang compiler) ;)

thomaskilian

  • Guest
Re: class multiplicity
« Reply #4 on: May 24, 2004, 08:03:06 am »
Funny, couldn't find that post here although I was a 100% shure having read it???. Tried to google but also no luck. So my best guess for it: class multiplicity is some kind of template. If you use association with multiplicity the meaning is clear. Attaching the multiplicity to the class could be used for each association automatically? Anything else doesn't seem to make sense.

Barry_Pearce

  • EA User
  • **
  • Posts: 70
  • Karma: +0/-0
    • View Profile
Re: class multiplicity
« Reply #5 on: June 24, 2004, 04:10:54 pm »
The concept is not new and has been around since early 90s and the days of booch. The multiplicity on a class denotes the number of concurrent instances that are allowed.

{1} = singleton
{ * } = no restriction
{ 4 } = there will be 4
{ 0..4 } = there will be 0-4 instances

this creational restriction can be enforced through design patterns used for object creation - such as factory methods etc.

to be honest normally on unrestricted or singleton are used - however it depends entirely on your design.

Do not confuse multiplicity on the class though with multiplicity offered on associations,.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: class multiplicity
« Reply #6 on: June 24, 2004, 04:25:28 pm »
Thanks Barry,

I was thinking it was something "new" and ignored the possibility that it was something that has been hanging around...

Singletons and "any number" are, as you say pretty obvious.  I suppose if you were building a tennis game you may wish to limit the number of "player" instances to 2 or 4 exactly.  Similarly, electron shell container classes may have rules that would mean that they could contain 0..n electron instances.  Hmm, I wonder if there is a UML representation of the Pauli Exclusion Principal (more than one instance cannot have the same attribute values at a single point in time)  :-/

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.

Barry_Pearce

  • EA User
  • **
  • Posts: 70
  • Karma: +0/-0
    • View Profile
Re: class multiplicity
« Reply #7 on: June 28, 2004, 07:42:59 am »
That would be covered by OCL (Object Constraint Language) which allows you to express these sorts of constraints - would be nice to have more OCL support in EA to be honest with you. For reference see

The Object Constraint Language: Precise modelling with UML
Jos Warmer & Anneke Kleppe
ISBN 0-201-37940-6
Addisson-Wesley, 1999

OCL is AFAIK part of the UML 2.0 standard (from what I have seen of the specs at www.omg.org)

Hope this helps.