{"id":2102,"date":"2019-06-27T08:44:24","date_gmt":"2019-06-27T05:44:24","guid":{"rendered":"http:\/\/demensdeum.com\/blog\/?p=2102"},"modified":"2024-12-16T22:32:36","modified_gmt":"2024-12-16T19:32:36","slug":"prototype-pattern","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/ja\/2019\/06\/27\/prototype-pattern\/","title":{"rendered":"\u30d1\u30bf\u30fc\u30f3\u306e\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7"},"content":{"rendered":"<p>\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7 \u30d1\u30bf\u30fc\u30f3\u306f\u3001\u30b8\u30a7\u30cd\u30ec\u30fc\u30c6\u30a3\u30d6 \u30c7\u30b6\u30a4\u30f3 \u30d1\u30bf\u30fc\u30f3\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5c5e\u3057\u307e\u3059\u3002<br \/>\u79c1\u305f\u3061\u304c\u51fa\u4f1a\u3044\u7cfb\u30a2\u30d7\u30ea Tender \u3092\u958b\u767a\u3057\u3066\u3044\u308b\u3068\u3057\u307e\u3059\u3002\u79c1\u305f\u3061\u306e\u30d3\u30b8\u30cd\u30b9 \u30e2\u30c7\u30eb\u306b\u3088\u308c\u3070\u3001\u6709\u6599\u3067\u81ea\u5206\u306e\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3057\u3001\u540d\u524d\u3084\u5199\u771f\u306e\u9806\u5e8f\u3092\u81ea\u52d5\u7684\u306b\u5909\u66f4\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5185\u3067\u3055\u307e\u3056\u307e\u306a\u53cb\u9054\u306e\u30b0\u30eb\u30fc\u30d7\u3068\u8907\u6570\u306e\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u3092\u540c\u6642\u306b\u7ba1\u7406\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u884c\u308f\u308c\u307e\u3057\u305f\u3002<br \/>\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u30b3\u30d4\u30fc\u3001\u540d\u524d\u306e\u81ea\u52d5\u751f\u6210\u3001\u5199\u771f\u306e\u518d\u4e26\u3079\u66ff\u3048\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\u5358\u7d14\u306a\u64ec\u4f3c\u30b3\u30fc\u30c9\u306e\u5b9f\u88c5:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>fun didPressOnCopyProfileButton() {\n    let profileCopy = new Profile()\n    profileCopy.name = generateRandomName()\n    profileCopy.age = profile.age\n    profileCopy.photos = profile.photos.randomize()\n    storage.save(profileCopy)\n}\n<\/code><\/pre>\n<\/div>\n<p>\u6b21\u306b\u3001\u4ed6\u306e\u30c1\u30fc\u30e0 \u30e1\u30f3\u30d0\u30fc\u304c\u30b3\u30d4\u30fc \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u30a2\u30f3\u30c9\u30da\u30fc\u30b9\u30c8\u3057\u305f\u308a\u3001\u6700\u521d\u304b\u3089\u30b3\u30fc\u30c9\u3092\u8003\u3048\u51fa\u3057\u305f\u308a\u3057\u305f\u5f8c\u3001\u65b0\u3057\u3044\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3068\u60f3\u50cf\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u597d\u304d\u3067\u3059\u3002\u3053\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u306f\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u300c\u3044\u3044\u306d\uff01\u300d\u306e\u6570\u304c\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002\u3053\u3053\u3067\u3001\u65b0\u3057\u3044\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u3001\u30b3\u30d4\u30fc\u304c\u884c\u308f\u308c\u308b *\u3059\u3079\u3066* \u306e\u5834\u6240\u3092\u624b\u52d5\u3067\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30b3\u30fc\u30c9\u306e\u4fdd\u5b88\u3068\u30c6\u30b9\u30c8\u306f\u975e\u5e38\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u3001\u56f0\u96e3\u3067\u3059\u3002<br \/>\u3053\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u305f\u3081\u306b\u3001\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3\u304c\u767a\u660e\u3055\u308c\u307e\u3057\u305f\u3002\u5fc5\u8981\u306a\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u542b\u3080\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30d4\u30fc\u3092\u8fd4\u3059 copy() \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u4e00\u822c\u7684\u306a\u30b3\u30d4\u30fc \u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3 \u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u5909\u66f4\u3057\u305f\u5f8c\u306f\u3001\u30b3\u30d4\u30fc \u30b3\u30fc\u30c9\u3092\u542b\u3080\u3059\u3079\u3066\u306e\u5834\u6240\u3092\u624b\u52d5\u3067\u691c\u7d22\u3057\u3066\u66f4\u65b0\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001copy() \u30e1\u30bd\u30c3\u30c9\u3092 1 \u3064\u66f4\u65b0\u3059\u308b\u3060\u3051\u3067\u6e08\u307f\u307e\u3059\u3002<\/p>\n<h3>\u30bd\u30fc\u30b9<\/h3>\n<p><a href=\"https:\/\/refactoring.guru\/ru\/design-patterns\/prototype\" target=\"_blank\" rel=\"noopener\">https:\/\/refactoring.guru\/ru\/design-patterns\/prototype <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7 \u30d1\u30bf\u30fc\u30f3\u306f\u3001\u30b8\u30a7\u30cd\u30ec\u30fc\u30c6\u30a3\u30d6 \u30c7\u30b6\u30a4\u30f3 \u30d1\u30bf\u30fc\u30f3\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5c5e\u3057\u307e\u3059\u3002\u79c1\u305f\u3061\u304c\u51fa\u4f1a\u3044\u7cfb\u30a2\u30d7\u30ea Tender \u3092\u958b\u767a\u3057\u3066\u3044\u308b\u3068\u3057\u307e\u3059\u3002\u79c1\u305f\u3061\u306e\u30d3\u30b8\u30cd\u30b9 \u30e2\u30c7\u30eb\u306b\u3088\u308c\u3070\u3001\u6709\u6599\u3067\u81ea\u5206\u306e\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3057\u3001\u540d\u524d\u3084\u5199\u771f\u306e\u9806\u5e8f\u3092\u81ea\u52d5\u7684\u306b\u5909\u66f4\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5185\u3067\u3055\u307e\u3056\u307e\u306a\u53cb\u9054\u306e\u30b0\u30eb\u30fc\u30d7\u3068\u8907\u6570\u306e\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u3092\u540c\u6642\u306b\u7ba1\u7406\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u884c\u308f\u308c\u307e\u3057\u305f\u3002\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u30b3\u30d4\u30fc\u3001\u540d\u524d\u306e\u81ea\u52d5\u751f\u6210\u3001\u5199\u771f\u306e\u518d\u4e26\u3079\u66ff\u3048\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5358\u7d14\u306a\u64ec\u4f3c\u30b3\u30fc\u30c9\u306e\u5b9f\u88c5: fun didPressOnCopyProfileButton() { let profileCopy = new Profile() profileCopy.name = generateRandomName() profileCopy.age = profile.age profileCopy.photos = profile.photos.randomize() storage.save(profileCopy) } \u6b21\u306b\u3001\u4ed6\u306e\u30c1\u30fc\u30e0 \u30e1\u30f3\u30d0\u30fc\u304c\u30b3\u30d4\u30fc \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u30a2\u30f3\u30c9\u30da\u30fc\u30b9\u30c8\u3057\u305f\u308a\u3001\u6700\u521d\u304b\u3089\u30b3\u30fc\u30c9\u3092\u8003\u3048\u51fa\u3057\u305f\u308a\u3057\u305f\u5f8c\u3001\u65b0\u3057\u3044\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3068\u60f3\u50cf\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u597d\u304d\u3067\u3059\u3002\u3053\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u306f\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306e\u300c\u3044\u3044\u306d\uff01\u300d\u306e\u6570\u304c\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002\u3053\u3053\u3067\u3001\u65b0\u3057\u3044\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u3001\u30b3\u30d4\u30fc\u304c\u884c\u308f\u308c\u308b *\u3059\u3079\u3066* \u306e\u5834\u6240\u3092\u624b\u52d5\u3067\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30b3\u30fc\u30c9\u306e\u4fdd\u5b88\u3068\u30c6\u30b9\u30c8\u306f\u975e\u5e38\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u3001\u56f0\u96e3\u3067\u3059\u3002\u3053\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u305f\u3081\u306b\u3001\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3\u304c\u767a\u660e\u3055\u308c\u307e\u3057\u305f\u3002\u5fc5\u8981\u306a\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u542b\u3080\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30d4\u30fc\u3092\u8fd4\u3059 copy() \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u4e00\u822c\u7684\u306a\u30b3\u30d4\u30fc \u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3 \u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u5909\u66f4\u3057\u305f\u5f8c\u306f\u3001\u30b3\u30d4\u30fc \u30b3\u30fc\u30c9\u3092\u542b\u3080\u3059\u3079\u3066\u306e\u5834\u6240\u3092\u624b\u52d5\u3067\u691c\u7d22\u3057\u3066\u66f4\u65b0\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001copy() \u30e1\u30bd\u30c3\u30c9\u3092 1 \u3064\u66f4\u65b0\u3059\u308b\u3060\u3051\u3067\u6e08\u307f\u307e\u3059\u3002 \u30bd\u30fc\u30b9 https:\/\/refactoring.guru\/ru\/design-patterns\/prototype<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[61,52],"tags":[95,110],"class_list":["post-2102","post","type-post","status-publish","format-standard","hentry","category-techie","category-tutorials","tag-patterns","tag-prototype","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"ja","enabled_languages":["en","ru","zh","de","fr","ja","pt"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"ru":{"title":true,"content":true,"excerpt":false},"zh":{"title":true,"content":true,"excerpt":false},"de":{"title":true,"content":true,"excerpt":false},"fr":{"title":true,"content":true,"excerpt":false},"ja":{"title":true,"content":true,"excerpt":false},"pt":{"title":true,"content":true,"excerpt":false}}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/2102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/comments?post=2102"}],"version-history":[{"count":10,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/2102\/revisions"}],"predecessor-version":[{"id":3951,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/2102\/revisions\/3951"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/media?parent=2102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/categories?post=2102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/tags?post=2102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}