11
Теория моделирования и нотации / Как правильно структурировать диаграмму классов в PlantUml?
« Последний ответ от Виталий И 06 Мая 2024, 00:14:08 »Как правильно структурировать диаграмму классов в PlantUml?
Пробую построить диаграмму классов в PlantUml, получаю кашу.
```cs
class MainViewModdel : BaseViewModdel
{
Entity1ViewModdel _entity1ViewModdel;
Entity2ViewModdel _entity2ViewModdel;
Entity3ViewModdel _entity3ViewModdel;
public MainViewModdel()
{
_entity1ViewModdel = new Entity1ViewModdel();
_entity2ViewModdel = new Entity2ViewModdel();
_entity3ViewModdel = new Entity3ViewModdel();
}
}
class Entity1ViewModdel : BaseViewModdel
{
+ Main(args: string[]): void
}
class Entity2ViewModdel : BaseViewModdel
{
+ Main(args: string[]): void
}
class Entity3ViewModdel : BaseViewModdel
{
+ Main(args: string[]): void
}
```
```cs
internal abstract class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string PropertyName = null)
{
// Код...
}
protected virtual bool Set<T>(ref T field, T value, [CallerMemberName] string PropertyName = null)
{
// Код...
}
}
```
# uml
```puml
skinparam linetype ortho
left to right direction
class BaseViewModel {
+ event PropertyChangedEventHandler PropertyChanged;
# virtual void OnPropertyChanged([CallerMemberName] string PropertyName = null)
# virtual bool Set<T>(ref T field, T value, [CallerMemberName] string PropertyName = null)
}
class MainViewModel {
- _entity1ViewModel : Entity1ViewModel
- _entity2ViewModel : Entity2ViewModel
- _entity3ViewModel : Entity3ViewModel
+ MainViewModel()
}
class Entity1ViewModel {
+ Main(args: string[]): void
}
class Entity2ViewModel {
+ Main(args: string[]): void
}
class Entity3ViewModel {
+ Main(args: string[]): void
}
BaseViewModel <|-- MainViewModel
BaseViewModel <|-- Entity1ViewModel
BaseViewModel <|-- Entity2ViewModel
BaseViewModel <|-- Entity3ViewModel
MainViewModel --> Entity1ViewModel
MainViewModel --> Entity2ViewModel
MainViewModel --> Entity3ViewModel
```
Пробую построить диаграмму классов в PlantUml, получаю кашу.
```cs
class MainViewModdel : BaseViewModdel
{
Entity1ViewModdel _entity1ViewModdel;
Entity2ViewModdel _entity2ViewModdel;
Entity3ViewModdel _entity3ViewModdel;
public MainViewModdel()
{
_entity1ViewModdel = new Entity1ViewModdel();
_entity2ViewModdel = new Entity2ViewModdel();
_entity3ViewModdel = new Entity3ViewModdel();
}
}
class Entity1ViewModdel : BaseViewModdel
{
+ Main(args: string[]): void
}
class Entity2ViewModdel : BaseViewModdel
{
+ Main(args: string[]): void
}
class Entity3ViewModdel : BaseViewModdel
{
+ Main(args: string[]): void
}
```
```cs
internal abstract class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string PropertyName = null)
{
// Код...
}
protected virtual bool Set<T>(ref T field, T value, [CallerMemberName] string PropertyName = null)
{
// Код...
}
}
```
# uml
```puml
skinparam linetype ortho
left to right direction
class BaseViewModel {
+ event PropertyChangedEventHandler PropertyChanged;
# virtual void OnPropertyChanged([CallerMemberName] string PropertyName = null)
# virtual bool Set<T>(ref T field, T value, [CallerMemberName] string PropertyName = null)
}
class MainViewModel {
- _entity1ViewModel : Entity1ViewModel
- _entity2ViewModel : Entity2ViewModel
- _entity3ViewModel : Entity3ViewModel
+ MainViewModel()
}
class Entity1ViewModel {
+ Main(args: string[]): void
}
class Entity2ViewModel {
+ Main(args: string[]): void
}
class Entity3ViewModel {
+ Main(args: string[]): void
}
BaseViewModel <|-- MainViewModel
BaseViewModel <|-- Entity1ViewModel
BaseViewModel <|-- Entity2ViewModel
BaseViewModel <|-- Entity3ViewModel
MainViewModel --> Entity1ViewModel
MainViewModel --> Entity2ViewModel
MainViewModel --> Entity3ViewModel
```