{"id":7181,"date":"2012-12-18T19:55:38","date_gmt":"2012-12-18T11:55:38","guid":{"rendered":"http:\/\/ihower.tw\/blog\/?p=7181"},"modified":"2012-12-18T23:11:18","modified_gmt":"2012-12-18T15:11:18","slug":"kent-beck-%e7%9a%84%e5%9b%9b%e5%80%8b%e7%b0%a1%e5%96%ae%e8%a8%ad%e8%a8%88%e5%8e%9f%e5%89%87","status":"publish","type":"post","link":"https:\/\/ihower.tw\/blog\/7181-kent-beck-%e7%9a%84%e5%9b%9b%e5%80%8b%e7%b0%a1%e5%96%ae%e8%a8%ad%e8%a8%88%e5%8e%9f%e5%89%87","title":{"rendered":"Kent Beck \u7684\u56db\u500b\u7c21\u55ae\u7a0b\u5f0f\u8a2d\u8a08\u539f\u5247"},"content":{"rendered":"<p>\u4ec0\u9ebc\u662f\u597d\u8a2d\u8a08\uff0c\u6253\u5f9e\u958b\u59cb coding \u4ee5\u4f86\u5c31\u662f\u4e00\u500b\u4e0d\u65b7\u8ffd\u6c42\u7684\u5927\u54c9\u554f\uff0c\u5f9e<br \/>\n<a href=\"http:\/\/en.wikipedia.org\/wiki\/SOLID_(object-oriented_design)\">SOLID<\/a> \u770b\u5230 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Software_design_pattern\">Design Patterns<\/a>\uff0c\u6bcf\u4e00\u500b\u539f\u5247\u770b\u8d77\u4f86\u597d\u6709\u9053\u7406\uff0c\u6bcf\u4e00\u500b\u8a2d\u8a08\u6a21\u5f0f\u90fd\u5728\u7b49\u8457\u4f60\u7684\u5957\u7528\u3002<\/p>\n<p>\u4f46\u662f\u6700\u8fd1\u5e7e\u5e74\u7684\u5de5\u4f5c\u8b93\u6211\u6709\u4e0d\u4e00\u6a23\u7684\u5fc3\u5f97\uff0c\u800c\u4e0d\u518d\u8cbb\u5fc3\u8ffd\u6c42\u300c\u5b8c\u7f8e\u300d\u7684\u8a2d\u8a08\u3002\u540c\u4e00\u500b\u554f\u984c\uff0c\u6bcf\u500b\u4eba\u90fd\u6703\u60f3\u51fa\u4e0d\u4e00\u6a23\u7684\u89e3\u6cd5\uff0c\u90fd\u8aaa\u81ea\u5df1\u7684\u89e3\u6bd4\u8f03\u597d\u3002\u65bc\u662f\u9019\u4e9b\u8a2d\u8a08\u539f\u5247\uff0c\u5e38\u5c31\u6dea\u70ba\u722d\u8ad6\u7684\u5de5\u5177\uff0c\u7576\u6211\u89ba\u5f97\u4f60\u7684\u89e3\u6cd5\u505a\u592a\u591a\u4e8b\u60c5\u6642\uff0c\u642c\u51fa<a href=\"http:\/\/en.wikipedia.org\/wiki\/You_ain't_gonna_need_it\">YAGNI<\/a>; \u7576\u6211\u89ba\u5f97\u4f60\u7684\u89e3\u6cd5\u592a\u8907\u96dc\u6642\uff0c\u642c\u51fa<a href=\"http:\/\/en.wikipedia.org\/wiki\/KISS_Principle\">KISS<\/a>; \u7576\u89ba\u5f97\u4e00\u500b\u985e\u5225\u592a\u80a5\u5927\u7684\u6642\u5019\uff0c\u5c31\u642c\u51fa <a href=\"http:\/\/en.wikipedia.org\/wiki\/Single_responsibility_principle\">SRP<\/a>\uff0c\u53cd\u6b63\u90fd\u53ef\u4ee5\u627e\u5230\u652f\u6301\u7684\u8ad6\u9ede\u5c31\u5c0d\u4e86\u3002\u5f88\u591a\u6642\u5019\u5176\u5be6\u4e0d\u7ba1\u54ea\u4e00\u7a2e\u65b9\u6848\uff0c\u90fd\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\u53ef\u884c\u65b9\u6848\uff0c\u65bc\u662f\u5f8c\u4f86\u6211\u5c31\u4e0d\u60f3\u53bb\u722d\u500b\u4f60\u6b7b\u6211\u6d3b\u3001\u65a4\u65a4\u8a08\u8f03\u7576\u4e0b\u7684\u7d30\u7bc0\u8a2d\u8a08\u4e86\u3002\u597d\u8a2d\u8a08\u61c9\u8a72\u662f\u6f14\u9032(grow)\u51fa\u4f86\u7684\uff0c\u6211\u9996\u5148\u5728\u4e4e\u7684\u53cd\u800c\u662f\u6709\u6c92\u6709\u7559\u4e0b\u53ef\u7528\u7684\u6e2c\u8a66\u548c\u6e05\u695a\u597d\u8b80\u7684\u7a0b\u5f0f\uff0c\u9019\u6a23\u624d\u53ef\u4ee5\u7559\u4e0b(\u5f8c\u4eba)\u6539\u9032\u7684\u6a5f\u6703\u3002<\/p>\n<p>\u56de\u5230\u6b63\u984c\uff0cKent Beck \u5728 eXtreme Programming \u4e2d\uff0c\u5c0d\u65bc\u4ec0\u9ebc\u662f Simple Design\uff0c\u7559\u4e0b\u4e86\u56db\u500b <a href=\"http:\/\/www.c2.com\/cgi\/wiki?XpSimplicityRules\">Xp Simplicity Rules<\/a>\uff0c\u6211\u500b\u4eba\u883b\u559c\u6b61\u7684\uff0c\u56e0\u70ba\u5f88\u7c21\u55ae\u53c8\u57fa\u672c\uff1a<\/p>\n<ol>\n<li>\n<p><strong>Pass All Tests \u901a\u904e\u5168\u90e8\u6e2c\u8a66<\/strong>\uff1a\u6709\u6e2c\u8a66\u624d\u80fd\u5920\u8b93\u8edf\u9ad4\u4e0d\u65b7\u7684\u6f14\u9032(grow)\u4e0b\u53bb\uff0c\u4e0d\u7136\u4f60\u4e0d\u662f\u88ab regression bugs \u6df9\u6b7b\uff0c\u5c31\u662f\u53ea\u80fd\u4e0d\u8a08\u6210\u672c\u628acode\u780d\u6389\u91cd\u7df4\u3002\u5982\u4f55\u5beb\u597d\u6e2c\u8a66\u4e5f\u662f\u500b\u5927\u54c9\u554f\uff0c<a href=\"http:\/\/xunitpatterns.com\/\">xUnit Test Patterns: Refactoring Test Code<\/a>\u4e00\u66f8\u662f\u5176\u4e2d\u7684bible\uff0c\u5acc\u539a\u7684\u8a71\uff0c\u53ef\u4ee5\u5148\u770b\u770b<a href=\"http:\/\/www-public.it-sudparis.eu\/~gibson\/Teaching\/CSC7302\/ReadingMaterial\/vanDeursenMdenBK01.pdf\">Refactoring Test Code<\/a>\u9019\u4e00\u7bc7paper\uff0c\u90fd\u662f\u5728\u8b1b\u91cd\u69cb\u4f60\u7684\u6e2c\u8a66\u7a0b\u5f0f\u3002\u7576\u7136\uff0c\u4e8b\u60c5\u7e3d\u662f\u904e\u7336\u4e0d\u53ca\uff0c\u8001\u95c6\u4ed8\u9322\u7d66\u4f60\u662f\u70ba\u4e86<a href=\"http:\/\/stackoverflow.com\/questions\/153234\/how-deep-are-your-unit-tests\/153565#153565\">\u5f97\u5230 code\uff0c\u4e0d\u662f tests<\/a>\u3002\u6e2c\u8a66\u53ea\u662f\u5e6b\u52a9\u6211\u5011\u5beb\u597dcode\u7684\u5de5\u5177\uff0c\u8ffd\u6c42100%\u5b8c\u6574\u7684\u597d\u6e2c\u8a66\u4e26\u4e0d\u662f\u76ee\u7684\u3002<\/p>\n<\/li>\n<li>\n<p><strong>Reveals Intent (Self-Documenting Code) \u7a0b\u5f0f\u80fd\u5920\u8868\u9054\u51fa\u610f\u5716<\/strong>\uff1a\u5176\u4e2d\u6700\u91cd\u8981\u800c\u4e14\u57fa\u672c\u7684\uff0c\u5c31\u662f\u8981\u6709\u597d\u7684\u7a0b\u5f0f\u547d\u540d\uff0c\u7121\u8ad6\u662f\u985e\u5225\u3001\u65b9\u6cd5\u3001\u8b8a\u6578\u7b49\u7b49\u3002\u5c08\u8b1b Readable \u7684\u66f8\u6709\u4e00\u672c\u53ef\u4ee5\u63a8\u85a6 <a href=\"http:\/\/shop.oreilly.com\/product\/9780596802301.do\">The Art of Readable Code<\/a>\u3002\u6211\u9019\u88e1\u9084\u63a8\u85a6\u4e00\u500b\u6211\u6700\u559c\u6b61\u7684\u6280\u5de7 <a href=\"https:\/\/www.google.com\/search?q=Composed+Method\">Composed Method<\/a> (\u641e\u7b11\u8ac7\u8edf\u5de5\u4e5f\u6709\u4e00\u7bc7<a href=\"http:\/\/teddy-chen-tw.blogspot.tw\/2012\/05\/implementation-patterns-composed-method.html\">\u4ecb\u7d39<\/a>)\uff0c\u9019\u62db\u4e5f\u662f Kent Beck \u5927\u5e2b\u63d0\u51fa\u7684\uff0c\u5c07\u7d30\u7bc0\u7684\u5be6\u4f5c\u62bd\u53d6\u6210\u4e00\u500b\u5c0f\u65b9\u6cd5\uff0c\u8b93\u6574\u500b\u65b9\u6cd5\u88e1\u7684\u64cd\u4f5c\u90fd\u662f\u985e\u4f3c\u7684\u7c92\u5ea6\uff0c\u5c0f\u5c0f\u4e00\u62db\uff0c\u5927\u6709\u4f5c\u7528\u3002<\/p>\n<\/li>\n<li>\n<p><strong>No Duplication (DRY) \u4e0d\u91cd\u8907<\/strong>\uff1a&#8221;Every piece of knowledge must have a single, unambiguous, authoritative representation within a system&#8221; \u5b8c\u6574\u5b9a\u7fa9\u8acb\u8907\u8aa6\u4e09\u6b21\u3002\u6709\u6642\u5019\u91cd\u8907\u4e26\u4e0d\u662f\u9019\u9ebc\u660e\u986f\uff0c\u4f8b\u5982\u4f5c\u7528\u91cd\u8907\u7684\u7a0b\u5f0f\uff0c\u4f46\u547d\u540d\u4e0d\u540c\uff0c\u6216\u662f\u547d\u540d\u91cd\u8907\uff0c\u4f46\u7a0b\u5f0f\u4f5c\u7528\u4e0d\u4e00\u6a23\u3002\u9019\u88e1\u63a8\u85a6 David Chelimsky \u7684\u5f71\u7247 <a href=\"http:\/\/confreaks.com\/videos\/434-rubyconf2010-maintaining-balance-while-reducing-duplication\">Maintaining Balance While Reducing Duplication<\/a> (<a href=\"http:\/\/blog.davidchelimsky.net\/wp-content\/uploads\/2010\/11\/duplication.pdf\">slides<\/a>)\u548c <a href=\"http:\/\/confreaks.com\/videos\/984-goruco2012-maintaining-balance-while-reducing-duplication-part-ii\">Maintaining Balance while Reducing Duplication: Part II<\/a>\uff0c\u53ef\u4ee5\u589e\u9032\u5c0d DRY \u7684\u7406\u89e3\uff0cDRY \u4e0d\u53ea\u662f\u5728\u8b1b\u4e0d\u8981\u91cd\u8907\u7a0b\u5f0f\u78bc\u800c\u5df2\u3002<\/p>\n<\/li>\n<li>\n<p><strong>Has no superfluous parts (Minimizes the number of classes and methods) \u4e0d\u591a\u9918<\/strong>\uff1a\u9019\u4e00\u689d\u4e5f\u5c31\u662f <a href=\"http:\/\/en.wikipedia.org\/wiki\/You_ain't_gonna_need_it\">YAGNI<\/a>\uff0c\u4e0d\u8981\u5be6\u4f5c\u591a\u9918\u7684\u529f\u80fd\u3002\u6211\u500b\u4eba\u4e0d\u600e\u9ebc\u559c\u611b\u9019\u500b\u539f\u5247\u3002\u4e0d\u662f\u4e0d\u8d0a\u540c\uff0c\u4e0d\u9700\u8981\u7684\u529f\u80fd\u82b1\u6642\u9593\u53bb\u5beb\u7576\u7136\u662f\u6d6a\u8cbb\u5927\u5bb6\u6642\u9593\uff0c\u800c\u662f\u9019\u500b\u539f\u5247\u592a\u5bb9\u6613\u4f8b\u5916\u4e86\u3002\u6709\u6642\u5019\u6703\u5beb\u4e0b\u591a\u9918\u7684\u7a0b\u5f0f\u4f86\u589e\u52a0\u529f\u80fd\u6216\u64f4\u5145\u6027\uff0c\u90a3\u662f\u56e0\u70ba\u4f60\u64c1\u6709\u7684\u7d93\u9a57\u3001\u76f4\u89ba\u8ddf\u7576\u6642\u7684\u60c5\u5883\u544a\u8a34\u4f60\u61c9\u8a72\u9019\u9ebc\u505a\uff0c\u9019\u53ef\u4ee5\u5728\u4e0d\u4e45\u7684\u5c07\u4f86\u5c31\u6d3e\u4e0a\u7528\u5834\uff0c\u904e\u65bc\u5f37\u8abf YAGNI \u53cd\u800c\u4e00\u677f\u4e00\u773c\u6559\u689d\u4e3b\u7fa9\u4e86\u3002\u5149\u55ae\u770b&#8221;\u6e1b\u5c11\u985e\u5225\u8ddf\u65b9\u6cd5\u7684\u6578\u91cf&#8221;\u8ddf <a href=\"http:\/\/en.wikipedia.org\/wiki\/Single_responsibility_principle\">SRP<\/a> \u548c Composed Method \u5c31\u6709\u6240\u885d\u7a81\u4e86\uff0c\u5f8c\u5169\u8005\u90fd\u6703\u589e\u52a0\u985e\u5225\u548c\u65b9\u6cd5\u7684\u6578\u91cf\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u91cd\u8981\u6027 1 &gt; 2 &gt; 3 &gt; 4\uff0c\u4e5f\u6709\u7248\u672c\u8b1b 1 &gt; 3 &gt; 2 &gt; 4\u3002<\/p>\n<h1>\u53c3\u8003\u8cc7\u6599<\/h1>\n<ul>\n<li><a href=\"http:\/\/www.c2.com\/cgi\/wiki?XpSimplicityRules\">Xp Simplicity Rules<\/a><\/li>\n<li><a href=\"http:\/\/agileinaflash.blogspot.tw\/2009\/02\/simple-design.html\">Agile in a Flash: Simple Design<\/a><\/li>\n<li><a href=\"http:\/\/agile.dzone.com\/articles\/4-rules-simple-design\">The 4 rules of simple design<\/a><\/li>\n<li><a href=\"http:\/\/theholyjava.wordpress.com\/2011\/02\/14\/clean-code-four-simple-design-rules\/\">Clean Code: Four Simple Design Rules \u2013 Obligatory Read<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u9ebc\u662f\u597d\u8a2d\u8a08\uff0c\u6253\u5f9e\u958b\u59cb coding \u4ee5\u4f86\u5c31\u662f\u4e00\u500b\u4e0d\u65b7\u8ffd\u6c42\u7684\u5927\u54c9\u554f\uff0c\u5f9e SOLID \u770b\u5230 Design Pat &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ihower.tw\/blog\/7181-kent-beck-%e7%9a%84%e5%9b%9b%e5%80%8b%e7%b0%a1%e5%96%ae%e8%a8%ad%e8%a8%88%e5%8e%9f%e5%89%87\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Kent Beck \u7684\u56db\u500b\u7c21\u55ae\u7a0b\u5f0f\u8a2d\u8a08\u539f\u5247\u3009<\/span><\/a><\/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_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,2],"tags":[],"class_list":["post-7181","post","type-post","status-publish","format-standard","hentry","category-programming","category-software-development","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1q6tG-1RP","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/7181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/comments?post=7181"}],"version-history":[{"count":49,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/7181\/revisions"}],"predecessor-version":[{"id":7596,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/7181\/revisions\/7596"}],"wp:attachment":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/media?parent=7181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/categories?post=7181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/tags?post=7181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}