0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Goでクラス図を自動生成する

Posted at

はじめに

表題通り、Goでクラス図を自動生成します。goplantumlを使うと簡単に生成できます。

成果物

goplantumlを使うとクラス図を自動生成できます。
pokemon_battle.png

準備

goplantumlのinstall
go install github.com/jfeliu007/goplantuml/cmd/goplantuml@latest
PNG画像を生成するためのツール
brew install plantuml

UMLを作成する

UMLを作成する
~/develop/pokemon_battle (feat/initial)$ goplantuml internal/core > pokemon_battle.puml

これで下記ファイルが作成されます。

pokemon_battle.puml
@startuml
namespace core {
    class Battle << (S,Aquamarine) >> {
        + Pokemon1 *Pokemon
        + Pokemon2 *Pokemon

        + Start() string

    }
    class Move << (S,Aquamarine) >> {
        - randSource *rand.Rand

        + Name string
        + Power int
        + Accuracy int
        + Type string

        + CanHit() bool
        + CalculateDamage(attacker *Pokemon, defender *Pokemon) int

    }
    class Pokemon << (S,Aquamarine) >> {
        + Name string
        + HP int
        + Attack int
        + Defense int
        + Speed int
        + Moves []Move

        + AttackPokemon(target *Pokemon, move Move) (int, error)
        + IsFainted() bool

    }
}


@enduml

これを画像ファイルに出力します。

pngを出力
~/develop/pokemon_battle (feat/initial)$ plantuml pokemon_battle.puml  

感想

簡単に作れるので、構成を軽く見るのに良いですね!!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?