Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ふんわり使うPlantUML

 ふんわり使うPlantUML

PlantUML を使って、ふんわりと図を描くはなし。

PHPerKaigi 2023 (2023-03-24)
https://phperkaigi.jp/2023/

Norio Suzuki

March 24, 2023
Tweet

More Decks by Norio Suzuki

Other Decks in Programming

Transcript

  1. !TV[VLJ
    ;ΜΘΓ࢖͏1MBOU6.-
    1)1FS,BJHJ

    View full-size slide

  2. ࿩͢͜ͱ
    w ʮ;ΜΘΓ࢖͏ʯͷఆٛ
    w 1MBOU6.-ͷ࢖͍ํɾֶͼํ
    w Θͨ͠ͷ࢖͍ํ
    w ͓·͚

    View full-size slide

  3. ࿩͞ͳ͍͜ͱ
    w 6.-ͦͷ΋ͷʹ͍ͭͯͷৄࡉ
    w ଞͷπʔϧͱͷൺֱ

    View full-size slide

  4. !TV[VLJ
    IUUQTUXJUUFSDPNTV[VLJ
    IUUQTHJUIVCDPNTV[VLJ
    IUUQTTQFBLFSEFDLDPNTV[VLJ

    View full-size slide

  5. $VSSFOUMZXPSLFEBU3"#0 *OD
    IUUQTSBCPDBU

    View full-size slide

  6. 1MBOU6.-Λʮ;ΜΘΓ࢖͏ʯ

    View full-size slide

  7. w ςΩετͰهड़͠ɺਤΛඳͨ͘Ίͷπʔϧ
    w 6.-Λத৺ͱͨ͠ଟ࠼ͳਤΛαϙʔτ
    w ςΩετϑΝΠϧͳͷͰཤྺ؅ཧָ͕
    1MBOU6.-ͱ͸
    IUUQTQMBOUVNMDPN

    View full-size slide

  8. ౷ҰϞσϦϯάݴޠ
    lΦϒδΣΫτࢦ޲ͷΤοηϯεΛத৺ʹɺ
    ඪ४తͳਤͷॻ͖ํΛܾΊͯɺͭ·Βͳ͍
    ޡղΛආ͚ΔΑ͏ʹͨ͠ͷ͕6.-
    ʢ6OJ
    fi
    FE.PEFMJOH-BOHVBHFʣͰ͢z

    ൈਮ
    ͪΐ͏ͥͭιϑτ΢ΣΞઃܭೖ໳ᴷᴷ
    1)1Ͱཧղ͢ΔΦϒδΣΫτࢦ޲ͷ׆༻
    6.-

    View full-size slide

  9. ͭ·Βͳ͍ޡղͳ͘఻͑Δᶃ
    ਖ਼͍͠จষͰ
    දݱ͢Δ
    ͭ·Βͳ͍ޡղͳ͘఻͑Δ
    👍

    View full-size slide

  10. ͭ·Βͳ͍ޡղͳ͘఻͑Δᶄ
    ਖ਼͍͠จষͱ
    ਖ਼͍͠6.-Ͱ
    දݱ͢Δ
    ਖ਼͍͠จষͰ
    දݱ͢Δ
    ͭ·Βͳ͍ޡղͳ͘఻͑Δ
    ˠ
    👍 💯

    View full-size slide

  11. UML
    *NBHFDSFBUFECZ4UBCMF%J
    ff
    VTJPO0OMJOFIUUQTTUBCMFEJ
    ff
    VTJPOXFCDPN

    View full-size slide

  12. ͭ·Βͳ͍ޡղͳ͘఻͑Δᶅ
    ਖ਼͍͠จষͱ
    ਖ਼͍͠6.-Ͱ
    දݱ͢Δ
    ਖ਼͍͠จষͰ
    දݱ͢Δ
    ਖ਼͍͠จষͱ
    ਤͰ
    දݱ͢Δ
    ͭ·Βͳ͍ޡղͳ͘఻͑Δ
    ˠ
    ˠ
    👍 💯
    🎉

    View full-size slide

  13. ·ͣ͸ਤͱͯ͠ඳ͘

    View full-size slide

  14. 6.-ͱͯ͠ͷਖ਼͠͞͸
    ޙ͔Β෇͍ͯ͘Δ

    View full-size slide

  15. ͜Ε͕ʮ;ΜΘΓ࢖͏ʯ

    View full-size slide

  16. 1MBOU6.-ͷجຊॻࣜ

    View full-size slide

  17. ॻࣜͷجຊ
    @startuml
    ཁૉAͷఆٛ

    ཁૉBͷఆٛ
    ཁૉAͱཁૉBͷؔ࿈
    @enduml

    View full-size slide

  18. γʔέϯεਤ
    @startuml
    participant Alice
    participant Bob
    Alice -> Bob
    @enduml

    View full-size slide

  19. Ϋϥεਤ
    @startuml
    class Alice
    class Bob
    Alice -> Bob
    @enduml

    View full-size slide

  20. Ϣʔεέʔεਤ
    @startuml
    usecase Alice
    usecase Bob
    Alice -> Bob
    @enduml

    View full-size slide

  21. Ϣʔεέʔεਤ
    @startuml
    (Alice) -> (Bob)
    @enduml
    Ϣʔεέʔε͸ؙׅހͰғΜͰ࢖͍·͢
    ؙׅހͷର͸ପԁʹࣅ͍ͯΔ͔ΒͰ͢


    IUUQTQMBOUVNMDPNKBVTFDBTFEJBHSBN

    View full-size slide

  22. ཁૉҎ্ͷؔ࿈ͷॻ͖ํ
    @startuml
    usecase Alice
    usecase Bob
    usecase Carol
    Alice -> Bob -> Carol
    @enduml

    View full-size slide

  23. ཁૉҎ্ͷؔ࿈Ͱ΋ཁૉͣͭॻ͘
    @startuml
    usecase Alice
    usecase Bob
    usecase Carol
    Alice -> Bob
    Bob -> Carol
    @enduml

    View full-size slide

  24. ͜ͷه๏Ҏ֎Ͱ
    ཁૉؒͷؔ࿈Λඳ͘ਤ΋͋Δ
    +40/ͱ͔:".-ͱ͔
    ϚΠϯυϚοϓͱ͔

    View full-size slide

  25. 1MBOU6.-ͰਤΛඳը͢Δ

    View full-size slide

  26. ίϚϯυϥΠϯͰϑΝΠϧΛม׵
    $ java -jar plantuml.jar file.puml -t png
    %PXOMPBEGSPNQMBOUVNMDPN
    PS
    CSFXJOTUBMMQMBOUVNM

    View full-size slide

  27. ެࣜαΠτͷ0OMJOF4FSWFSͰม׵
    0OMJOF4FSWFSϝχϡʔ͔Β࢖͏

    View full-size slide

  28. %PDLFSDPOUBJOFSQMBOUVNMTFSWFS
    $ docker run -d -p 8080:8080 \

    plantuml/plantuml-server
    http://localhost:8080/

    View full-size slide

  29. ςΩετΤσΟλ΍*%&ͱͷ࿈ܞ
    ࿈ܞํ๏͸KBSϑΝΠϧͩͬͨΓ
    0OMJOF4FSWFSʢ"1*4FSWFSʣͩ
    ͬͨΓ
    ΤσΟλ࿈ܞ
    https://plantuml.com/ja/running

    View full-size slide

  30. 8FCαʔϏεΛ࢖͏
    w 1MBOU6.-ରԠͷ8FCαʔϏεͷྫ
    w )BDL.% IUUQTIBDLNEJP

    w FTB IUUQTFTBJP

    View full-size slide

  31. ʲ஫ҙʳ
    ଞਓ͕؅ཧ͍ͯ͠Δ0OMJOF4FSWFSʹ͸
    ൿີ৘ใΛهࡌ͠ͳ͍

    View full-size slide

  32. QBUIΛσίʔυ͢Δͱɺ
    ݩͷίʔυʹͳΔ

    View full-size slide

  33. ࠓ೔͜͜ͰαϯϓϧΛࢼ͚ͩ͢ͳΒ
    )BDL.%͕͓ख͔ܰ΋
    ηοτΞοϓෆཁ

    ϑϦʔϓϥϯ͋Γ

    View full-size slide

  34. Θͨ͠ͷར༻๏

    View full-size slide

  35. Θͨ͠ͷར༻๏
    w ઃܭϑΣʔζͰͷ಄ͷ੔ཧ
    w ։ൃ࣌ͷιʔείʔυɾϦʔσΟϯά
    w ӡ༻υΩϡϝϯτͰͷิ଍આ໌

    View full-size slide

  36. ઃܭϑΣʔζͰͷ࢖͍ํ
    w ΞʔΩςΫνϟͷ੔ཧ
    w σʔλߏ଄ͷ੔ཧ
    w γʔέϯεਤ͔Βڞ௨ॲཧΛ୳Δ
    w ίʔυΛॻ͍͔ͯΒؾ෇͘ͱख໭Γ͕ൃੜ͢Δ৔߹͕͋Δ

    View full-size slide

  37. ΞʔΩςΫνϟਤͷྫᶃ
    @startuml
    (User) -> (API)
    (API) -> (DB)
    ' Queue
    (API) --> (Queue)
    (Queue) <-- (Subscriber)
    (Subscriber) -> (MTA)
    @enduml

    View full-size slide

  38. ΞʔΩςΫνϟਤͷྫᶄ
    @startuml
    actor User
    queue Queue
    database DB
    (User) -> (API): POST /register
    (API) -> (DB): Save
    ' Queue
    (API) --> (Queue): Publish Message
    (Queue) <-- (Subscriber): Subscribe Message
    (Subscriber) -> (MTA): Email
    @enduml

    View full-size slide

  39. ΞʔΩςΫνϟਤͷྫᶅ
    @startuml
    !include
    !include
    !include
    !include
    !include
    !include
    Users(User, "User", "tech")
    Aurora(DB, "DB", "tech")
    SimpleQueueService("Queue", "Queue", "tech")
    SimpleEmailService("MTA", "MTA", "tech")
    (User) -> (API): POST /register
    (API) -> (DB): Save
    ' Queue
    (API) --> (Queue): Publish Message
    (Queue) <-- (Subscriber): Subscribe Message
    (Subscriber) -> (MTA): Email
    @enduml

    View full-size slide

  40. γʔέϯεਤͷྫᶃ
    @startuml
    User -> API: POST /save
    API -> API: Create Message
    API -> Queue: Publish Message
    API <-- Queue: OK
    User <-- API: OK
    == Subscriber Process ==
    Queue <- Subscriber: Fetch Message
    Queue --> Subscriber: Message
    Subscriber -> DB: Save
    Subscriber <-- DB: OK
    @enduml

    View full-size slide

  41. ;ΜΘΓ࢖͏ͱ͖ͷϙΠϯτ
    w ਤ͸ͻͱͭ͡Όͳͯ͘΋ྑ͍
    w ཻ౓Λม͑ͨෳ਺ͷਤ
    w શମ֓ཁͱॲཧৄࡉ
    w ʮԿ΋͔΋ਖ਼֬ʹඳ͔ͳΕ͹ʂʯΈ͍ͨͳ࢖໋ײ͸๨ΕΔ
    w ͍͕ͭΜ͹Γͨ͘ͳΔ͕ɺ͕Μ͹Βͳ͍

    View full-size slide

  42. ιʔείʔυɾϦʔσΟϯάͰͷར༻
    w ʮ೺Ѳ͖͠Ε͍ͯͳ͍ػೳͷमਖ਼ʯͳͲͷͱ͖ʹ࢖͏
    w ΤσΟλͷػೳͰॲཧͷࢀরݩΛ௥͍ͬͯ͘
    w ϝιου୯ҐͳͲͰϓϩοτ͠ɺؔ࿈෇͚͍ͯ͘
    w Ͳͷ෦෼ʹमਖ਼ΛՃ͑Δͷ͕Ұ൪εδ͕ྑͦ͞͏͔Λ୳Δ

    View full-size slide

  43. ιʔείʔυɾϦʔσΟϯάͷྫ
    @startuml
    skinparam usecase<> {
    backgroundColor #fcc
    }
    skinparam usecase<> {
    backgroundColor #cfc
    }
    ' command ܥ
    rectangle "terminate Command" as terminateCommand
    usecase "TerminationService::exec()" as terminateService
    ' admin ܥ
    rectangle "POST /admin/delete API" as adminDeleteApi
    usecase "Admin\DeleteService::delete()" as adminDeleteService
    ' ࡟আຊମ
    usecase "Deprecated\DeleteService::delete()" as deleteServiceDeprecated <>
    usecase "DeleteService::delete()" as deleteService <>
    usecase "෇Ճ৘ใͷ࡟আॲཧ" as deleteInfo <>
    ' unregister ܥ
    rectangle "POST /unregister API" as unregisterApi
    usecase "UnregisterService::unregister()" as unregisterService
    ' command ܥ
    (terminateCommand) --> (terminateService)
    (terminateService) --> (deleteServiceDeprecated)
    ' admin ܥ
    (adminDeleteApi) --> (adminDeleteService)
    (adminDeleteService) --> (deleteServiceDeprecated)
    (deleteServiceDeprecated) --> (deleteService)
    ' unregister ܥ
    (unregisterApi) ---> (unregisterService)
    (unregisterService) --> (deleteService)
    ' RENEW
    (deleteService) --> (deleteInfo)
    @enduml

    View full-size slide

  44. ;ΜΘΓ࢖͏ͱ͖ͷϙΠϯτ
    w શ෦Λඳ͜͏ͱ͕Μ͹Βͳ͍
    w ඳ͘ͷ͕໨తͰ͸ͳ͘ɺඳ͍ͨ݁ՌͰॲཧΛ೺Ѳ͢Δͷ͕໨త
    w ඞཁͳՕॴ͸QSJWBUFϝιουͷॲཧͰ΋ϓϩοτ͢Δ
    w ࣗ෼Ͱ೺Ѳ͠΍͚͢Ε͹ɺଟগཻ౓͕ϒϨͯ΋ؾʹ͠ͳ͍

    View full-size slide

  45. 1MBOU6.-ͷֶͼํ

    View full-size slide

  46. w ඳ͚Δਤͷ಺༰͕໢ཏ͞Ε͍ͯΔ
    w ߏ଄ཱ͕ମతͰͪΐͬͱ௥͍ʹ͍͘
    w ʢ޿ࠂαΠζ΋ͪΐͬͱେ͖Ίʣ
    ඞཁͳ৘ใ͸ެࣜαΠτʹ͋Δ
    IUUQTQMBOUVNMDPN

    View full-size slide

  47. ެࣜαΠτͷ௥͍ํ
    IUUQTQMBOUVNMDPN
    ਤ͝ͱͷϦϯΫ

    ʢ⾢ͰεΫϩʔϧʣ
    ֤ϖʔδ

    ڞ௨ϝχϡʔ
    ݴޠ੾ସ
    ϖʔδ֊૚ߏ଄
    ೥݄ݱࡏ

    View full-size slide

  48. ϦϑΝϨϯεΨΠυʢ1%'ΨΠυʣ
    IUUQTQMBOUVNMDPNKBHVJEF

    View full-size slide

  49. ϦϑΝϨϯεΨΠυͷΦεεϝϙΠϯτ
    IUUQTQMBOUVNMDPNKBHVJEF
    w ͦΕͧΕͷਤ͝ͱʹষཱͯ
    w ॻ͖͍ͨਤͷ৘ใΛ௥͍΍͍͢
    w ʢ޿ࠂ͕ͳ͍ʣ

    View full-size slide

  50. w (JU)VC4QPOTPST
    w 1BUSFPO
    w -JCFSBQBZ
    w 1BZ1BM
    1MBOU6.-͕༗༻ͩͱࢥͬͨΒεϙϯαʔʹ
    IUUQTQMBOUVNMDPNKB

    View full-size slide

  51. εϙϯαʔಛయͱͯ͠BEGSFF൛ͷ
    XFCTJUFΛ࢖͑Δ
    εϙϯαʔಛయ
    IUUQTQMBOUVNMDPNQBUSFPOKB

    View full-size slide

  52. ਤΛ;Θͬͱඳ͜͏

    View full-size slide

  53. ;Θͬͱ͍ͯͯ͠΋
    ޡղͳ͘఻ΘΔ֬཰͸্͕Δ

    View full-size slide

  54. ਖ਼֬͞͸ޙ͔Β෇͍ͯ͘Δ

    View full-size slide

  55. ཁૉͷϨΠΞ΢τௐ੔
    w ϨΠΞ΢τ͸1MBOU6.-ʹ೚ͤΔͷ͕جຊ
    w ϨΠΞ΢τΛ׬ᘳʹ੔͍͑ͨͳΒผͷπʔϧΛ࢖ͬͨ΄͏͕͍͍
    w ͋Δఔ౓ͷௐ੔͸ޮ͘
    w ϥΠϯͷ௕͞
    w ໼ҹͷํ޲Λௐ੔
    w άϧʔϐϯά
    w ఆٛॱ

    View full-size slide

  56. ϥΠϯͷ௕͞
    @startuml
    (A) - (B)
    (A) -- (C)
    (A) --- (D)
    (A) ---- (E)
    @enduml

    View full-size slide

  57. ໼ҹͷํ޲Λௐ੔
    @startuml
    (A) -r-> (B)
    (A) -d-> (C)
    (A) -l-> (D)
    (A) -u-> (E)
    @enduml SJHIUMFGU
    EPXOVQ

    View full-size slide

  58. άϧʔϐϯά
    @startuml
    rectangle Group {
    (B)
    (C)
    }
    (A) -> (B)
    (A) -> (C)
    @enduml

    View full-size slide

  59. άϧʔϐϯάͱIJEEFOϥΠϯ
    @startuml
    rectangle Group {
    (B)
    (C)
    (B) -d[hidden]- (C)
    }
    (A) -> (B)
    (A) -> (C)
    @enduml
    E͸EPXOͷ͜ͱ
    ଞͷํ޲ࢦఆ΋Ͱ͖Δ

    View full-size slide

  60. ཁૉͷఆٛॱ
    @startuml
    (A) -> (B)
    @enduml
    @startuml
    (B) <- (A)
    @enduml

    View full-size slide

  61. ݟͨ໨ͷมߋ
    w ςʔϚʢUIFNFʣΛ࢖͏
    w ϥΠϒϥϦΛ࢖͏
    w TLJOQBSBNΛ࢖͏

    View full-size slide

  62. ςʔϚʢTQBDFMBCʣ
    @startuml
    !theme spacelab
    (A) -- (B)
    (A) -- (C)
    @enduml
    ૊ΈࠐΈͷςʔϚͷҰཡ͸

    IUUQTQMBOUVNMDPNKBUIFNF

    View full-size slide

  63. ϥΠϒϥϦΛ࢖͏
    @startuml
    !include
    !include
    !include
    !include
    !include
    Users(A, "A", "tech")
    DynamoDB(B, "B", "tech")
    Aurora(C, "C", "tech")
    (A) -- (B)
    (A) -- (C)
    @enduml
    ૊ΈࠐΈͷϥΠϒϥϦͷҰཡ͸

    IUUQTQMBOUVNMDPNKBTUEMJC

    View full-size slide

  64. ৭Λม͑ͯݟ΍͘͢͢Δ
    @startuml
    skinparam usecase {
    backgroundColor #fcc
    }
    (A) -- (B)
    (A) -- (C)
    @enduml
    શͯͷVTFDBTF͕ର৅

    View full-size slide

  65. ৭Λม͑ͯݟ΍͘͢͢ΔʢಛఆͷཁૉͷΈʣ
    @startuml
    skinparam usecase<> {
    backgroundColor #fcc
    }
    usecase A <>
    (A) -- (B)
    (A) -- (C)
    @enduml
    41&$*"-ͷϥϕϧ͕෇͍ͨ
    VTFDBTFͷΈ͕ର৅

    View full-size slide

  66. TLJOQBSBNͷݕࡧ
    IUUQTQMBOUVNMEPDVNFOUBUJPOSFBEUIFEPDTJPFOMBUFTUGPSNBUUJOHBMMTLJOQBSBNTIUNM
    "TIMFZT1MBOU6.-%PD
    ࢦఆՄೳͳTLJOQBSBNΛݕࡧ

    View full-size slide

  67. 3FGFSFODFT
    w 1MBOU6.-
    w IUUQTQMBOUVNMDPN
    w "TIMFZT1MBOU6.-%PD
    w IUUQTQMBOUVNMEPDVNFOUBUJPOSFBEUIFEPDTJPFOMBUFTU
    GPSNBUUJOHBMMTLJOQBSBNTIUNM
    w ͪΐ͏ͥͭιϑτ΢ΣΞઃܭೖ໳
    w IUUQTHJIZPKQCPPL

    View full-size slide

  68. 3FGFSFODFT
    w 4UBCMF%J
    ff
    VTJPO0OMJOF
    w IUUQTTUBCMFEJ
    ff
    VTJPOXFCDPN
    w "NBOJTMPPLJOHVQBUBIJHIXBMM5IFXBMMJTNBEFPGCSJDLT5IF
    XBMMJTNFUFSTIJHI

    View full-size slide