{"id":296,"date":"2008-01-18T14:21:24","date_gmt":"2008-01-18T06:21:24","guid":{"rendered":"https:\/\/lifeparty.idv.tw\/blog\/archives\/296"},"modified":"2008-01-18T17:18:12","modified_gmt":"2008-01-18T09:18:12","slug":"%e6%87%89%e7%94%a8%e6%9c%8d%e5%8b%99%e7%9a%84%e6%b8%9b%e9%9c%87%e9%bb%9e","status":"publish","type":"post","link":"https:\/\/lifeparty.idv.tw\/blog\/archives\/296","title":{"rendered":"\u61c9\u7528\u670d\u52d9\u7684\u6e1b\u9707\u9ede"},"content":{"rendered":"<p>\u5728<a href=\"http:\/\/en.wikipedia.org\/wiki\/Service-oriented_architecture\">\u670d\u52d9\u5c0e\u5411\u7684\u67b6\u69cb<\/a>\u4e2d\uff0c<a href=\"http:\/\/www.martinfowler.com\/eaaCatalog\/serviceLayer.html\">\u670d\u52d9\u5c64<\/a>\u7684\u6982\u5ff5\u53ef\u4ee5\u8b93\u670d\u52d9\u7684\u61c9\u7528\u8207\u5be6\u4f5c\u4e0d\u6703\u76f8\u4e92\u5e72\u64fe\u3002\u8b93\u696d\u52d9\u7684\u6b78\u696d\u52d9\uff0c\u6280\u8853\u7684\u6b78\u6280\u8853\uff0c\u5f7c\u6b64\u4e4b\u9593\u5247\u662f\u900f\u904e\u61c9\u7528\u670d\u52d9\u4f86\u6e9d\u901a\uff0c\u4ee5\u9054\u6210\u4ee5\u6280\u8853\u5be6\u4f5c\u4f86\u5be6\u73fe\u696d\u52d9\u9700\u6c42\u3002\u4e0d\u904e\uff0c\u7576\u9762\u81e8\u696d\u52d9\u7684\u64f4\u589e\u6642\uff0c\u9700\u6c42\u7684\u8b8a\u5316\u5e38\u4f7f\u5f97\u61c9\u7528\u670d\u52d9\u9762\u81e8\u6539\u8b8a\uff0c\u4ee4\u958b\u767c\u8005\u76f8\u7576\u56f0\u64fe\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u7576\u696d\u52d9\u74b0\u5883\u9762\u81e8\u6539\u8b8a\u6642\uff0c\u7cfb\u7d71\u4e5f\u5fc5\u9808\u8996\u4f7f\u7528\u60c5\u5883\u8b8a\u5316\u800c\u9032\u884c\u8abf\u6574\uff0c\u5982\u6b64\u5c07\u5f71\u97ff\u5230\u61c9\u7528\u670d\u52d9\u7684\u8a2d\u8a08\u8207\u5be6\u4f5c\u3002\u4f46\u9019\u7a2e\u6539\u8b8a\u8207\u8abf\u6574\u52e2\u5fc5\u5c07\u5f71\u97ff\u5230\u4e86\u670d\u52d9\u5c0e\u5411\u67b6\u69cb\u4e0d\u8b93\u8edf\u9ad4\u9700\u6c42\u76f4\u63a5<a href=\"http:\/\/en.wikipedia.org\/wiki\/Coupling_%28computer_science%29\">\u8026\u5408<\/a>\u6280\u8853\u5be6\u4f5c\u7684\u521d\u8877\u3002<\/p>\n<p>\u63db\u53e5\u8a71\u8aaa\uff0c\u76f4\u63a5\u4f9d\u64da\u9700\u6c42\u7684\u8b8a\u5316\u800c\u8abf\u6574\u670d\u52d9\u7684\u8a2d\u8a08\uff0c\u5c07\u7121\u6cd5\u8b93\u696d\u52d9\u9700\u6c42\u8207\u6280\u8853\u5be6\u4f5c\u76f8\u4e92\u7368\u7acb\u3002\u5982\u679c\u4efb\u7531\u9019\u6a23\u7684\u60c5\u5f62\u767c\u751f\uff0c\u8a2d\u8a08\u5c07\u6703\u6108\u8b8a\u6108\u8907\u96dc\uff0c\u4e26\u4e14\u5728\u672a\u4f86\u7684\u67d0\u4e00\u5929\u5ba3\u544a\u7121\u6cd5\u9069\u61c9\u696d\u52d9\u9700\u6c42\u7684\u8b8a\u52d5\uff0c\u5230\u6642\u5019\u60c5\u6cc1\u5c31\u6703\u8b8a\u5f97\u76f8\u7576\u9ebb\u7169\u3002<\/p>\n<p>\u70ba\u4ec0\u9ebc\u6703\u767c\u751f\u9019\u6a23\u7684\u60c5\u6cc1\u5462\uff1f\u4f9d\u64da\u540c\u4eba\u7684\u8edf\u9ad4\u958b\u767c\u7d93\u9a57\u986f\u793a\uff0c\u591a\u8b8a\u7684\u6280\u8853\u8207\u4e0d\u78ba\u5b9a\u7684\u9700\u6c42\u5e38\u5e38\u6703\u76f8\u4e92\u5f71\u97ff\u800c\u589e\u52a0\u4e86\u6574\u5408\u7684\u8907\u96dc\u6027\u3002\u4e0d\u540c\u7684\u6280\u8853\u5be6\u4f5c\u65b9\u5f0f\uff0c\u5e38\u5e38\u57fa\u65bc\u4e00\u4e9b\u5047\u8a2d\uff0c\u4f46\u9019\u4e9b\u5047\u8a2d\u537b\u6210\u70ba\u4e86\u8b93\u7cfb\u7d71\u96e3\u4ee5\u6574\u5408\u7684\u98a8\u96aa\u4f86\u6e90\uff0c\u800c\u70ba\u4e86\u89e3\u6c7a\u554f\u984c\u5f80\u5f80\u5c31\u5728\u76f8\u4e92\u727d\u5c31\u7684\u60c5\u6cc1\u4e0b\uff0c\u4f7f\u8a2d\u8a08\u589e\u52a0\u4e86<strong>\u6c92\u6709\u5fc5\u8981\u7684\u8907\u96dc\u5ea6<\/strong>\u3002<\/p>\n<p>\u4e00\u822c\u800c\u8a00\uff0c\u670d\u52d9\u5c0e\u5411\u67b6\u69cb\u7684\u8edf\u9ad4\u958b\u767c\u6703\u5c07\u61c9\u7528<a href=\"http:\/\/en.wikipedia.org\/wiki\/Service_%28Systems_Architecture%29\">\u670d\u52d9<\/a>\u62bd\u96e2\u51fa\u4f86\uff0c\u4e26\u63d0\u4f9b\u670d\u52d9<a href=\"http:\/\/en.wikipedia.org\/wiki\/Interface_%28computer_science%29\">\u754c\u9762<\/a>\u4ee5\u4f9b\u4f7f\u7528\u8005\u754c\u9762\u547c\u53eb\u4f7f\u7528\uff0c\u540c\u6642\u5176\u5b83\u61c9\u7528\u7cfb\u7d71\u4e5f\u53ef\u4ee5\u900f\u904e\u76f8\u540c\u7684\u670d\u52d9\u754c\u9762\u4f86\u8abf\u7528\u61c9\u7528\u670d\u52d9\u3002\u4e0d\u904e\uff0c\u554f\u984c\u5c31\u5728\u65bc\u8de8\u529f\u80fd\u6216\u6280\u8853\u9818\u57df\u7684\u7cfb\u7d71\uff0c\u5b83\u5011\u5f88\u96e3\u80fd\u5920\u5206\u4eab\u76f8\u540c\u7684\u8a2d\u8a08\u6a21\u578b\u3002\u4ee5\u529f\u80fd\u4f86\u770b\uff0c\u56e0\u70ba\u89e3\u6c7a\u7684\u554f\u984c\u4e0d\u540c\u6240\u4ee5\u8a2d\u8a08\u89c0\u9ede\u6703\u6709\u5f88\u5927\u7684\u4e0d\u540c\uff1b\u540c\u6a23\u7684\u9053\u7406\uff0c\u6280\u8853\u5be6\u4f5c\u65b9\u6cd5\u7684\u5dee\u7570\uff0c\u4e5f\u8b93\u5f7c\u6b64\u5728\u8cc7\u8a0a\u7684\u50b3\u9001\u4e0a\u9762\u81e8\u6975\u5927\u7684\u6311\u6230\u3002<\/p>\n<p>\u70ba\u4e86\u89e3\u6c7a\u4ee5\u4e0a\u7684\u56f0\u5883\uff0c\u5728\u8edf\u9ad4\u67b6\u69cb\u4e0a\u61c9\u8a72\u4fdd\u8b77\u61c9\u7528\u670d\u52d9\u5118\u91cf\u4e0d\u53d7\u9700\u6c42\u8b8a\u52d5\u7684\u5f71\u97ff\u3002\u56e0\u6b64\uff0c\u6211\u5011\u5fc5\u9808\u70ba\u61c9\u7528\u670d\u52d9\u8a2d\u8a08\u6e1b\u9707\u9ede\u4f86<strong>\u7de9\u885d\u9700\u6c42\u8b8a\u52d5\u6240\u5e36\u4f86\u7684\u885d\u64ca<\/strong><!--more-->\uff0c\u4e26\u4e14\u8b93\u61c9\u7528\u670d\u52d9\u53ef\u4ee5<strong>\u5f88\u6709\u5f48\u6027\u5730\u88ab\u91cd\u7d44<\/strong>\uff0c\u4f7f\u5f97\u61c9\u7528\u670d\u52d9\u7684\u958b\u767c\u8b8a\u5f97\u66f4\u6709\u6548\u7387\u3002\u800c\u4e14\u9019\u500b\u6e1b\u9707\u9ede\u5fc5\u9808\u53ef\u4ee5\u652f\u63f4<strong>\u8de8\u7cfb\u7d71\u751a\u81f3\u662f\u8de8\u5e73\u53f0\u6216\u7a0b\u5f0f\u8a9e\u8a00\u7684\u9700\u6c42<\/strong>\uff0c\u56e0\u70ba\u9019\u6a23\u624d\u80fd\u4e0d\u6703\u53d7\u9650\u65bc\u4e0d\u540c\u7684\u6280\u8853\u9818\u57df\uff0c\u800c\u9054\u5230\u5b8c\u5168\u5730\u6574\u5408\u5404\u7a2e\u7570\u8cea\u6027\u7cfb\u7d71\u7684\u76ee\u7684\u3002<\/p>\n<p>\u5982\u4f55\u80fd\u6eff\u8db3\u4ee5\u4e0a\u8a2d\u8a08\u9700\u6c42\u5462\uff1f<a href=\"http:\/\/en.wikipedia.org\/wiki\/Facade_pattern\">Fa\u00e7ade Pattern<\/a> \u53ef\u4ee5\u7b26\u5408\u9019\u4e9b\u9700\u6c42\uff0c\u8a2d\u8a08 Service Fa\u00e7ade \u8b93\u5b83\u4f86\u8ca0\u8cac\u5be6\u969b\u61c9\u7528\u670d\u52d9\u7684\u8abf\u7528\uff0c\u4ee5\u6d88\u9664\u670d\u52d9\u61c9\u7528\u7aef\u8207\u670d\u52d9\u5be6\u4f5c\u4e4b\u9593\u7684\u8026\u5408\uff0c\u53c3\u8003\u5982\u4e0b\u5716\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lifeparty.idv.tw\/blog\/wp-content\/uploads\/2008\/01\/service-facade.PNG\" alt=\"service-facade.PNG\" \/><\/p>\n<p>\u5982\u5716\u6240\u793a\uff0cPresentation \u53ef\u4ee5\u76f4\u63a5\u900f\u904e ApplicationServices \u7684\u670d\u52d9\u754c\u9762\u4f86\u8abf\u7528\u61c9\u7528\u670d\u52d9\uff0cPresentation \u8207 ApplicationServices \u4e4b\u9593\u5206\u4eab\u76f8\u540c\u7684<a href=\"http:\/\/en.wikipedia.org\/wiki\/Domain_model\">\u8a9e\u610f\u6a21\u578b<\/a> BizModel\u3002\u56e0\u6b64 Presentation \u5728\u8abf\u7528\u61c9\u7528\u670d\u52d9\u7684\u904e\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u50b3\u905e BizModel \u4e2d\u6240\u8a2d\u8a08\u7684<a href=\"http:\/\/en.wikipedia.org\/wiki\/Business_object_%28computer_science%29\">\u9818\u57df\u7269\u4ef6<\/a>\u4f86\u7576\u6210\u8abf\u7528\u61c9\u7528\u670d\u52d9\u7684\u53c3\u6578\uff0c\u540c\u6642\u4e5f\u53ef\u4ee5\u53d6\u5f97\u61c9\u7528\u670d\u52d9\u57f7\u884c\u5b8c\u7562\u5f8c\u6240\u56de\u50b3\u7684 BizModel \u9818\u57df\u7269\u4ef6\u3002<\/p>\n<p>\u7136\u800c\uff0cOtherApplication \u537b\u53ef\u80fd\u6c92\u6709 BizModel \u7684\u89c0\u5ff5\u53ef\u4ee5\u76f4\u63a5\u8abf\u7528 ApplicationServices \u7684\u61c9\u7528\u670d\u52d9\u3002\u5be6\u52d9\u4e0a\u4e5f\u5f88\u53ef\u80fd\u56e0\u70ba\u63a1\u7528\u4e0d\u540c\u7684\u6280\u8853\u9818\u57df\uff0c\u800c\u4f7f\u5f97\u7121\u6cd5\u63a1\u7528\u76f8\u540c\u7684 BizModel \u4f86\u8abf\u7528\u61c9\u7528\u670d\u52d9\u3002\u56e0\u6b64\uff0c\u6211\u5011\u5fc5\u9808\u63d0\u4f9b\u4e0d\u540c\u7684\u670d\u52d9\u754c\u9762\u8b93 OtherApplication \u4f86\u8abf\u7528\u670d\u52d9\uff0c\u4e26\u4e14\u8a2d\u8a08 TxnMessage \u4f86\u50b3\u9001\u6216\u53d6\u5f97\u8abf\u7528\u61c9\u7528\u670d\u52d9\u6240\u9700\u7684\u8cc7\u8a0a\u6216\u670d\u52d9\u57f7\u884c\u7d50\u679c\u3002<\/p>\n<p>\u5982\u6b64\uff0cOtherApplication \u4fbf\u53ef\u900f\u904e ServceFa\u00e7ade \u4f86\u53d6\u7528\u61c9\u7528\u670d\u52d9\uff0c\u53ea\u8981\u4f9d\u64da\u5be6\u969b\u529f\u80fd\u9700\u6c42\u4f86\u7528 ServiceFa\u00e7adeImpl \u5be6\u73fe ServiceFa\u00e7ade\uff0c\u8b93\u5b83\u53ef\u4ee5\u7522\u751f\u9069\u5408\u7684 BizModel \u9818\u57df\u7269\u4ef6\uff0c\u4fbf\u53ef\u900f\u904e ApplicationServices \u4f86\u8abf\u7528\u5be6\u969b\u7684\u61c9\u7528\u670d\u52d9\u3002<\/p>\n<p>\u5176\u5be6\u5982\u679c\u4e0d\u7528 ServiceFa\u00e7ade \u7684\u8a71\uff0c\u70ba OtherApplication \u5b9a\u7fa9\u65b0\u7684\u61c9\u7528\u670d\u52d9\u754c\u9762\u4e5f\u662f\u53ef\u4ee5\u89e3\u6c7a OtherApplication \u7121\u6cd5\u5b58\u53d6 BizModel \u7684\u554f\u984c\u3002\u4f46\u5982\u6b64\u7684\u8a2d\u8a08\u5c07\u6703\u4f7f\u5f97\u61c9\u7528\u670d\u52d9\u5143\u4ef6\u7522\u751f<strong>\u5de2\u72c0\u4ea4\u6613<\/strong>\u7684\u8907\u96dc\u60c5\u6cc1\u3002<\/p>\n<p>\u56e0\u70ba\u8981\u8b93\u73fe\u6709\u7684\u61c9\u7528\u670d\u52d9\u53ef\u4ee5\u91cd\u8986\u4f7f\u7528\uff0c\u4ee5\u589e\u52a0\u8edf\u9ad4\u958b\u767c\u7684\u6548\u7387\uff0c\u52e2\u5fc5\u6703\u8b93\u65b0\u7684\u670d\u52d9\u53bb\u547c\u53eb\u5230\u539f\u6709\u7684\u61c9\u7528\u670d\u52d9\u5143\u4ef6\u3002\u4f46\u901a\u5e38\u61c9\u7528\u670d\u52d9\u6703\u727d\u6d89\u5230<a href=\"http:\/\/en.wikipedia.org\/wiki\/Database_transaction\">\u4ea4\u6613<\/a>\u7684\u5be6\u73fe\uff0c\u61c9\u7528\u670d\u52d9\u547c\u53eb\u61c9\u7528\u670d\u52d9\u6703\u8b93\u7570\u5e38\u7684\u8655\u7406\u8b8a\u5f97\u76f8\u7576\u8907\u96dc\u3002<\/p>\n<p>\u904b\u7528 ServiceFa\u00e7ade \u53ef\u4ee5\u907f\u514d\u9019\u6a23\u7684\u554f\u984c\uff0c\u4f7f ServiceFa\u00e7ade \u8207 ApplicationServices \u4e4b\u9593\u6b0a\u8cac\u5206\u660e\uff0c\u540c\u6642\u9084\u53ef\u4ee5\u8b93\u4e0d\u540c\u61c9\u7528\u670d\u52d9\u7684\u8abf\u7528\u7531\u540c\u4e00\u500b ServiceFa\u00e7ade \u4f86\u5354\u8abf\uff0c\u7c21\u5316\u7cfb\u7d71\u8026\u5408\u7684\u8907\u96dc\u5ea6\u3001\u4ee5\u53ca\u5229\u65bc\u61c9\u7528\u670d\u52d9\u8abf\u7528\u7684\u63a7\u7ba1\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u7576\u767c\u73fe\u7cfb\u7d71\u76f8\u4e92\u95dc\u806f\u8b8a\u5f97\u8907\u96dc\u5ea6\u6642\uff0cServiceFa\u00e7ade \u662f\u500b\u7c21\u55ae\u53c8\u5177\u6709\u5f48\u6027\u7684\u8a2d\u8a08\u6982\u5ff5\uff0c\u662f\u53ef\u4ee5\u8b93\u8edf\u9ad4\u67b6\u69cb\u7a69\u56fa\u53c8\u53ef\u4ee5\u9069\u61c9\u8b8a\u5316\u7684\u79d8\u5bc6\u6b66\u5668\u5440\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u5011\u5fc5\u9808\u70ba\u61c9\u7528\u670d\u52d9\u8a2d\u8a08\u6e1b\u9707\u9ede\u4f86\u7de9\u885d\u9700\u6c42\u8b8a\u52d5\u6240\u5e36\u4f86\u7684\u885d\u64ca\uff0c\u4e26\u4e14\u8b93\u61c9\u7528\u670d\u52d9\u53ef\u4ee5\u5f88\u6709\u5f48\u6027\u5730\u88ab\u91cd\u7d44\uff0c\u4f7f\u5f97\u61c9\u7528\u670d\u52d9\u7684\u958b\u767c\u8b8a\u5f97\u66f4\u6709\u6548\u7387\u3002\u800c\u4e14\u9019\u500b\u6e1b\u9707\u9ede\u5fc5\u9808\u53ef\u4ee5\u652f\u63f4\u8de8\u7cfb\u7d71\u751a\u81f3\u662f\u8de8\u5e73\u53f0\u6216\u7a0b\u5f0f\u8a9e\u8a00\u7684\u9700\u6c42\uff0c\u56e0\u70ba\u9019\u6a23\u624d\u80fd\u4e0d\u6703\u53d7\u9650\u65bc\u4e0d\u540c\u7684\u6280\u8853\u9818\u57df\uff0c\u800c\u9054\u5230\u5b8c\u5168\u5730\u6574\u5408\u5404\u7a2e\u7570\u8cea\u6027\u7cfb\u7d71\u7684\u76ee\u7684\u3002 <a href=\"https:\/\/lifeparty.idv.tw\/blog\/archives\/296\">\u95b1\u8b80\u5168\u6587 <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":[29,24,41,19],"tags":[],"class_list":["post-296","post","type-post","status-publish","format-standard","hentry","category-29","category-24","category-thinking","category-19"],"_links":{"self":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts\/296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/comments?post=296"}],"version-history":[{"count":0,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts\/296\/revisions"}],"wp:attachment":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/media?parent=296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/categories?post=296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/tags?post=296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}