{"id":2725,"date":"2018-05-12T21:09:32","date_gmt":"2018-05-12T12:09:32","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=2725"},"modified":"2023-05-27T20:32:56","modified_gmt":"2023-05-27T11:32:56","slug":"%e3%80%90gof%e3%81%ae%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%80%91%e3%80%8cbrige%e3%80%8d%e3%81%a3%e3%81%a6%e3%81%a9%e3%82%93%e3%81%aa%e3%83%91%e3%82%bf%e3%83%bc","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=2725","title":{"rendered":"\u3010GoF\u306e\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011\u300cDecorator(\u30c7\u30b3\u30ec\u30fc\u30bf)\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f"},"content":{"rendered":"<h2>\u300cDecorator(\u30c7\u30b3\u30ec\u30fc\u30bf)\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u65e2\u5b58\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u5909\u66f4\u305b\u305a\u306b\u3001\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408<\/strong><\/span>\u306b\u4f7f\u3048\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n<h2>\u30e1\u30ea\u30c3\u30c8<\/h2>\n<p>\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3059\u308b\u3088\u308a\u3082\u3001\u81ea\u7531\u5ea6\u304c\u9ad8\u3044\u65b9\u6cd5\u3067\u3001\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u3069\u306e\u3088\u3046\u306b\u30af\u30e9\u30b9\u8a2d\u8a08\u3059\u308c\u3070\u3044\u3044\u306e\u304b\uff1f<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u3042\u308b\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u306e\u6a5f\u80fd\u62e1\u5f35\u306e\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u300c\u30c7\u30b3\u30ec\u30fc\u30bf\u30af\u30e9\u30b9\u300d<\/strong><\/span>\u3068\u3044\u3046\u306e\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<p>\u300c\u30c7\u30b3\u30ec\u30fc\u30bf\u30af\u30e9\u30b9\u300d\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u6a5f\u80fd\u3092\u62e1\u5f35\u3057\u305f\u3044\u30b5\u30d6\u30af\u30e9\u30b9\u3092\u3001\u8981\u7d20\u3068\u3057\u3066\u6301\u3061\u3001\u3055\u3089\u306b\u305d\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u62e1\u5f35\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u3082\u6301\u305f\u305b\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h3>Adapter\u30d1\u30bf\u30fc\u30f3\u3068\u306e\u9055\u3044<\/h3>\n<p>Adapter\u30d1\u30bf\u30fc\u30f3\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u3042\u304f\u307e\u3067\u4ed6\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3082\u3042\u308b\u7279\u5b9a\u306e\u6a5f\u80fd\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u4ef2\u4ecb\u3059\u308b\u5f79\u5272<\/strong><\/span>\u3067\u3042\u308a\u3001\u6a5f\u80fd\u62e1\u5f35\u306f\u3057\u306a\u3044\u3067\u3059\u3002<\/p>\n<p>\u305d\u308c\u306b\u5bfe\u3057\u3066\u3001Decorator\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u6a5f\u80fd\u62e1\u5f35\u305d\u306e\u3082\u306e\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>Adapter\u30d1\u30bf\u30fc\u30f3\u306b\u3064\u3044\u3066\u306f\u3001\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u3082\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3054\u89a7\u4e0b\u3055\u3044\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"OsgLYnQDwr\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=2708\">\u3010GoF\u306e\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011\u300cAdapter\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f\u3001\u8a2d\u8a08\u306a\u3069<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=2708&#038;embed=true#?secret=OsgLYnQDwr\" data-secret=\"OsgLYnQDwr\" width=\"500\" height=\"282\" title=\"&#8220;\u3010GoF\u306e\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011\u300cAdapter\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f\u3001\u8a2d\u8a08\u306a\u3069&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<h2>\u5b9f\u969b\u306b\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3002<\/h2>\n<p>\u5b9f\u88c5\u30a4\u30e1\u30fc\u30b8\u306f\u3001\u30af\u30e9\u30b9\u56f3\u306b\u3059\u308b\u3068\u4e0b\u8a18\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2730\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/Decorator_\u30af\u30e9\u30b9\u56f3.png\" alt=\"\" width=\"655\" height=\"307\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/Decorator_\u30af\u30e9\u30b9\u56f3.png 655w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/Decorator_\u30af\u30e9\u30b9\u56f3-300x141.png 300w\" sizes=\"(max-width: 655px) 100vw, 655px\" \/><\/p>\n<h3>Main.java(\u5229\u7528\u3059\u308b\u30af\u30e9\u30b9\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package Decorator;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void main(String args[]) {\r\n\r\n\t\t\/\/\u88c5\u98fe\u524d\r\n\t\tTanakaImpl tanaka = new TanakaImpl();\r\n\t\tSystem.out.println(tanaka.getName());\r\n\r\n\t\t\/\/\u88c5\u98fe\u5f8c\r\n\t\tBirthDayDecorator bdd = new BirthDayDecorator(tanaka);\r\n\t\tSystem.out.println(bdd.getName());\r\n\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>Employee.java(\u793e\u54e1\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package Decorator;\r\n\r\npublic interface Employee {\r\n\r\n\tString getName();\r\n\r\n}\r\n<\/pre>\n<p>\u30c7\u30b3\u30ec\u30fc\u30b7\u30e7\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u3046\u3068\u3001<span style=\"color: #ff0000;\"><strong>\u3053\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306e\u5185\u5bb9\u3092\u5909\u3048\u306a\u304f\u3066\u3082\u3001\u51e6\u7406\u3092\u5909\u3048\u3089\u308c\u308b\u3068\u3044\u3046\u306e\u304c\u3053\u306e\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306e\u809d<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>TanakaImpl.java(\u7530\u4e2d\u3068\u3044\u3046\u793e\u54e1\u306e\u5b9f\u88c5\u30af\u30e9\u30b9\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package Decorator;\r\n\r\npublic class TanakaImpl implements Employee{\r\n\r\n\tpublic String getName() {\r\n\t\treturn \"\u7530\u4e2d\u592a\u90ce\";\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>BirthDayDecorator.java(\u793e\u54e1\u540d\u3092\u30c7\u30b3\u30ec\u30fc\u30b7\u30e7\u30f3\u3059\u308b\u30af\u30e9\u30b9\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package Decorator;\r\n\r\npublic class BirthDayDecorator implements Employee {\r\n\r\n\tEmployee taisho;\r\n\r\n\tBirthDayDecorator(Employee taisho){\r\n\t\tthis.taisho = taisho;\r\n\t}\r\n\r\n\tpublic String getName() {\r\n\r\n\t\t\/\/\u540d\u524d\u3092\u88c5\u98fe\u3059\u308b\u3002\r\n\t\tString name = this.taisho.getName();\r\n\t\tname += \"\u3055\u3093\u3002(*\u2267\u2200\u2266)\u03c6\u2026\u8a95\u751f\u65e5\u304a\u3081\u3067\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u266a\";\r\n\t\treturn name;\r\n\t}\r\n\r\n}<\/pre>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2732\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u30c7\u30b3\u30ec\u30fc\u30b7\u30e7\u30f3_\u5b9f\u884c\u7d50\u679c.png\" alt=\"\" width=\"363\" height=\"109\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u30c7\u30b3\u30ec\u30fc\u30b7\u30e7\u30f3_\u5b9f\u884c\u7d50\u679c.png 363w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u30c7\u30b3\u30ec\u30fc\u30b7\u30e7\u30f3_\u5b9f\u884c\u7d50\u679c-300x90.png 300w\" sizes=\"(max-width: 363px) 100vw, 363px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"\u300cDecorator(\u30c7\u30b3\u30ec\u30fc\u30bf)\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f \u65e2\u5b58\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u5909\u66f4\u305b\u305a\u306b\u3001\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306b\u4f7f\u3048\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002 \u30e1\u30ea\u30c3\u30c8 \u30af\u30e9\u30b9\u3092\u7d99\u627f\u3059\u308b\u3088\u308a\u3082\u3001\u81ea\u7531\u5ea6\u304c\u9ad8\u3044\u65b9\u6cd5\u3067\u3001\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067 [&hellip;]","protected":false},"author":1,"featured_media":2737,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,29,21],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2725"}],"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=2725"}],"version-history":[{"count":10,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2725\/revisions"}],"predecessor-version":[{"id":20225,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2725\/revisions\/20225"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/2737"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2725"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}