{"id":14387,"date":"2021-09-19T13:04:09","date_gmt":"2021-09-19T04:04:09","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=14387"},"modified":"2023-04-30T08:29:09","modified_gmt":"2023-04-29T23:29:09","slug":"%e3%80%90ddd%e3%80%91%e3%80%8c%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%82%aa%e3%83%96%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%80%8d%e3%82%92%e4%bd%9c%e3%82%8b%e3%80%82","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=14387","title":{"rendered":"\u3010DDD\u3011\u300c\u30b3\u30de\u30f3\u30c9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u300d\u3092\u4f5c\u308b\u3002"},"content":{"rendered":"<h2>\u30b3\u30de\u30f3\u30c9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u306f\uff1f<\/h2>\n<p>\u300c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\u300d\u306e\u51e6\u7406\uff08\u767b\u9332\u51e6\u7406\u3084\u66f4\u65b0\u51e6\u7406\uff09\u3092\u547c\u3076\u969b\u306b\u3001\u4eca\u5f8c\u306e\u5909\u66f4\u3067\u3044\u3061\u3044\u3061\u30b7\u30b0\u30cd\u30c1\u30e3\u304c\u5909\u308f\u3063\u3066\u3057\u307e\u3046\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\u300d\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u30b7\u30b0\u30cd\u30c1\u30e3\u304c\u5897\u3048\u308b\u305f\u3073\u306b\u3044\u3061\u3044\u3061\u30e1\u30bd\u30c3\u30c9\u3092\u66f8\u304d\u63db\u3048\u306a\u304f\u3066\u3082\u826f\u3044\u3088\u3046\u306b\u3001\u30b7\u30b0\u30cd\u30c1\u30e3\u3092\u7ba1\u7406\u3059\u308b\u305f\u3081\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3059\u3002<\/p>\n<p>\u8fd1\u5e74\u306e\u958b\u767a\u3067\u306f\u30b3\u30fc\u30c9\u30c1\u30a7\u30c3\u30af\u30c4\u30fc\u30eb\u306e\u30ea\u30f3\u30bf\u30fc\u306a\u3069\u3092\u4f7f\u3063\u3066\u958b\u767a\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u300c\u30b7\u30b0\u30cd\u30c1\u30e3\u306e\u6570\u304c\u591a\u3059\u304e\u306a\u3044\u304b\u300d\u3084\u300c\u30e1\u30bd\u30c3\u30c9\u306e\u884c\u6570\u304c\u9577\u3059\u304e\u306a\u3044\u304b\u300d\u3082\u30c1\u30a7\u30c3\u30af\u306b\u5165\u3063\u3066\u3044\u308b\u30ea\u30f3\u30bf\u30fc\u3082\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u5bfe\u7b56\u306b\u3082\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u5b9f\u88c5<\/h2>\n<p>\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u51e6\u7406(UserApplicationService\u30af\u30e9\u30b9\u306eRegister\u30e1\u30bd\u30c3\u30c9)\u3067\u3042\u308c\u3070\u3001\u300cUserRegisterCommand\u300d\u3068\u3044\u3046\u540d\u524d\u3092\u3068\u308a\u3001\u30e1\u30f3\u30d0\u306b\u306f\u30e6\u30fc\u30b6\u30fc\u540d\u306a\u3069\u3092\u53d6\u308a\u307e\u3059\u3002<\/p>\n<h3>\u30b3\u30de\u30f3\u30c9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h3>\n<pre class=\"lang:default decode:true\">class UserRegisterCommand {\r\n  \u30e6\u30fc\u30b6\u30fcid;\r\n  \u30e6\u30fc\u30b6\u30fc\u540d;\r\n  \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9;\r\n}<\/pre>\n<h3>\u4f7f\u3046\u5074<\/h3>\n<pre class=\"lang:default decode:true\">class UserApplicationService { \r\n\u3000\u3000\u3000\u3000IUserRepository userRepository; \r\n  public void Register(UserRegisterCommand command) {\r\n    if (command.\u30e6\u30fc\u30b6\u30fc\u540d === null) {\r\n      throw new Exception(\"\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\")\r\n    }\r\n    if (command.\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9=== null) { \r\n      throw new Exception(\"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\") \r\n    }\r\n    var user = new User(command.\u30e6\u30fc\u30b6\u30fc\u540d,command.\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9)\r\n    userRepository.Save(user);\r\n  }\r\n}<\/pre>\n<p>\u4eca\u5f8c\u30e6\u30fc\u30b6\u30fc\u306b\u9805\u76ee\u304c\u5897\u3048\u305f\u5834\u5408\uff08\u4f8b\u3048\u3070\u3001\u5e74\u9f62\u304c\u5897\u3048\u305f\u5834\u5408\uff09\u306a\u3069\u3067\u3082\u30b3\u30de\u30f3\u30c9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u8ffd\u52a0\u3059\u6d41\u3060\u3051\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\u5074\u306e\u30b7\u30b0\u30cd\u30c1\u30e3\u3092\u3044\u3061\u3044\u3061\u3044\u3058\u308b\u5fc5\u8981\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u6ce8\u610f\u70b9<\/h2>\n<p>\u3042\u304f\u307e\u3067\u7279\u5b9a\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u969b\u306e\u30b7\u30b0\u30cd\u30c1\u30e3\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u3044\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u300c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\u300d\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u306e\u305f\u3081\u306b\u4f7f\u3046\u3082\u306e\u3067\u306f\u306a\u3044\u306e\u3067\u6ce8\u610f\u3066\u3067\u3059\u3002\uff08\u305d\u306e\u5f79\u5272\u306fDI\u3084DI\u30b3\u30f3\u30c6\u30ca\u3068\u304b\u306b\u306a\u308a\u307e\u3059\u3002\uff09<\/strong><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"\u30b3\u30de\u30f3\u30c9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u306f\uff1f \u300c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\u300d\u306e\u51e6\u7406\uff08\u767b\u9332\u51e6\u7406\u3084\u66f4\u65b0\u51e6\u7406\uff09\u3092\u547c\u3076\u969b\u306b\u3001\u4eca\u5f8c\u306e\u5909\u66f4\u3067\u3044\u3061\u3044\u3061\u30b7\u30b0\u30cd\u30c1\u30e3\u304c\u5909\u308f\u3063\u3066\u3057\u307e\u3046\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002 \u300c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\u300d\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u30b7\u30b0\u30cd\u30c1\u30e3\u304c\u5897\u3048\u308b [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[129],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/14387"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14387"}],"version-history":[{"count":4,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/14387\/revisions"}],"predecessor-version":[{"id":19334,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/14387\/revisions\/19334"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14387"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}