File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes UML and Constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "UML and Constructors" Watch "UML and Constructors" New topic

UML and Constructors

Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
i was just wondering... do we have to put Constructors as part of Class Diagrams? if so, where? are they considered Operations?

SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
Deepak Arora

Joined: Jul 10, 2001
Posts: 26
if you See Larman diagrams, you will note that he has used message create() to instantiate a new object in the interaction diagram , actually every language has its own way of creating a new object, (e.g java instantiate with new operator) & UML can not provide any language dependent notation of creating new object therefore there is no notion of constroctor in UML(correct me UML gurus if i am mistaken)
Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
thanks for the input Deepak! it's all coming back now.. i guess you're right! i remember using create in place of Constructors before and yep we got it from a book by Craig Larman. thanks again Deepak!
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
That's correct!create() is a language-independent way to create a new instance of a class in UML.The message should be passed actually be passed to a class, but UML allows it to be passed to an instance.
The create() of UML gets translated to language-dependent syntax of OO language(for example, new operator in Java)
-- Sandeep
[This message has been edited by Desai Sandeep (edited July 11, 2001).]
I agree. Here's the link:
subject: UML and Constructors
It's not a secret anymore!