From d776b20bfad3b1861813f84b1d33aa03b4506874 Mon Sep 17 00:00:00 2001 From: ddddddO Date: Sun, 16 Oct 2022 15:57:08 +0900 Subject: [PATCH] add sample --- README.md | 9 +++- _example/component_design/README.md | 8 ++++ _example/component_design/components.pu | 27 ++++++++++++ _example/component_design/components.svg | 52 ++++++++++++++++++++++++ _example/component_design/main.go | 35 ++++++++++++++++ 5 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 _example/component_design/README.md create mode 100644 _example/component_design/components.pu create mode 100644 _example/component_design/components.svg create mode 100644 _example/component_design/main.go diff --git a/README.md b/README.md index cf682bc..f7a3bbf 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Easily manage 🕸DAG🕷 with Go.
DAG is an acronym for Directed Acyclic Graph.
Output is in PlantUML or Mermaid format.
-Useful for progressing tasks. +Useful for progressing tasks, designing components, etc... ⚠It is incompatible with v0.2.0 and earlier versions⚠ @@ -348,8 +348,13 @@ func main() { } ``` -### ginger grilled pork recipe (and more) +### Ginger grilled pork recipe (and more) ![dag](_example/dinner/dag.svg) +### Component design +![dag](_example/component_design/components.svg) + +- 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」P131 図14-4 より + # Reference - [about DAG](https://nave-kazu.hatenablog.com/entry/2015/11/30/154810) diff --git a/_example/component_design/README.md b/_example/component_design/README.md new file mode 100644 index 0000000..2a819c5 --- /dev/null +++ b/_example/component_design/README.md @@ -0,0 +1,8 @@ +# コンポーネントの依存関係 +- 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」P131 図14-4 + +![image](components.svg) + +```console +go run main.go > components.pu +``` \ No newline at end of file diff --git a/_example/component_design/components.pu b/_example/component_design/components.pu new file mode 100644 index 0000000..284e9e8 --- /dev/null +++ b/_example/component_design/components.pu @@ -0,0 +1,27 @@ +@startuml +rectangle "Main" as 1 +usecase "View" as 2 +usecase "Presenters" as 4 +usecase "Interactors" as 5 +usecase "Entities" as 8 +usecase "Permissions" as 9 +usecase "Database" as 7 +usecase "Controllers" as 3 +usecase "Authorizer" as 6 + +1 --> 2 +2 --> 4 +4 --> 5 +5 --> 8 +8 --> 9 +1 --> 5 +1 --> 7 +7 --> 5 +7 --> 8 +1 --> 3 +3 --> 5 +1 --> 6 +6 --> 5 +6 --> 9 + +@enduml diff --git a/_example/component_design/components.svg b/_example/component_design/components.svg new file mode 100644 index 0000000..f6e6c01 --- /dev/null +++ b/_example/component_design/components.svg @@ -0,0 +1,52 @@ +MainViewPresentersInteractorsEntitiesPermissionsDatabaseControllersAuthorizer \ No newline at end of file diff --git a/_example/component_design/main.go b/_example/component_design/main.go new file mode 100644 index 0000000..f2ba46d --- /dev/null +++ b/_example/component_design/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "os" + + g "github.com/ddddddO/gdag" +) + +func main() { + mainComp := g.DAG("Main") + view := g.Task("View") + controllers := g.Task("Controllers") + presenters := g.Task("Presenters") + interactors := g.Task("Interactors") + authorizer := g.Task("Authorizer") + database := g.Task("Database") + entities := g.Task("Entities") + permissions := g.Task("Permissions") + + mainComp.Con(view).Con(presenters).Con(interactors) + mainComp.Con(interactors).Con(entities) + mainComp.Con(database).Con(interactors) + database.Con(entities).Con(permissions) + mainComp.Con(controllers).Con(interactors).Con(entities) + mainComp.Con(authorizer).Con(interactors) + authorizer.Con(permissions) + + uml, err := mainComp.UML() + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + fmt.Println(uml) +} \ No newline at end of file