nakajima jun
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    セキュア・バイ・デザイン 第7章 状態の複雑さの軽減 === ###### tags: `セキュア・バイ・デザイン読書会` # Discord開始位置 - # 自己紹介 - なかじま(J.Nakajima) - ファシリ役 - タイムキーパー役 - こばやし(t2_Kobayashi) - 読み上げ役 # 参加の仕方 - マイクはいつでもONにして、話に参加して結構です。 - テキストチャットでも、コメントやリアクションでどんどん参加してください!ラジオ担当が拾っていきます。 - 聞いているだけの方もOKです! # ディスカッションをより豊かにするためのグランドルール - 参加者は毎回任意 - 今回は不参加、次回は参加をするといった気軽な感じ - 途中参加も断然OK! まずは聞くだけでも大丈夫です! - フィードバックを恐れない - マサカリは怖いと思いますが、アウトプットからのフィードバックを受け、学びを深めていきましょう - アウトプット7割:インプット3割の気持ちで臨みましょう! - 経験の有る無しは気にしない - 自分はDDD非経験者だから……と気後れする必要はないです - 堂々と意見や疑問を語りましょう - ページ数と同時に、節のタイトルやキーワードを言って頂けるとスムーズです - 電子書籍で読んでいるとページ数ではわからないため - 話していない人が、率先してメモしましょう - このHackMDはみんなのものです。どんどん書いていきましょう:+1: :+1: - 気になる質問や同感するものには :+1: を末尾につけてください。 # タイムテーブル | 時間 | 所要時間 | 内容 |備考 | | -------- | -------- | -------- | -------- | | 19:50- | - | 集合開始 | | | 20:00-20:15 | 15分 | 当日の流れとグランドルールの共有 | | | 20:15-20:25 | 10分 | 感想記入&HackMDに書かれた皆さんの感想・気づき・疑問をもっと掘り下げたいものを、 :+1: 付けていく | | | 20:25-21:55 | 90分 | 本の節ごとにディスカッション(ここでも適宜、HackMDに気づきとか書いていってもらっていいです) | | |21:55-22:00 | 5分 | 次回開催日と読む範囲決めてクローズ | | ## 下に感想などを書いていって下さい。どんな些細なことでもOKです。 --- # 用語でわからないところ - 例:集約がわからん # 第7章 序章 ## 目安の時間 - 18分 ## 感想・気づき - > p.246 Note: エンティティを設計する際に気をつけないといけないのが、そのエンティティが使われる環境です。その理由は、そのエンティティが単一スレッドの環境で使われるのか、それとも、複数スレッドの環境で使われるかに寄って、エンティティの実装が大きく変わることになるからです。 - 基本的に不変にすれば良いと思っていたから、あまり考えてなかった :+1::+1::+1: - [discord](https://discord.com/channels/432531367427964929/911610565103845387/974996127638257684) - > 不変オブジェクトにすると、状態を引き回す必要が生じたときに大分面倒くさくなるので、「単一スレッドからしか触らないなら、可変でも良い」という選択肢は有ったほうが吉、という感覚 - > 組み込みとか低レイヤだと、めっちゃ気にします。エンティティだからというか、なんに付けても常に気にしている状態ですが。 - > p.247 このような残高の結果になった理由は、2つのスレッドが同期を取って順番に処理を実行するようにはなっておあらず、同時に処理できるようになっていたことにあります。 ## 疑問 --- # 7.1 部分的不変エンティティ(partially immutable entity) ## 目安の時間 - 18分 ## 感想・気づき - > p.248 そもそも、エンティティは状態の変化を扱うものとして設計されるものなのですが、そうであったとしても、エンティティの中で「この部分は可変にする必要があるのか?」ということを考えることが重要だと本書では考えています - これには同意。全部が全部、可変である必要はないと思っている。 ## 疑問 --- # 7.2 状態オブジェクト(state object) ## 目安の時間 - 18分 ## 感想・気づき - > p.253 しかしながら、実際の開発に置いて、開発者はエンティティを単なる構造体(privateなデータ・フィールドとそれに伴うGatter/Setterメソッドを持ったクラス)として見てしまう傾向があります。 - これはすごくよくわかる:+1::+1: - > p.253 この把握することの難しさはテストの難しさにも繋がります。 - 依存関係が少ないほうが良い:+1: - 状態オブジェクト(State object)はとてもわかりやすい。PersonにisMarriedって持たせると、可変オブジェクトとして扱わないといけないけど、MaritalStatusという状態オブジェクトとして作っておけば、Person側からは参照を不変オブジェクトとして持っておけば良い。可変な箇所を局所化かつ、意味のあるものとして纏めておける ## 疑問 - > p260 それでは、この状態オブジェクトをどのようにエンティティに組み込むのか見てみましょう - リスト7.9のPersonクラスで状態のテストをどこまで行うべきかどうか気になる - MaritalStatus#dateでは「結婚していない場合」、「結婚している場合」、「離婚した場合」の3パターンの条件分岐があるが、Person#dateのテストを書く時はどの状態でテストを行うと良いのか - Person#dateから見るとMaritalStatus#dateの結果はvoid, 例外の2パターンだから、そこだけテストすれば十分か - [discord](https://discord.com/channels/432531367427964929/911610565103845387/975001657115021342) - 各メソッドで if 文などで判定していた処理を状態オブジェクトというヘルパーに移動したけど、そのヘルパーを呼び出すルールは忘れないでね、ということなんでしょうか?:+1::+1::+1::+1: - [discord](https://discord.com/channels/432531367427964929/911610565103845387/974998513559695360) --- # 7.3 エンティティ・スナップショット(entity snapshot) ## 目安の時間 - 18分 ## 感想・気づき - > p.261 データベースにデータを取得するまでの往復の時間はシステムがクライアントにレスポンスを返すまでの時間を遅くしてしまうからです - 一般的にI/Oは計算時間より遅くなりがち :+1: - > p.261 複数のスレッドからアクセスされるようになっても、エンティティを正しく機能させる、ということです - セキュリティの完全性の話 - > p.266 有名なのがGreg Young氏が提唱するコマンド・クエリ責務分離(Command Query Responsibility Segregation: CQRS)のパターンやMartin Thompson氏が提唱する単一書き込み原則(Single Writer Principle)などがそれに当たり、両方とも同じようなことを唱えています。 - CQRSは知っていたけど、単一書き込み原則は初めて聞いた :+1: :+1::+1::+1::+1: - 変更ができること自体が完全性を損なう可能性があるということは、たしかに納得いく話だなと思った - ただエンティティの状態を変更するのがエンティティ自身ではなくて、ドメインサービスなどに逃されるのは、ちょっと気になる。(本書でも言及はされているけど) :+1: - たとえば、addOrderItemメソッドもエンティティに実装しておいて、新しい不変なエンティティを生成するでも良いのでは。 ## 疑問 - データベースが変更されたら、そのタイミングでスナップショットのインスタンスを作り直すのでしょうか? - 例えばリスト7.11のOrderService#addOrderItemメソッドが呼ばれたら、そのタイミングでOrderSnapShotのインスタンスを生成し直す感じでしょうか?(具体的な実装方法が知りたいです) :+1::+1::+1::+1::+1::+1::+1::+1: - [discord](https://discord.com/channels/432531367427964929/911610565103845387/975006397920055326) --- # 7.4 エンティティ・リレー(entity relay) ## 目安の時間 - 18分 ## 感想・気づき - エンティティリレーの導入の動機は、エンティティが管理する状態遷移の数が多くなるのを分割して、管理しやすくすること - p.271の婚姻ステータスの例だと、生きているか亡くなったか。結婚しているか独身か、というのは1つのステータスではなくて、2種類のステータスに分けられそうな気がしている - pp.272-273 私たち著者の経験から言えば、エンティティで扱う状態が5個までなら管理可能で、10個までならなんとか管理できるレベルだと考えています - 5個でも体感多い気はしている - この個数は、独身→結婚→離婚 という1ステータスの中の状態遷移の数のことか - pp.278-279 エンティティ・リレーのシンプルさは、次のエンティティが生成されるときの状態が遷移前のエンティティの中で1つに決められていることから来ています。しかしながら、もし、生成される次のエンティティが複数あるのであれば、再びモデリングし直すことを考えたほうがよいでしょう。きっと、対象のフェーズを終わらせる状態がどこかにあり、その状態をエンティティに追加できるはずです。もし、それができないのであれば、複数のフェーズを1つのフェーズとして見ているのかもしれません。 - これは常に考えていきたい。もしかしたらドメイン的に関心のない状態まで含まれていたりとかするかもしれない。:+1: - 特に、p.279にある、4つの箇条書きは意識したい :+1::+1: :+1: :+1::+1::+1: ## 疑問 - エンティティ・リレーを実際に現場でやっていらっしゃる人はいますか? どんな風に実装していますか? :+1::+1::+1::+1::+1::+1::+1::+1: ---

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully