Skip to content

Commit

Permalink
add sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddddO committed Oct 16, 2022
1 parent a481ff2 commit d776b20
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Easily manage 🕸DAG🕷 with Go.<br>
DAG is an acronym for Directed Acyclic Graph.<br>
Output is in PlantUML or Mermaid format.<br>
Useful for progressing tasks.
Useful for progressing tasks, designing components, etc...

⚠It is incompatible with v0.2.0 and earlier versions⚠

Expand Down Expand Up @@ -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)
8 changes: 8 additions & 0 deletions _example/component_design/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# コンポーネントの依存関係
- 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」P131 図14-4

![image](components.svg)

```console
go run main.go > components.pu
```
27 changes: 27 additions & 0 deletions _example/component_design/components.pu
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions _example/component_design/components.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions _example/component_design/main.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit d776b20

Please sign in to comment.