C# Class, Interface, Enum and Other Concepts in UML
C# Class in UML
A simple class can include contructors, fields and methods. The visibility of fields and methods can be restricted to:
- private - is accessible only within the same class, UML symbol is minus -
- protected - is accessible within the same class and inherited classes, UML symbol is hash #
- internal - is accessible within the same assembly, UML symbol is tilde ~
- public - is freely accessible, UML symbol is plus +
Read-only fields (C# keyword: readonly) are marked with a UML {readonly} modifier. To set it, right-click on a UML attribute and choose Modifiers from the context menu and then Read-Only.
Static fields (C# keyword: static) are expressed using a UML static modifier. They are depicted as underlined text. To set it, right-click on a UML attribute and choose Modifiers from the context menu and then Static.
C# Properties in UML
C# properties can be modeled as UML attributes with property stereotype. You can set the stereotype in multiple ways:
- type <<property>> before the attribute name when editing an attribute in the diagram editor
- select an attribute and choose from the ribbon - Field tab / Add group / Stereotype button / property
- right-click on an attribute and in the context menu choose Stereotypes / property
Software Ideas Modeler allows you to define source codes for the get and set body of a property.
C# Abstract Class in UML
An abstract class with abstract properties and methods can be modeled using UML notation. An abstract class cannot be instantiated and it can contain methods without implementation. The logic of method bodies can be defined in subclasses. An abstract field and abstract method are rendered using an italic font.
C# Static Class in UML
A static class with static fields and methods can be modeled using UML notation. A static class cannot be instantiated or inherited and it can contain only static members. A static class represents a singleton design pattern. A static class is defined using static stereotype in UML.
C# Generic Class
A generic class defines generic parameters. They are represented by UML template parameters.
You can add a new template parameter to a class using the ribbon / Model tab / Add group / Template Parameter button.
C# Events and Delegates
You can also model events and delegates using UML tool Software Ideas Modeler. Events are modeled as UML attributes with an event stereotype. Delegates are modeled as UML operations with a delegate stereotype.
C# Attributes
UML does not provide direct support for the concept of C# attributes. However, you can use tagged values. You can add tag Annotation with an attribute definition in the value using Software Ideas Modeler to add C# attribute to a class, field, or method. The source generator will translate the tagged value to the attribute.
C# Inheritance in UML
An inheritance of classes can be modeled directly using UML. You can connect a subclass with a superclass using UML generalization. The triangle head arrow of generalization points from a subclass to a superclass.
C# Nested Classes in UML
A nested class can be defined using UML containment relationship. The connector is depicted as a circle with the plus sign inside, the circle end is connected to the container class, the other end is connected to the nested class.
C# Class Composition in UML
You can use a class as a field type of another class using the UML composition association. In this way, classes can create complex hierarchies.
C# Interfaces in UML
Interfaces define what members are expected from a classifier, but it does not define any implementation for them. C# interfaces can be modeled using UML interfaces. UML interfaces are associated to classes using realization relationships.
C# Enum in UML
An enumeration defines a set of named values. Numeric values can be defined for particular enumeration items. C# enums are modeled using UML enumerations. If you want to define an enum with flags - use flags stereotype for the enumeration.
C# Namespace in UML
A namespace is defined using UML package element. The root namespace can be defined in the repository element (diagram, folder). The setting is available as Custom Namespace field in the Properties dialog for Diagram or Folder. The field must be checked and filled.
C# Using in UML
Usings can be defined for the particular classes using tagged values. Enter the desired usings as values for Import tags
nudelchef 11 March 2021 9:34:11
C# Properties in UML
Dusan Rodina - softwareideas.net 12 March 2021 9:19:45
RE: C# Properties in UML
Cool 9 February 2022 14:22:34
Suggestions
Dusan Rodina - softwareideas.net 9 February 2022 21:48:22
RE: Suggestions