Book a Demo

Author Topic: Creating objects in collaboration diagrams  (Read 6508 times)

p.pienaar

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Creating objects in collaboration diagrams
« on: June 03, 2004, 03:36:41 pm »
Hi,

I've got a question for all you UML gurus out there - how do you show object creation (i.e. calling a constructor and an object being instantiated) in a collaboration diagram?

I have an object which I need to create another object, and then call a method on that object.

Thanks in advance,

-Phil

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Creating objects in collaboration diagrams
« Reply #1 on: June 03, 2004, 04:44:38 pm »
This is, indeed, one of the mysteries of the universe.  I have myself spent 1..* lifetimes trying to decide how best to do this.

Enlightenment, they say, comes with ages and lasts for seconds ... but this is my take on the issue.

In collaboration diagrams we are concerned with conceptual level material.  The implementation is not specified.  That is, the act of creation of an object is left to (insert deity of choice here).

In sequence diagrams the issue becomes more germaine and a mechanism is provided to show the act of instantiation.

IOW, the collaboration diagram is only identifying what information exchanges occur between objects, not how messaging flows (this includes instantiation).  The sequencing of collaboration messages is there (IMO) only to link message chains together, not to imply some temporal information.

So to answer your question... I would not show the creational message just the method call. i.e. assume that the object is created.

Having said that....

I have a problem with this for nontrivial constructors.  Example A: Zoo x = new Zoo(); which in itself creates rafts of other objects - cages, aquaurims, giraffes etc.  In this case must the constructor call be shown?  Probably not, given the above explanation.
Example B: Encyclopaedia EB = new Encyclopaedia (rafts and rafts of parameters); in this case there is a information component in the constructor call and I have  for some reason decided that this information must be passed to the object exactly when it is constructed.  That is, the parameterised information and the fact that the message must be implemented as a constructor is important.  It would b nice to have this visuall represented in UML - but it aint!


Hope that's gurulike enough for you (never answer a question without raising another  ;D )

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.

p.pienaar

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Creating objects in collaboration diagrams
« Reply #2 on: June 07, 2004, 02:11:47 pm »
Thanks mate for your insight into collaboration - I think it really helped me get in touch with my inner dolphin ..

FYI I managed to find an example of an object being instantiated in a book called 'UML and the Unified Process' by Jim Arlow & Ila Neustadt, which is a Booch Jacobson Rumbaugh title by Addison Wesley ..

The object is instantiated by sending it a <<create>> message  :) Funny that ..

Anyway that just adds some confusion to the mix

Cheers again for your help

-P