Steve Cook's WebLog

Class Diagrams

The most familiar UML diagram is the class diagram.  A class diagram can mean many different things.  If you look around a room in which developers are writing software, you’ll often see whiteboards with UML class diagrams on.  This is UmlAsSketch.  The rectangles on these diagrams are 1:1 with the code.  But this raises something of a conflict with the UML specification.  Let’s say the code is C# - which it often is, where I work.   C# only has single inheritance of classes, while UML has multiple.  C# has fields, properties, methods, events, indexers, constructors and destructors, while UML has attributes and operations – actually C# has attributes too, but they mean something completely different.  UML defines visibility to be public, private, protected and package: C# agrees on the first three, but also has internal and protected internal and does not have package.

A second popular use for UML class diagrams is conceptual object models (often called analysis models).  The classes in these models don’t represent actual classes in the code; instead they represent conceptual entities that interact to represent the behaviour of the proposed software without thinking much about implementation issues like persistence, user interaction, performance, or security.  Many authors wrote about using such diagrams for “object oriented analysis” during the 1990s: indeed that was the impetus behind the “unification” of the UML.  Proponents of Model Driven Development frequently generate code from these diagrams, and it’s this use of class diagrams that is best catered for by the current UML specification.

Another popular use for these diagrams is conceptual data models.  For example, a software designer who uses use cases to represent the interactions between system components needs to say what kinds of data traverse the lines in their diagram.  UML diagrams can be used to represent entities and relationships for this – although again, there are problematical mismatches between the specification and the way that the diagrams are used in practice.

Pragmatically, the UML class diagram is a successful reusable syntax, covering the uses I’ve listed above and more. But the current scheme of UML profiles falls short of representing these uses.  For example you can't change the visibility scheme, and it's very hard to find an effective way of representing C# properties that is consistent with the UML semantics.  So in Visual Studio we keep the physical and conceptual representations separate: the Class Designer looks rather like UML but directly represents the code, and we will also have the Logical Class Designer, which implements the UML specification and is used for logical (conceptual, analysis) class design.

What do you use Class Diagrams for?

Published Monday, October 13, 2008 10:47 AM by Steve Cook
Filed under:

Comments

 

Tad Anderson said:

I use class diagrams to design modules, layout architecture, and define ASP.NET WAE models.

Examples here:

http://www.softwareprocessengineering.com/Members/_SPE_Ex_012008/Example_Diagrams.htm

I also use class diagrams to develop Profiles (something MS uses DSLs for)

Example here:

http://www.softwareprocessengineering.com/Members/_SPE_Ex_012008/EPFMapPluginExample/index.html

I use class diagrams to do models for Product Line Engineering:

http://realworldsa.dotnetdevelopersjournal.com/umlstaticple.htm

I have a question:

Will the Microsoft VSTS 2010 Architecture UML tools be used?

As happy as I am to see Microsoft going with UML, I am hoping the grapevine is wrong, and that the tools are not exclusively for the VSTS 2010 Architecture version. I am afraid if that is the case, they won't be getting used very much at all. At least not in the environments I have been in lately.

Read the rest of the thought here:

http://realworldsa.dotnetdevelopersjournal.com/microsoftvsts2010architectureumltools.htm

October 13, 2008 9:21 AM
 

IHateSpaghetti {code} said:

Alot interesting posts this week - I collected the ones that I liked (and read their blog) the most.

October 18, 2008 3:00 PM
New Comments to this post are disabled

This Blog

Syndication

News

Locations of visitors to this page
Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the author’s discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.


© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker