UML Representations in Visio 
Author Message
 UML Representations in Visio

I've started playing with the UML code generation in Visio for C#. I'm
wondering about a few things however (and if it makes it any easier to
explain, I really don't know a whole lot about UML -- it's a sort of learn
UML by figuring out how it represents code that I'm more familiar with).

How do I create an interface and then "attach" it to a class that implements
that interface? So far I've only been able to figure out how to inherit from
a UML interface. Obviously that isn't going to work very well if I want a
class to implement more than one interface.

I've managed to add a "collection" of objects to a class (e.g. a user has
multiple addresses). The generated code puts the collection into an array
(nice improvement over what Visual Modeler did for VB), but there is no
relationship shown between the classes. Should there be an association of
some sort? If so, which one?

Thanks for any clues you can provide. And if there is a reference that has
UML diagrams and the associated C# code for common programming situations,
that would be helpful too.

Colin



Sun, 21 Mar 2004 21:36:11 GMT  
 UML Representations in Visio
Colin,
I take it the version of Visio included with VS.Net (you did say for C# ;-))

You should have the UML Static Structure Shapes open.

To create an interface drag an interface shape onto your drawing page. You
can use either the box shape, or the lollipop. I normally use the box shape
when I am defining the interface, then use the lollipop to identify the
class implements the interface...

To implement the interface drag the interface from the "Model Explorer" onto
one of the class's connection points (blue x on edge), so one end of the
interface (it should be a lollipop) turns red, meaning it is "connected".

The "Binary Association" and "Composition" represents collections &
references. Based on the Multiplicity value of either end of the
association... Composition is just a special case Association (ownership)!

Dependency I think of more as "makes use of" such as in a method, or method
parameter...

Hope this helps
Jay


Quote:
> I've started playing with the UML code generation in Visio for C#. I'm
> wondering about a few things however (and if it makes it any easier to
> explain, I really don't know a whole lot about UML -- it's a sort of learn
> UML by figuring out how it represents code that I'm more familiar with).

> How do I create an interface and then "attach" it to a class that
implements
> that interface? So far I've only been able to figure out how to inherit
from
> a UML interface. Obviously that isn't going to work very well if I want a
> class to implement more than one interface.

> I've managed to add a "collection" of objects to a class (e.g. a user has
> multiple addresses). The generated code puts the collection into an array
> (nice improvement over what Visual Modeler did for VB), but there is no
> relationship shown between the classes. Should there be an association of
> some sort? If so, which one?

> Thanks for any clues you can provide. And if there is a reference that has
> UML diagrams and the associated C# code for common programming situations,
> that would be helpful too.

> Colin



Mon, 22 Mar 2004 11:50:15 GMT  
 UML Representations in Visio
That's the version (now that I've realized I have it installed). I think
that info should give me enough to play with on the train tonight (I'm
learning C#/UML in 20 minute spurts during my commute home).

I think I have the hang of the multiplicity, but I'm still not sure what the
names of each end should be, or exactly what "composition" means (I think
that association is fairly straightforward). If I create a 0..* binary
association from say user to address (i.e. user has 0 or more addresses --
am I using the terminolgy correctly?) does that mean that Visio should
generate code that has an array of address objects? If I specify the
multiplicity of an attribute, Visio does the right thing (i.e. create an
array as appropriate), but I don't think it did when I used binary
association (I could be wrong and just don't remember what got generated
yesterday).

I realize that this has veered a wee bit off topic, but I've found that C#
is a nice fit with UML and with me.

Thanks for the help.

Colin



Quote:
> Colin,
> I take it the version of Visio included with VS.Net (you did say for C#
;-))

> You should have the UML Static Structure Shapes open.

> To create an interface drag an interface shape onto your drawing page. You
> can use either the box shape, or the lollipop. I normally use the box
shape
> when I am defining the interface, then use the lollipop to identify the
> class implements the interface...

> To implement the interface drag the interface from the "Model Explorer"
onto
> one of the class's connection points (blue x on edge), so one end of the
> interface (it should be a lollipop) turns red, meaning it is "connected".

> The "Binary Association" and "Composition" represents collections &
> references. Based on the Multiplicity value of either end of the
> association... Composition is just a special case Association (ownership)!

> Dependency I think of more as "makes use of" such as in a method, or
method
> parameter...

> Hope this helps
> Jay



> > I've started playing with the UML code generation in Visio for C#. I'm
> > wondering about a few things however (and if it makes it any easier to
> > explain, I really don't know a whole lot about UML -- it's a sort of
learn
> > UML by figuring out how it represents code that I'm more familiar with).

> > How do I create an interface and then "attach" it to a class that
> implements
> > that interface? So far I've only been able to figure out how to inherit
> from
> > a UML interface. Obviously that isn't going to work very well if I want
a
> > class to implement more than one interface.

> > I've managed to add a "collection" of objects to a class (e.g. a user
has
> > multiple addresses). The generated code puts the collection into an
array
> > (nice improvement over what Visual Modeler did for VB), but there is no
> > relationship shown between the classes. Should there be an association
of
> > some sort? If so, which one?

> > Thanks for any clues you can provide. And if there is a reference that
has
> > UML diagrams and the associated C# code for common programming
situations,
> > that would be helpful too.

> > Colin



Mon, 22 Mar 2004 21:24:09 GMT  
 UML Representations in Visio
Colin,
The 'end' names become the member name in the generated source. They read
'backwards', the end label closest to Class1, is the label for the variable
in Class2 of type Class1. While the end closest to Class2 is the variable in
Class1 of type Class2...

If you have Class1 & Class2, with a composition line between then. And the
diamond is pointing to Class1. The way I think of it: then Class1 is
"responsible" for Class2, that Class2 does not/can not exist without Class1.

I haven't played specifically with the generator, I would expect both
composition and Binary Association to create...

Menu option 'UML - Code - Preference's controls what gets generated for the
associations Array, Hashtable...

Yea, it probably does belong in microsoft.public.vsnet.enterprise.tools, but
I won't tell if you don't ;-)

Hope this helps
Jay


Quote:
> That's the version (now that I've realized I have it installed). I think
> that info should give me enough to play with on the train tonight (I'm
> learning C#/UML in 20 minute spurts during my commute home).

> I think I have the hang of the multiplicity, but I'm still not sure what
the
> names of each end should be, or exactly what "composition" means (I think
> that association is fairly straightforward). If I create a 0..* binary
> association from say user to address (i.e. user has 0 or more addresses --
> am I using the terminolgy correctly?) does that mean that Visio should
> generate code that has an array of address objects? If I specify the
> multiplicity of an attribute, Visio does the right thing (i.e. create an
> array as appropriate), but I don't think it did when I used binary
> association (I could be wrong and just don't remember what got generated
> yesterday).

> I realize that this has veered a wee bit off topic, but I've found that C#
> is a nice fit with UML and with me.

> Thanks for the help.

> Colin



> > Colin,
> > I take it the version of Visio included with VS.Net (you did say for C#
> ;-))

> > You should have the UML Static Structure Shapes open.

> > To create an interface drag an interface shape onto your drawing page.
You
> > can use either the box shape, or the lollipop. I normally use the box
> shape
> > when I am defining the interface, then use the lollipop to identify the
> > class implements the interface...

> > To implement the interface drag the interface from the "Model Explorer"
> onto
> > one of the class's connection points (blue x on edge), so one end of the
> > interface (it should be a lollipop) turns red, meaning it is
"connected".

> > The "Binary Association" and "Composition" represents collections &
> > references. Based on the Multiplicity value of either end of the
> > association... Composition is just a special case Association
(ownership)!

> > Dependency I think of more as "makes use of" such as in a method, or
> method
> > parameter...

> > Hope this helps
> > Jay



> > > I've started playing with the UML code generation in Visio for C#. I'm
> > > wondering about a few things however (and if it makes it any easier to
> > > explain, I really don't know a whole lot about UML -- it's a sort of
> learn
> > > UML by figuring out how it represents code that I'm more familiar
with).

> > > How do I create an interface and then "attach" it to a class that
> > implements
> > > that interface? So far I've only been able to figure out how to
inherit
> > from
> > > a UML interface. Obviously that isn't going to work very well if I
want
> a
> > > class to implement more than one interface.

> > > I've managed to add a "collection" of objects to a class (e.g. a user
> has
> > > multiple addresses). The generated code puts the collection into an
> array
> > > (nice improvement over what Visual Modeler did for VB), but there is
no
> > > relationship shown between the classes. Should there be an association
> of
> > > some sort? If so, which one?

> > > Thanks for any clues you can provide. And if there is a reference that
> has
> > > UML diagrams and the associated C# code for common programming
> situations,
> > > that would be helpful too.

> > > Colin



Tue, 23 Mar 2004 07:54:39 GMT  
 UML Representations in Visio
I got the binary association to generate a collection of my class, but I
needed to set the 'Navigable' property to true. It seems blindingly obvious
now why that should be the case...

I'll have to look into the generated code again and pay a bit closer
attention to the variable names. I was wondering where those came from :)

The code generation is actually really nice, and it can even handle
properties properly (I never liked the way Visual Modeler represented
properties as 2 operations -- I know that's how they were implemented in VB,
but it just didn't make any conceptual sense to me). I still can't get it to
generate the full code for inheritance however (e.g. class1 is virtual and
class2 inherits from class1, i.e. public class class2: class1 {...}, but the
virtual function stubs for class1 are not generated in class2).

Would I be correct in thinking of composition as class2 is composed of the
code specific to class2 and an instance of class1 that provides essential
functionality to class2? That appears to be what gets generated.

Thanks again for all the assistance.



Quote:
> Colin,
> The 'end' names become the member name in the generated source. They read
> 'backwards', the end label closest to Class1, is the label for the
variable
> in Class2 of type Class1. While the end closest to Class2 is the variable
in
> Class1 of type Class2...

> If you have Class1 & Class2, with a composition line between then. And the
> diamond is pointing to Class1. The way I think of it: then Class1 is
> "responsible" for Class2, that Class2 does not/can not exist without
Class1.

> I haven't played specifically with the generator, I would expect both
> composition and Binary Association to create...

> Menu option 'UML - Code - Preference's controls what gets generated for
the
> associations Array, Hashtable...

> Yea, it probably does belong in microsoft.public.vsnet.enterprise.tools,
but
> I won't tell if you don't ;-)

> Hope this helps
> Jay



> > That's the version (now that I've realized I have it installed). I think
> > that info should give me enough to play with on the train tonight (I'm
> > learning C#/UML in 20 minute spurts during my commute home).

> > I think I have the hang of the multiplicity, but I'm still not sure what
> the
> > names of each end should be, or exactly what "composition" means (I
think
> > that association is fairly straightforward). If I create a 0..* binary
> > association from say user to address (i.e. user has 0 or more
addresses --
> > am I using the terminolgy correctly?) does that mean that Visio should
> > generate code that has an array of address objects? If I specify the
> > multiplicity of an attribute, Visio does the right thing (i.e. create an
> > array as appropriate), but I don't think it did when I used binary
> > association (I could be wrong and just don't remember what got generated
> > yesterday).

> > I realize that this has veered a wee bit off topic, but I've found that
C#
> > is a nice fit with UML and with me.

> > Thanks for the help.

> > Colin



> > > Colin,
> > > I take it the version of Visio included with VS.Net (you did say for
C#
> > ;-))

> > > You should have the UML Static Structure Shapes open.

> > > To create an interface drag an interface shape onto your drawing page.
> You
> > > can use either the box shape, or the lollipop. I normally use the box
> > shape
> > > when I am defining the interface, then use the lollipop to identify
the
> > > class implements the interface...

> > > To implement the interface drag the interface from the "Model
Explorer"
> > onto
> > > one of the class's connection points (blue x on edge), so one end of
the
> > > interface (it should be a lollipop) turns red, meaning it is
> "connected".

> > > The "Binary Association" and "Composition" represents collections &
> > > references. Based on the Multiplicity value of either end of the
> > > association... Composition is just a special case Association
> (ownership)!

> > > Dependency I think of more as "makes use of" such as in a method, or
> > method
> > > parameter...

> > > Hope this helps
> > > Jay



> > > > I've started playing with the UML code generation in Visio for C#.
I'm
> > > > wondering about a few things however (and if it makes it any easier
to
> > > > explain, I really don't know a whole lot about UML -- it's a sort of
> > learn
> > > > UML by figuring out how it represents code that I'm more familiar
> with).

> > > > How do I create an interface and then "attach" it to a class that
> > > implements
> > > > that interface? So far I've only been able to figure out how to
> inherit
> > > from
> > > > a UML interface. Obviously that isn't going to work very well if I
> want
> > a
> > > > class to implement more than one interface.

> > > > I've managed to add a "collection" of objects to a class (e.g. a
user
> > has
> > > > multiple addresses). The generated code puts the collection into an
> > array
> > > > (nice improvement over what Visual Modeler did for VB), but there is
> no
> > > > relationship shown between the classes. Should there be an
association
> > of
> > > > some sort? If so, which one?

> > > > Thanks for any clues you can provide. And if there is a reference
that
> > has
> > > > UML diagrams and the associated C# code for common programming
> > situations,
> > > > that would be helpful too.

> > > > Colin



Tue, 23 Mar 2004 21:46:00 GMT  
 UML Representations in Visio
Colin,
Not sure what to suggest on the inheritance.

You are using Generalization correct?

If you hold down the Ctrl key while you drag & drop a method from one class,
to another class in the Model Explorer it will copy the method to the other
class. Then change the 'Has Method' under 'Method' on the operations
properties of the second class to make it concrete... It would be nice if
Visio could do this for you... ;-)

Sounds like you have the idea behind Composition.

Hope this helps
Jay


Quote:
> I got the binary association to generate a collection of my class, but I
> needed to set the 'Navigable' property to true. It seems blindingly
obvious
> now why that should be the case...

> I'll have to look into the generated code again and pay a bit closer
> attention to the variable names. I was wondering where those came from :)

> The code generation is actually really nice, and it can even handle
> properties properly (I never liked the way Visual Modeler represented
> properties as 2 operations -- I know that's how they were implemented in
VB,
> but it just didn't make any conceptual sense to me). I still can't get it
to
> generate the full code for inheritance however (e.g. class1 is virtual and
> class2 inherits from class1, i.e. public class class2: class1 {...}, but
the
> virtual function stubs for class1 are not generated in class2).

> Would I be correct in thinking of composition as class2 is composed of the
> code specific to class2 and an instance of class1 that provides essential
> functionality to class2? That appears to be what gets generated.

> Thanks again for all the assistance.

<<snip>>


Sat, 27 Mar 2004 08:37:08 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Visio UML C++ help

2. VC++.net Enterprise and Visio/UML question

3. [visio uml]

4. Visio UML

5. visio, uml, and templates <slightly off topic>

6. Visio 2002 .vsl add-ins using C# possible???

7. How to disable showing operation signatures in Visio

8. How to add / Show Visio component in C#

9. visio confusion

10. Visio for Enterprise Architects

11. Visio 2002 - Update model from code

12. Need to display Visio preview thumbnails from C#

 

 
Powered by phpBB® Forum Software