Tag Archives: UML

mermaid

I wrote about PlantText before. It is about creating diagrams with code. mermaid is another one from the same category. Recently GitHub has given support for this.

I tried to create some class diagrams with mermaid online editor.

classDiagram

    class ILog {
        <<interface>>
        void LogInfo(string message)
        void LogWarn(string message)
        void LogError(string message)
    }

    class ConsoleLog {
        void LogInfo(string message)
        void LogWarn(string message)
        void LogError(string message)
    }
    ILog --|> ConsoleLog : Implements

    class FileLog {
        void LogInfo(string message)
        void LogWarn(string message)
        void LogError(string message)
    }
    ILog --|> FileLog : Implements

    class AppInsightsLog {
        void LogInfo(string message)
        void LogWarn(string message)
        void LogError(string message)
    }
    ILog --|> AppInsightsLog : Implements

    class IGreetService {
        <<interface>>
        string UserName

        string GetHello()
        string GetBye()
    }

    class GreetService {        
        string UserName
        ILog Logger

        string GetHello()
        string GetBye()
    }
    IGreetService --|> GreetService : Implements
    ILog ..> GreetService : Dependency

PlantText

Recently I need to create a UML diagram based on some domain models and I found a text based one called PlantText. In this you can write code to generate UML diagram. The main point of interest is you can store and manage your UML generation code in your source control the same way of your application code. You can re-generate the UML diagram from the code at any time from the PlantText website. Not just UML diagram they have many other kinds of diagram support as well.

https://www.planttext.com/

@startuml

abstract class Car {
  +int Id
  +string Name
  +void Start()
  +void Accelerate()
  +void DeAccelerate()
  +void Stop()
}

class BMW {
  +float Price
  +Location GetGpsLocation()
  +Warranty GetWarranty()
}

Car <|-down- BMW

@enduml