alchemical
alchemical

Reputation: 13985

Visual Studio 2008 Class Designer - associations

We are attempting to use VS2008 Class Designer for a UML-like class diagram. However, when we create an "association" link between two classes, VS2008 is adding lines to our code! We do not want this.

One reason we don't want this is that our idea of association (via a collection parrameter, etc.) is different than VS2008. For example, we have the following types of association we would like to include in the class diagram:

  1. Class A is a property of Class B.
  2. Class A is inside a collection property of Class B.
  3. Class A instantiates and uses a property or method of Class B.

VS2008 seems to consider all relationships to be of type #1 and to force them into this model by re-writing the code. Is there anyway to use the VS2008 class modeling tool to more effectively accommodate all 3 types of associations?

UPDATE: I went with Visio, however I think there are some tools out there allowing UML modeling with round-tripping, including Enterprise Architect and possible VS2010.

Upvotes: 0

Views: 1673

Answers (4)

Esther Fan - MSFT
Esther Fan - MSFT

Reputation: 8516

Visual Studio 2010 Ultimate support UML class diagrams as well as sequence, component, use case, and activity diagrams. Editing these diagrams won't affect your code. You can also create sequence, dependency graphs, and layer diagrams from code and edit them to focus on the areas that you want. Changes to these diagram also will not affect your code.

I've posted more links on my profile for more info.

Upvotes: 0

John Saunders
John Saunders

Reputation: 161773

You should clarify. What do you mean "Class A is a property of Class B"? Do you mean that Class B has a property of type "A"?

That is not an association in UML terms - it's a dependency. In fact, all of your examples are dependencies, and not associations.


Do you mean:

public class ClassA {}

public class ClassB
{
    public ClassA Property1 {get;set;}
}

If this is what you mean, then I would read it as

Class B has a property named "Property1". Property1 is of type "ClassA".

In UML, this is not an association - it's a dependency.


I'll concede that there is a subset of the set of properties which do correspond directly to associations. In fact, my example above is a member of that subset.

A counter-example (and what I was thinking about) is:

public class ClassA {}

public class ClassB
{
    public ClassA Property1 
    {
        get {/* perform some arbitrary calculation, then return the result */}
        set {}
    }
}

I apologize for thinking about the general case, and not the specific case.

The real answer to the original question has already been given: the Class Designer is a Class Designer, not a UML Class Diagram tool. It uses a notation similar to that of a UML Class Diagram, but it is not a tool for producing a Class Diagram - it is a tool for designing a .NET class.

Contrast this with the UML Class Diagram available in Visual Studio 2010, which is UML first, and class design second.

Upvotes: 1

Josh
Josh

Reputation: 69262

Class designer is not a general purpose diagramming tool like Visio. It's the "winforms designer" for POCO classes. It'd be like putting a label on a form to act as an annotation but not wanting visual studio to actually create the label.

Upvotes: 0

CesarGon
CesarGon

Reputation: 15335

Use Visio. The class diagram designer in Visual Studio is designed to tightly integrate with your code and keep in synch with it.

Upvotes: 1

Related Questions