{"id":2775,"date":"2018-05-13T14:30:11","date_gmt":"2018-05-13T05:30:11","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=2775"},"modified":"2023-05-27T20:30:36","modified_gmt":"2023-05-27T11:30:36","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%8cproxy%e3%83%97%e3%83%ad%e3%82%ad%e3%82%b7%e3%80%8d%e3%81%a3%e3%81%a6%e3%81%a9%e3%82%93","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=2775","title":{"rendered":"\u3010GoF\u306e\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011\u300cProxy(\u30d7\u30ed\u30ad\u30b7)\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f"},"content":{"rendered":"<h2>\u300cProxy(\u30d7\u30ed\u30ad\u30b7)\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f<\/h2>\n<p>\u65e2\u5b58\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u305f\u969b\u306b\u3001\u4e00\u65e6\u4e2d\u9593\u7684\u306a\u51e6\u7406\u3092\u5b9f\u884c\u3057\u3066\u304b\u3089\u6e21\u3059\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n<h2>\u30e1\u30ea\u30c3\u30c8<\/h2>\n<p>\u3042\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u3001\u4e2d\u9593\u7684\u306a\u51e6\u7406\u3092\u52a0\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4e2d\u9593\u7684\u306a\u51e6\u7406\u306e\u4f8b\u3068\u3057\u3066\u306f\u4e0b\u8a18\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30e1\u30bd\u30c3\u30c9\u306e\u547c\u3073\u51fa\u3057\u3001\u5b8c\u4e86\u3092\u30ed\u30b0\u306b\u8a18\u9332\u3059\u308b\u3002<\/li>\n<li>\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u884c\u53ef\u5426\u3092\u5224\u5b9a\u3059\u308b\u3002\uff08\u6a5f\u80fd\u7684\u306a\u610f\u5473\u3067\u306f\u306a\u304f\u3001\u6a29\u9650\u7684\u306a\u610f\u5473\u3067\u3002\uff09<\/li>\n<\/ul>\n<h2>\u30af\u30e9\u30b9\u8a2d\u8a08\u306e\u65b9\u6cd5<\/h2>\n<p>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u4f5c\u3063\u3066\u3001<span style=\"color: #ff0000;\"><strong>\u300c\u30d7\u30ed\u30ad\u30b7\u3092\u9069\u7528\u3057\u305f\u3044\u30af\u30e9\u30b9\u300d\u3068\u3001\u300c\u30d7\u30ed\u30ad\u30b7\u3092\u5b9f\u88c5\u3059\u308b\u30af\u30e9\u30b9\u300d\u306b\u305d\u308c\u305e\u308c\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u5b9f\u88c5\u3055\u305b\u3066\u3001\u300c\u30d7\u30ed\u30ad\u30b7\u3092\u5b9f\u88c5\u3059\u308b\u30af\u30e9\u30b9\u300d\u306b\u3060\u3051\u3001\u51e6\u7406\u3092\u8ffd\u52a0\u3059\u308b\u8a2d\u8a08\u306b\u3057\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h3 class=\"title\">Decorator(\u30c7\u30b3\u30ec\u30fc\u30bf)\u3068\u306e\u9055\u3044\u306f\uff1f<\/h3>\n<p>Decorator\u3082\u3001\u30c7\u30b3\u30ec\u30fc\u30bf\u7528\u306e\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u3001\u540c\u3058\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u5b9f\u88c5\u3055\u305b\u308b\u8a2d\u8a08\u306b\u306a\u3063\u3066\u304a\u308a\u4f3c\u3066\u3044\u307e\u3059\u3088\u306d\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u300cDecorator\u300d\u3068\u300cProxy\u300d\u9055\u3044<\/strong><\/span>\u3068\u3057\u3066\u306f\u3001\u4e0b\u8a18\u3067\u3059\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<th>\u30d1\u30bf\u30fc\u30f3<\/th>\n<th>\u7279\u5fb4<\/th>\n<\/tr>\n<tr>\n<td>Decorator<\/td>\n<td>\u65e2\u5b58\u306e\u51e6\u7406\u306b<span style=\"color: #ff0000;\"><strong>\u6a5f\u80fd\u3092\u8ffd\u52a0<\/strong><\/span>\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>Proxy<\/td>\n<td>\u65e2\u5b58\u306e\u51e6\u7406\u306b\u3001<span style=\"color: #ff0000;\"><strong>\u6a5f\u80fd\u3068\u306f\u9055\u3046\u5225\u306e\u51e6\u7406(\u30ed\u30b0\u51fa\u529b\u7b49)\u3092\u8ffd\u52a0<\/strong><\/span>\u3059\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u5b9f\u969b\u306b\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3002<\/h2>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30af\u30e9\u30b9\u56f3\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2780\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/proxy_\u30af\u30e9\u30b9\u56f3.png\" alt=\"\" width=\"578\" height=\"332\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/proxy_\u30af\u30e9\u30b9\u56f3.png 578w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/proxy_\u30af\u30e9\u30b9\u56f3-300x172.png 300w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><\/p>\n<h3>Main.java(\u30e1\u30a4\u30f3\u30d7\u30ed\u30b0\u30e9\u30e0\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package proxy;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void main(String[] args) {\r\n\r\n\t\t\/\/\u30d7\u30ed\u30ad\u30b7\u9069\u7528\u524d\r\n\t\tUsually usu = new Usually();\r\n\t\tusu.MethodA();\r\n\r\n\t\tSystem.out.println(\"------------------\");\r\n\r\n\t\t\/\/\u30d7\u30ed\u30ad\u30b7\u9069\u7528\u5f8c\r\n\t\tProxyImpl proxy = new ProxyImpl(usu);\r\n\t\tproxy.MethodA();\r\n\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>ProxyTest.java(\u30d7\u30ed\u30ad\u30b7\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package proxy;\r\n\r\npublic interface ProxyTest {\r\n\tvoid MethodA();\r\n}\r\n<\/pre>\n<h3>Usually.java(\u666e\u901a\u306e\u30af\u30e9\u30b9\uff1a\u3053\u308c\u3092\u30d7\u30ed\u30ad\u30b7\u306b\u4e00\u65e6\u3086\u3060\u306d\u308b\u3002\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package proxy;\r\n\r\npublic class Usually implements ProxyTest{\r\n\r\n\tpublic void MethodA() {\r\n\t\tSystem.out.println(\"\u666e\u901a\u306e\u51e6\u7406\u3067\u3059\u3002\");\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>ProxyImpl.java(\u30d7\u30ed\u30ad\u30b7\u306e\u5b9f\u88c5\u30af\u30e9\u30b9\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package proxy;\r\n\r\npublic class ProxyImpl implements ProxyTest {\r\n\tProxyTest proxytest;\r\n\r\n\tProxyImpl(ProxyTest proxytest){\r\n\t\tthis.proxytest = proxytest;\r\n\t}\r\n\r\n\tpublic void MethodA() {\r\n\t\tSystem.out.println(\"\u51e6\u7406\u3092\u958b\u59cb\u3057\u307e\u3059\u3002\");\r\n\t\tproxytest.MethodA();\r\n\t\tSystem.out.println(\"\u51e6\u7406\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002\");\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-2781\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u30d7\u30ed\u30ad\u30b7_\u5b9f\u884c\u7d50\u679c.png\" alt=\"\" width=\"276\" height=\"144\" \/><\/p>\n<p>\u30d7\u30ed\u30ad\u30b7\u306e\u9069\u7528\u5f8c\u3067\u306f\u3001\u51e6\u7406\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u300cProxy(\u30d7\u30ed\u30ad\u30b7)\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f \u65e2\u5b58\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u305f\u969b\u306b\u3001\u4e00\u65e6\u4e2d\u9593\u7684\u306a\u51e6\u7406\u3092\u5b9f\u884c\u3057\u3066\u304b\u3089\u6e21\u3059\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002 \u30e1\u30ea\u30c3\u30c8 \u3042\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u3001\u4e2d\u9593\u7684\u306a\u51e6\u7406\u3092\u52a0\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u4e2d\u9593\u7684\u306a\u51e6\u7406\u306e\u4f8b\u3068\u3057\u3066 [&hellip;]","protected":false},"author":1,"featured_media":2777,"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\/2775"}],"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=2775"}],"version-history":[{"count":7,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2775\/revisions"}],"predecessor-version":[{"id":20223,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2775\/revisions\/20223"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/2777"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2775"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}