How to represent a constructor in UML?

M

mrdoommaster

Hi,

How do I represent a constructor in UML?

Say I have a class named Foo. Would it look like so:

+Foo( some_val : int )

Is the above correct? Thanks for reading.
 
R

rcdailey

Hi,

How do I represent a constructor in UML?

Say I have a class named Foo. Would it look like so:

+Foo( some_val : int )

Is the above correct? Thanks for reading.

One more thing... How do I represent const parameter values? For
example:

void Bar( const std::string& file );

In UML, would this be:

+Bar( file : const std::string& )

Is the above correct? Thanks for your help.
 
V

Victor Bazarov

One more thing... How do I represent const parameter values? For
example:

void Bar( const std::string& file );

In UML, would this be:

+Bar( file : const std::string& )

Is the above correct? Thanks for your help.

Consider posting to comp.object. They are more likely involved
with UML than folks here. I am yet to meet somebody who uses
UML while programming in C++.

V
 
R

rcdailey

Consider posting to comp.object. They are more likely involved
with UML than folks here. I am yet to meet somebody who uses
UML while programming in C++.

V

Thanks; I did a search for "UML" in the newsgroup list but I was
unable to find related groups. I will use the group you suggested.
Thanks again!

PS: Just curious, why do most C++ programmers not use UML? I have a co-
worker that swears by it. In fact, he believes in UML so much that he
doesn't believe you can create a reliable set of C++ interfaces
without it. What do C++ programmers do during the design phase-
interface implementation?
 
W

werasm

PS: Just curious, why do most C++ programmers not use UML? I have a co-
worker that swears by it. In fact, he believes in UML so much that he
doesn't believe you can create a reliable set of C++ interfaces
without it. What do C++ programmers do during the design phase-
interface implementation?

I consider myself a c++ programmer and we use UML for a subset
of our work. For one, it does not scale well with templates (IMO).
Also, code generators generate sub-optimal code.
 
I

Ian Collins

PS: Just curious, why do most C++ programmers not use UML? I have a co-
worker that swears by it. In fact, he believes in UML so much that he
doesn't believe you can create a reliable set of C++ interfaces
without it. What do C++ programmers do during the design phase-
interface implementation?
UML can be a useful high level documentation tool, by having to maintain
a UML design (or any other form of detailed design) in the face of
shifting requirements code improvements is one chore too many.

Maybe things will change when the quality of round-tripping tools
improves to the point where we don't write code anymore.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Thanks; I did a search for "UML" in the newsgroup list but I was
unable to find related groups. I will use the group you suggested.
Thanks again!

PS: Just curious, why do most C++ programmers not use UML? I have a co-
worker that swears by it. In fact, he believes in UML so much that he
doesn't believe you can create a reliable set of C++ interfaces
without it. What do C++ programmers do during the design phase-
interface implementation?

UML is a programming language of its own, it does not try to model some
other language (or, you can say that it tries to model them all) which
means that you can hardly ever get a one to one mapping between the UML
model and the actual code, at least not if you want good code.

Because of this I think UML is useful when creating abstract designs,
and to discuss ideas. But it is not good as a specification of the
actual code, so if it's going to be used you have to take care not
spending to much time perfecting the UML design, since it probably will
not hold in the end.
 
?

=?iso-8859-1?q?Kirit_S=E6lensminde?=

That's the way I normally do it.
One more thing... How do I represent const parameter values? For
example:

void Bar( const std::string& file );

In UML, would this be:

+Bar( file : const std::string& )

Is the above correct? Thanks for your help.

I think you could do it that way. Normally I would do this:

~Bar( file : std::string )

You are logically passing a string (as copy), but the const reference
is an (implementation) optimisation to avoid copying the string. I
don't see it as part of the logical type for the member.

We use UML for C++ code generation, but the UML design sits at the
level of the object model above where the C++ is. There is an example
of the sort of UML design we use here:
http://www.kirit.com/Netflix Prize/Design/Static data/Class diagram

The diagram shows the highest level object model which produces
artefacts that can be interacted with through SQL, C++ and COM and
HTTP (via HTML).


K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top