Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to represent a C# property in UML?

Not quite an Attribute, not quite a Method. Stereotypes? <<get>> <<set>>?


I'm retro-modelling an existing system, so I need to clearly reflect that this is not the same as a readonly field or a methods pair (regardless of what the IL says), so I think I'll go with the stereotype, but I'll accept the language independant get_ set_ as a general solution. Thanks all for the sanity test.

like image 533
annakata Avatar asked Jan 22 '09 17:01

annakata


People also ask

What does ⊆ mean in math?

In set theory, a subset is denoted by the symbol ⊆ and read as 'is a subset of'. Using this symbol we can express subsets as follows: A ⊆ B; which means Set A is a subset of Set B. Note: A subset can be equal to the set.

What is a ∩ C?

A intersection B intersection C represents the common elements of the sets A, B, and C respectively. This is generally represented as A n B n C. The symbol 'n' represents intersection and gives the common element of the two sets.

What does ⊂ mean in math?

The symbol "⊂" means "is a proper subset of". Example. Since all of the members of set A are members of set D, A is a subset of D. Symbolically this is represented as A ⊆ D. Note that A ⊆ D implies that n(A) ≤ n(D) (i.e. 3 ≤ 6).

What is the symbol of C in math?

The capital Latin letter C is used in mathematics as a variable. For example, it appears in geometric formulas as a variable representing the circumference of a circle. It also is used to represent the set of complex numbers displayed using a “double-struck” typeface.


2 Answers

I usually prepare my UML diagrams in Visio (I know, I know; but what're ya gonna do?).

When diagramming properties, they end up as so:

+------------------------+ | MyClass                | |------------------------| | - _foo : int           | |------------------------| | «property» + Foo : int | +------------------------+ 

«property» being a custom stereotype derived from «operator».

Ugly, I know. But it works, and it's clear. I do constructors the same way.

like image 63
Mike Hofer Avatar answered Oct 01 '22 12:10

Mike Hofer


Properties are just a convenient way of writing get_MyValue() and set_MyValue(value) allowing assignment rather than the normal method calling (using parenthesis).

What you are accessing is actually a .NET property, C# has its own syntax for accessing these. Since under the skin the real get_ and set_ methods are created, so you could simply show those methods (to make your UML language independent - e.g. make your UML equally applicable to a VB.NET developer)

... or as you have suggested, introduce your own stereotype!

like image 26
Ray Hayes Avatar answered Oct 01 '22 13:10

Ray Hayes