{"id":78,"date":"2011-12-27T17:26:58","date_gmt":"2011-12-27T09:26:58","guid":{"rendered":"http:\/\/www.freezhongzi.info\/?p=78"},"modified":"2019-09-29T09:29:08","modified_gmt":"2019-09-29T01:29:08","slug":"%ef%bb%bfmvc%e5%ad%a6%e4%b9%a0","status":"publish","type":"post","link":"https:\/\/bl4kraven.com\/index.php\/2011\/12\/27\/%ef%bb%bfmvc%e5%ad%a6%e4%b9%a0\/","title":{"rendered":"\ufeffMVC\u5b66\u4e60"},"content":{"rendered":"<p>\u5f15\u8a00\uff1a<\/p>\n<blockquote><p>A Wise old computer scienist once said: Make your data structure smart and your code dump.<\/p>\n<p>We need SMART Models, THIN Controllers, and DUMB Views.<\/p><\/blockquote>\n<p>\u6700\u65e9\u7528MVC\u8fd8\u662f\u5728MFC\u4e2d\u7684\u6587\u6863\u89c6\u56fe\u6846\u67b6\uff0c\u4e0d\u8fc7\u7ed9\u4eba\u611f\u89c9\u6bd4\u8f83\u7e41\u7410\uff0c\u6ca1\u600e\u4e48\u597d\u5370\u8c61\u3002\u524d\u51e0\u5929\u65e0\u804a\u770b\u4e86\u4e00\u4e0bPython\u7684Django\u6846\u67b6\uff0c\u53d1\u73b0\u5b83\u91c7\u7528\u4e86\u4e00\u79cdMTV(Model Template View)\u7684\u6846\u67b6\uff0c\u548cMVC\u5dee\u4e0d\u591a\u3002\u770b\u6765MVC\u4f7f\u7528\u5f88\u5e7f\u6cdb\uff0c\u6211\u987a\u4fbf\u5b66\u4e60\u4e86\u4e00\u4e0b\u597d\u7528\u5728\u7684\u9879\u76ee\u4e2d\u3002<\/p>\n<p>\u4e00\u822c\u6765\u8bf4MVC\u4e2dController\u63a7\u5236\u6570\u636e\u6d41\u3001Model\u5b58\u6570\u636e\u3001View\u663e\u793a\u6570\u636e\u5bf9\u5e94\u4e8e\u6570\u636e\u7684\u8f93\u5165\u3001\u5904\u7406\u548c\u8f93\u51fa\u3002Controller\u8bbe\u8ba1\u65f6\u8981thin\u5c3d\u91cf\u7b80\u6d01\uff0cModel\u5219\u5fc5\u987bsmart\u5904\u7406\u5404\u79cd\u6570\u636e\uff0cView\u5219\u5c3d\u53ef\u80fddumb\u6309\u90e8\u5c31\u73ed\u7684\u663e\u793aModel\u7684\u6570\u636e\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p><center><img decoding=\"async\" src=\"https:\/\/bl4kraven.com\/pic\/mvc.png\"><\/center>\u5728C++\u4e2dMVC\u53ef\u4ee5\u7528Observer\u89c2\u5bdf\u8005\u6a21\u5f0f\u5b9e\u73b0\uff0c\u53ea\u662fObserver\u5c11\u4e86\u4e00\u4e2a\u63a7\u5236\u5668Controller\u3002\u5728\u5b9e\u9645\u7a0b\u5e8f\u4e2dController\u5bf9\u5e94\u4e8e\u9f20\u6807\u952e\u76d8\u4e4b\u7c7b\u7684\u5904\u7406\uff0c\u6240\u4ee5\u4e00\u4e2a\u7a97\u53e3\u7c7b\u5c31\u53ef\u4ee5\u641e\u5b9a\u4e86\u3002View\u7684\u8bdd\u5728windows\u4e2d\u5c31\u662fCanvas\u4e4b\u7c7b\u7684\u753b\u5e03\uff0c\u6bcf\u4e00\u4e2aCanvas\u5bf9\u5e94\u4e00\u4e2aView\u3002\u5b9e\u9645\u5b9e\u73b0\u4e2d\uff0c\u6211\u7528\u591a\u4e2aCanvas\u8bbf\u95ee\u540c\u4e00\u4e2aModel\uff0c\u64cd\u4f5c\u8d77\u6765\u597d\u50cfwindows\u7684\u8fdc\u7a0b\u63a7\u5236\u754c\u9762\u4e00\u6837:)\u3002\u6700\u540e\u4e5f\u662f\u6700\u91cd\u8981\u7684\u5c31\u662fModel\u4e86\uff0c\u7b80\u5355\u70b9\u7684\u5e94\u7528\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\u5c31\u591f\u4e86\uff0c\u5982\u679c\u590d\u6742\u7684\u8bdd\u5c31\u8981\u8003\u8651\u6570\u636e\u5e93\u4e86\u3002<\/p>\n<p>\u6211\u81ea\u5df1\u5199\u7684\u7a0b\u5e8f\u4e2dModel\u8bd5\u7740\u91c7\u7528Sqlite3\u6570\u636e\u5e93\uff0c\u4f46\u662f\u6bcf\u6b21\u64cd\u4f5cModel\u90fd\u8981\u9891\u7e41\u7684\u8bbf\u95ee\u786c\u76d8\uff0c\u628a\u6211\u7684\u786c\u76d8\u5f04\u7684\u5494\u5494\u54cd\u3002\u4e00\u822c\u6570\u636e\u5e93\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u5c31\u8981\u8003\u8651\u7528\u4e8b\u52a1\u5904\u7406\u63d2\u5165\u6216\u4fee\u6539\u8bb0\u5f55\uff0c\u4f46\u73b0\u5728\u64cd\u4f5cModel\u5374\u662f\u968f\u673a\u7684\uff0c\u6240\u4ee5\u4e8b\u52a1\u7528\u4e0d\u7740\u3002\u6700\u540e\u53ea\u597d\u7528Sqlite3\u7684\u5185\u5b58\u6570\u636e\u5e93\uff0c\u7a0b\u5e8f\u542f\u52a8\u65f6\u628a\u786c\u76d8\u4e2d\u7684\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165\u5185\u5b58\uff0c\u7a0b\u5e8f\u9000\u51fa\u65f6\u518d\u4fdd\u5b58\u5230\u786c\u76d8\u4e2d\u3002<\/p>\n<p>\u6700\u540e\u8865\u5145\u4e00\u70b9\uff1aSqlite3\u5bfc\u5165\u5185\u5b58\u6570\u636e\u5e93\u65f6\u8981\u6ce8\u610fPage size\u8981\u8bbe\u7f6e\u6210\u8ddf\u786c\u76d8\u4e2d\u7684\u4e00\u6837\uff0c\u5173\u4e8eSqlite3\u7528\u8d77\u6765\u8fd8\u771f\u4e0d\u9519\uff0c\u770b\u6765\u6570\u636e\u5e93\u4e5f\u8981\u597d\u597d\u5b66\u4e00\u4e0b\u3002<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Model%E2%80%93view%E2%80%93controller\">wiki<\/a><\/p>\n<p><a href=\"https:\/\/www.ruanyifeng.com\/blog\/2007\/11\/mvc.html\">\u962e\u4e00\u5cf0\uff1a\u8c08\u8c08MVC\u6a21\u5f0f<\/a><\/p>\n<p><a href=\"http:\/\/ootips.org\/mvc-pattern.html\">Model-View-Controller<\/a><\/p>\n<p><a href=\"http:\/\/c2.com\/cgi\/wiki?ModelViewController\">Model View Controller<\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00\uff1a A Wise old computer scienist once sa &hellip; <a href=\"https:\/\/bl4kraven.com\/index.php\/2011\/12\/27\/%ef%bb%bfmvc%e5%ad%a6%e4%b9%a0\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a> <a href=\"https:\/\/bl4kraven.com\/index.php\/2011\/12\/27\/%ef%bb%bfmvc%e5%ad%a6%e4%b9%a0\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-program"],"_links":{"self":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":2,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":551,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts\/78\/revisions\/551"}],"wp:attachment":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}