{"id":1830,"date":"2019-04-20T12:34:04","date_gmt":"2019-04-20T12:34:04","guid":{"rendered":"http:\/\/demensdeum.com\/blog\/?p=1830"},"modified":"2024-12-16T22:32:38","modified_gmt":"2024-12-16T19:32:38","slug":"memento-pattern","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/zh\/2019\/04\/20\/memento-pattern\/","title":{"rendered":"\u6a21\u5f0f\u201c\u5feb\u7167\u201d"},"content":{"rendered":"<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u63cf\u8ff0\u201c\u5feb\u7167\u201d\u6a21\u5f0f\u3002\u6216\u201c\u7eaa\u5ff5\u54c1\u201d<\/p>\n<p>\u6b64\u6a21\u5f0f\u6307\u7684\u662f\u201c\u884c\u4e3a\u201d\u6a21\u5f0f\u3002\u8bbe\u8ba1\u6a21\u5f0f\u3002<\/p>\n<h3><a href=\"https:\/\/pxhere.com\/en\/photo\/655263\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1834\" src=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2019\/04\/hipster-camera-1.jpg-1.jpg\" alt=\"\" width=\"360\" height=\"240\" \/><\/a><\/h3>\n<p>\u5047\u8bbe\u6211\u4eec\u6b63\u5728\u5f00\u53d1\u4e00\u4e2a\u56fe\u5f62\u7f16\u8f91\u5668\uff0c\u5e76\u4e14\u6211\u4eec\u9700\u8981\u6dfb\u52a0\u6839\u636e\u7528\u6237\u547d\u4ee4\u56de\u6eda\u64cd\u4f5c\u7684\u529f\u80fd\u3002\u540c\u6837\u975e\u5e38\u91cd\u8981\u7684\u662f\uff0c\u5728\u5b9e\u73b0\u6b64\u6a21\u5f0f\u65f6\uff0c\u7cfb\u7edf\u7ec4\u4ef6\u65e0\u6743\u8bbf\u95ee\u56de\u6eda\u201c\u64cd\u4f5c\u201d\u7684\u5185\u90e8\u72b6\u6001\uff0c\u5176\u4ed6\u7cfb\u7edf\u7ec4\u4ef6\u53ea\u80fd\u8bbf\u95ee\u5feb\u7167\u5bf9\u8c61\u800c\u65e0\u6cd5\u66f4\u6539\uff1b\u5176\u5185\u90e8\u72b6\u6001\uff0c\u63d0\u4f9b\u6e05\u6670\u3001\u7b80\u5355\u7684\u5916\u90e8\u63a5\u53e3\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f7f\u7528\u4e86\u201c\u5feb\u7167\u201d\u6a21\u5f0f\u3002\u6216\u201c\u5b88\u62a4\u8005\u201d\u3002<\/p>\n<p>\u5de5\u4f5c\u793a\u4f8b\u201c\u5feb\u7167\u201d\u4ecb\u7ecd\u5982\u4e0b\uff1a<\/p>\n<p><!-- iframe plugin v.5.1 wordpress.org\/plugins\/iframe\/ --><br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/demensdeum.com\/demos\/memento\/index.html\" width=\"400\" height=\"600\" scrolling=\"yes\" class=\"iframe-class\" frameborder=\"0\"><\/iframe><\/p>\n<p>\u5355\u51fb\u65f6\uff0c\u4f1a\u51fa\u73b0\u4e00\u4e2a\u7cbe\u7075\uff0c\u5355\u51fb\u5377\u66f2\u7684\u7bad\u5934\u65f6\uff0c\u64cd\u4f5c\u4f1a\u88ab\u53d6\u6d88&#8211;\u7cbe\u7075\u6d88\u5931\u4e86\u3002\u8be5\u793a\u4f8b\u7531\u4e09\u4e2a\u7c7b\u7ec4\u6210\uff1a<\/p>\n<ol>\n<li>\u663e\u793a\u7cbe\u7075\u548c\u56fe\u5f62\u754c\u9762\u7684\u753b\u5e03\u3002<\/li>\n<li>\u5c4f\u5e55\u63a7\u5236\u5668\uff0c\u5b83\u5904\u7406\u70b9\u51fb\u5e76\u63a7\u5236\u5c4f\u5e55\u7684\u903b\u8f91\u3002<\/li>\n<li>\u5982\u6709\u5fc5\u8981\uff0c\u53ef\u4f7f\u7528\u5c4f\u5e55\u63a7\u5236\u5668\u56de\u6eda\u6bcf\u6b21\u66f4\u6539\u540e\u6301\u7eed\u5b58\u5728\u7684\u753b\u5e03\u72b6\u6001\u3002<\/li>\n<\/ol>\n<p>\u5728\u6a21\u5f0f\u201c\u5feb\u7167\u201d\u7684\u4e0a\u4e0b\u6587\u4e2d\u8bfe\u7a0b\u6709\uff1a<\/p>\n<ol>\n<li>\u753b\u5e03&#8211;\u6e90\u4e2d\uff0c\u6b64\u7c7b\u7684\u72b6\u6001\u4fdd\u5b58\u4e3a\u201c\u5feb\u7167\u201d\uff0c\u4ee5\u4fbf\u4ee5\u540e\u6839\u636e\u8bf7\u6c42\u56de\u6eda\u3002\u6b64\u5916\uff0c\u6e90\u5fc5\u987b\u80fd\u591f\u5728\u5411\u5176\u4f20\u8f93\u201c\u5feb\u7167\u201d\u65f6\u6062\u590d\u72b6\u6001\u3002<\/li>\n<li>\u63a7\u5236\u5668\u4fdd\u7ba1\u4eba\uff0c\u6b64\u7c7b\u77e5\u9053\u5982\u4f55\u4ee5\u53ca\u4f55\u65f6\u4fdd\u5b58\/\u56de\u6eda\u72b6\u6001\u3002<\/li>\n<li>\u72b6\u6001&#8211;\u5feb\u7167\uff0c\u4e00\u4e2a\u5b58\u50a8\u6e90\u72b6\u6001\u7684\u7c7b\uff0c\u52a0\u4e0a\u65e5\u671f\u4fe1\u606f\u6216\u53ef\u4ee5\u7cbe\u786e\u5efa\u7acb\u56de\u6eda\u987a\u5e8f\u7684\u7d22\u5f15\u3002<\/li>\n<\/ol>\n<p>\u8be5\u6a21\u5f0f\u7684\u4e00\u4e2a\u91cd\u8981\u7279\u5f81\u662f\uff0c\u53ea\u6709\u6e90\u624d\u80fd\u8bbf\u95ee\u5feb\u7167\u4e2d\u5df2\u4fdd\u5b58\u72b6\u6001\u7684\u5185\u90e8\u5b57\u6bb5\uff0c\u8fd9\u662f\u4fdd\u62a4\u5feb\u7167\u514d\u53d7\u5916\u90e8\u66f4\u6539\uff08\u6765\u81ea\u60f3\u8981\u7ed5\u8fc7\u5c01\u88c5\u8fdb\u884c\u66f4\u6539\u7684\u5f00\u53d1\u4eba\u5458\u7684\u66f4\u6539\uff09\u6240\u5fc5\u9700\u7684\uff1b \uff0c\u7834\u574f\u7cfb\u7edf\u903b\u8f91\uff09\u3002\u4e3a\u4e86\u5b9e\u73b0\u5c01\u88c5\uff0c\u4f7f\u7528\u5185\u7f6e\u7c7b\uff0c\u5e76\u4e14\u5728 C++ \u4e2d\uff0c\u5b83\u4eec\u4f7f\u7528\u6307\u5b9a\u53cb\u5143\u7c7b\u7684\u529f\u80fd\u3002\u5c31\u6211\u4e2a\u4eba\u800c\u8a00\uff0c\u6211\u4e3a Rise \u5b9e\u73b0\u4e86\u4e00\u4e2a\u6ca1\u6709\u5c01\u88c5\u7684\u7b80\u5355\u7248\u672c\uff0c\u5e76\u5728\u4e3a Swift \u5b9e\u73b0\u65f6\u4f7f\u7528 Generic\u3002\u5728\u6211\u7684\u7248\u672c\u4e2d&#8211; Memento \u4ec5\u5c06\u5176\u5185\u90e8\u72b6\u6001\u8d4b\u4e88\u540c\u4e00\u7c7b\u72b6\u6001\u7684\u5b9e\u4f53\uff1a<br \/><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1856\" src=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2019\/04\/stateByRequest.jpg\" alt=\"\" width=\"321\" height=\"203\" \/><\/p>\n<h3>\u6765\u6e90<\/h3>\n<p><a href=\"https:\/\/refactoring.guru\/design-patterns\/memento\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/refactoring.guru\/design-patterns\/memento<\/a <\/p>\n<h3>\u6e90\u4ee3\u7801<\/h3>\n<p><a href=\"https:\/\/gitlab.com\/demensdeum\/patterns\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/gitlab.com\/demensdeum\/patterns\/<\/a>< \/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u63cf\u8ff0\u201c\u5feb\u7167\u201d\u6a21\u5f0f\u3002\u6216\u201c\u7eaa\u5ff5\u54c1\u201d \u6b64\u6a21\u5f0f\u6307\u7684\u662f\u201c\u884c\u4e3a\u201d\u6a21\u5f0f\u3002\u8bbe\u8ba1\u6a21\u5f0f\u3002 \u5047\u8bbe\u6211\u4eec\u6b63\u5728\u5f00\u53d1\u4e00\u4e2a\u56fe\u5f62\u7f16\u8f91\u5668\uff0c\u5e76\u4e14\u6211\u4eec\u9700\u8981\u6dfb\u52a0\u6839\u636e\u7528\u6237\u547d\u4ee4\u56de\u6eda\u64cd\u4f5c\u7684\u529f\u80fd\u3002\u540c\u6837\u975e\u5e38\u91cd\u8981\u7684\u662f\uff0c\u5728\u5b9e\u73b0\u6b64\u6a21\u5f0f\u65f6\uff0c\u7cfb\u7edf\u7ec4\u4ef6\u65e0\u6743\u8bbf\u95ee\u56de\u6eda\u201c\u64cd\u4f5c\u201d\u7684\u5185\u90e8\u72b6\u6001\uff0c\u5176\u4ed6\u7cfb\u7edf\u7ec4\u4ef6\u53ea\u80fd\u8bbf\u95ee\u5feb\u7167\u5bf9\u8c61\u800c\u65e0\u6cd5\u66f4\u6539\uff1b\u5176\u5185\u90e8\u72b6\u6001\uff0c\u63d0\u4f9b\u6e05\u6670\u3001\u7b80\u5355\u7684\u5916\u90e8\u63a5\u53e3\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f7f\u7528\u4e86\u201c\u5feb\u7167\u201d\u6a21\u5f0f\u3002\u6216\u201c\u5b88\u62a4\u8005\u201d\u3002 \u5de5\u4f5c\u793a\u4f8b\u201c\u5feb\u7167\u201d\u4ecb\u7ecd\u5982\u4e0b\uff1a \u5355\u51fb\u65f6\uff0c\u4f1a\u51fa\u73b0\u4e00\u4e2a\u7cbe\u7075\uff0c\u5355\u51fb\u5377\u66f2\u7684\u7bad\u5934\u65f6\uff0c\u64cd\u4f5c\u4f1a\u88ab\u53d6\u6d88&#8211;\u7cbe\u7075\u6d88\u5931\u4e86\u3002\u8be5\u793a\u4f8b\u7531\u4e09\u4e2a\u7c7b\u7ec4\u6210\uff1a \u663e\u793a\u7cbe\u7075\u548c\u56fe\u5f62\u754c\u9762\u7684\u753b\u5e03\u3002 \u5c4f\u5e55\u63a7\u5236\u5668\uff0c\u5b83\u5904\u7406\u70b9\u51fb\u5e76\u63a7\u5236\u5c4f\u5e55\u7684\u903b\u8f91\u3002 \u5982\u6709\u5fc5\u8981\uff0c\u53ef\u4f7f\u7528\u5c4f\u5e55\u63a7\u5236\u5668\u56de\u6eda\u6bcf\u6b21\u66f4\u6539\u540e\u6301\u7eed\u5b58\u5728\u7684\u753b\u5e03\u72b6\u6001\u3002 \u5728\u6a21\u5f0f\u201c\u5feb\u7167\u201d\u7684\u4e0a\u4e0b\u6587\u4e2d\u8bfe\u7a0b\u6709\uff1a \u753b\u5e03&#8211;\u6e90\u4e2d\uff0c\u6b64\u7c7b\u7684\u72b6\u6001\u4fdd\u5b58\u4e3a\u201c\u5feb\u7167\u201d\uff0c\u4ee5\u4fbf\u4ee5\u540e\u6839\u636e\u8bf7\u6c42\u56de\u6eda\u3002\u6b64\u5916\uff0c\u6e90\u5fc5\u987b\u80fd\u591f\u5728\u5411\u5176\u4f20\u8f93\u201c\u5feb\u7167\u201d\u65f6\u6062\u590d\u72b6\u6001\u3002 \u63a7\u5236\u5668\u4fdd\u7ba1\u4eba\uff0c\u6b64\u7c7b\u77e5\u9053\u5982\u4f55\u4ee5\u53ca\u4f55\u65f6\u4fdd\u5b58\/\u56de\u6eda\u72b6\u6001\u3002 \u72b6\u6001&#8211;\u5feb\u7167\uff0c\u4e00\u4e2a\u5b58\u50a8\u6e90\u72b6\u6001\u7684\u7c7b\uff0c\u52a0\u4e0a\u65e5\u671f\u4fe1\u606f\u6216\u53ef\u4ee5\u7cbe\u786e\u5efa\u7acb\u56de\u6eda\u987a\u5e8f\u7684\u7d22\u5f15\u3002 \u8be5\u6a21\u5f0f\u7684\u4e00\u4e2a\u91cd\u8981\u7279\u5f81\u662f\uff0c\u53ea\u6709\u6e90\u624d\u80fd\u8bbf\u95ee\u5feb\u7167\u4e2d\u5df2\u4fdd\u5b58\u72b6\u6001\u7684\u5185\u90e8\u5b57\u6bb5\uff0c\u8fd9\u662f\u4fdd\u62a4\u5feb\u7167\u514d\u53d7\u5916\u90e8\u66f4\u6539\uff08\u6765\u81ea\u60f3\u8981\u7ed5\u8fc7\u5c01\u88c5\u8fdb\u884c\u66f4\u6539\u7684\u5f00\u53d1\u4eba\u5458\u7684\u66f4\u6539\uff09\u6240\u5fc5\u9700\u7684\uff1b \uff0c\u7834\u574f\u7cfb\u7edf\u903b\u8f91\uff09\u3002\u4e3a\u4e86\u5b9e\u73b0\u5c01\u88c5\uff0c\u4f7f\u7528\u5185\u7f6e\u7c7b\uff0c\u5e76\u4e14\u5728 C++ \u4e2d\uff0c\u5b83\u4eec\u4f7f\u7528\u6307\u5b9a\u53cb\u5143\u7c7b\u7684\u529f\u80fd\u3002\u5c31\u6211\u4e2a\u4eba\u800c\u8a00\uff0c\u6211\u4e3a Rise \u5b9e\u73b0\u4e86\u4e00\u4e2a\u6ca1\u6709\u5c01\u88c5\u7684\u7b80\u5355\u7248\u672c\uff0c\u5e76\u5728\u4e3a Swift \u5b9e\u73b0\u65f6\u4f7f\u7528 Generic\u3002\u5728\u6211\u7684\u7248\u672c\u4e2d&#8211; Memento \u4ec5\u5c06\u5176\u5185\u90e8\u72b6\u6001\u8d4b\u4e88\u540c\u4e00\u7c7b\u72b6\u6001\u7684\u5b9e\u4f53\uff1a \u6765\u6e90 https:\/\/refactoring.guru\/design-patterns\/memento<\/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":[100,95],"class_list":["post-1830","post","type-post","status-publish","format-standard","hentry","category-techie","category-tutorials","tag-memento","tag-patterns","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"zh","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\/zh\/wp-json\/wp\/v2\/posts\/1830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/comments?post=1830"}],"version-history":[{"count":32,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts\/1830\/revisions"}],"predecessor-version":[{"id":3959,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts\/1830\/revisions\/3959"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/media?parent=1830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/categories?post=1830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/tags?post=1830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}