{"id":4903,"date":"2024-10-07T08:01:01","date_gmt":"2024-10-07T00:01:01","guid":{"rendered":""},"modified":"2024-10-07T08:01:01","modified_gmt":"2024-10-07T00:01:01","slug":"\u8bbe\u8ba1\u539f\u5219 \u5355\u4e00\u804c\u8d23_\u8bbe\u8ba1\u7684\u56db\u5927\u57fa\u672c\u539f\u5219","status":"publish","type":"post","link":"https:\/\/mushiming.com\/4903.html","title":{"rendered":"\u8bbe\u8ba1\u539f\u5219 \u5355\u4e00\u804c\u8d23_\u8bbe\u8ba1\u7684\u56db\u5927\u57fa\u672c\u539f\u5219"},"content":{"rendered":"

\u5355\u4e00\u804c\u8d23\u539f\u5219\u7684\u82f1\u6587\u540d\u79f0\u662fSingle Responsibility Principle\uff0c\u7b80\u79f0\u662fSRP\u3002\u8fd9\u4e2a\u8bbe\u8ba1\u539f\u5219\u5907\u53d7\u4e89\u8bae\uff0c\u4e89\u8bae\u4e4b\u5904\u5c31\u662f\u5bf9\u804c\u8d23\u7684\u5b9a\u4e49\uff0c\u4ec0\u4e48\u662f\u7c7b\u7684\u804c\u8d23\uff0c\u4ee5\u53ca\u600e\u4e48\u5212\u5206\u7c7b\u7684\u804c\u8d23\u3002\u6211\u4eec\u5148\u4e3e\u4f8b\u6765\u8bf4\u660e\u4ec0\u4e48\u662f\u5355\u4e00\u804c\u8d23\u539f\u5219\u3002<\/p>\n

\u57fa\u672c\u4e0a\u6240\u6709\u63a5\u89e6\u5230\u7528\u6237\u3001\u673a\u6784\u3001\u89d2\u8272\u7ba1\u7406\u8fd9\u4e9b\u6a21\u5757\u7684\u9879\u76ee\uff0c\u4f7f\u7528\u7684\u90fd\u662fRBAC\u6a21\u578b\uff08Role-Based Access Control\uff0c\u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\uff0c\u901a\u8fc7\u5206\u914d\u548c\u53d6\u6d88\u89d2\u8272\u6765\u5b8c\u6210\u7528\u6237\u6743\u9650\u7684\u6388\u4e88\u548c\u53d6\u6d88\uff0c\u4f7f\u52a8\u4f5c\u4e3b\u4f53\uff08\u7528\u6237\uff09\u4e0e\u8d44\u6e90\u7684\u884c\u4e3a\uff08\u6743\u9650\uff09\u5206\u79bb\uff09\uff0c\u786e\u5b9e\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u89e3\u51b3\u529e\u6cd5\u3002\u6211\u4eec\u8fd9\u91cc\u8981\u8bb2\u7684\u662f\u7528\u6237\u7ba1\u7406\u3001\u4fee\u6539\u7528\u6237\u7684\u4fe1\u606f\u3001\u589e\u52a0\u673a\u6784\uff08\u4e00\u4e2a\u4eba\u5c5e\u4e8e\u591a\u4e2a\u673a\u6784\uff09\u3001\u589e\u52a0\u89d2\u8272\u7b49\u3002\u7528\u6237\u6709\u8fd9\u4e48\u591a\u7684\u4fe1\u606f\u548c\u884c\u4e3a\u8981\u7ef4\u62a4\uff0c\u6211\u4eec\u5c31\u628a\u8fd9\u4e9b\u5199\u9053\u4e00\u4e2a\u63a5\u53e3\u4e2d\uff0c\u90fd\u662f\u7528\u6237\u7ba1\u7406\u7c7b\u561b\uff0c\u6211\u4eec\u6765\u770b\u770b\u5b83\u7684\u7c7b\u56fe\uff0c\u5982\u56fe1-1\u6240\u793a\u3002<\/p>\n

\n
\n \"\u8bbe\u8ba1\u539f\u5219
\n \u56fe1-1\u200b\u200b \u7528\u6237\u4fe1\u606f\u7ef4\u62a4\u7c7b\u56fe
\n <\/figcaption><\/figure>\n<\/div>\n

 <\/p>\n

\u5982\u6b64\u7b80\u5355\u7684\u7c7b\u56fe\uff0c\u5373\u4fbf\u662f\u4e00\u4e2a\u521d\u7ea7\u7684\u7a0b\u5e8f\u5458\u4e5f\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2a\u63a5\u53e3\u8bbe\u8ba1\u7684\u6709\u95ee\u9898\uff0c\u7528\u6237\u7684\u5c5e\u6027\u548c\u7528\u6237\u7684\u884c\u4e3a\u6ca1\u6709\u5206\u5f00\uff0c\u8fd9\u662f\u4e00\u4e2a\u4e25\u91cd\u7684\u9519\u8bef\u3002\u8fd9\u4e2a\u63a5\u53e3\u786e\u5b9e\u8bbe\u8ba1\u7684\u4e00\u56e2\u7cdf\uff0c\u5e94\u8be5\u628a\u7528\u6237\u7684\u4fe1\u606f\u62bd\u53d6\u6210\u4e00\u4e2aBO\uff08Business Object\uff0c\u4e1a\u52a1\u5bf9\u8c61\uff09\uff0c\u628a\u884c\u4e3a\u62bd\u53d6\u6210\u4e00\u4e2aBiz\uff08Business Logic\uff0c\u4e1a\u52a1\u903b\u8f91\uff09\uff0c\u6309\u7167\u8fd9\u4e2a\u601d\u8def\u5bf9\u7c7b\u56fe\u8fdb\u884c\u4fee\u6b63\uff0c\u5982\u56fe1-2\u6240\u793a\u3002<\/p>\n

\n
\n \"\u8bbe\u8ba1\u539f\u5219
\n \u56fe1-2 \u804c\u8d23\u5212\u5206\u540e\u7684\u7c7b\u56fe
\n <\/figcaption><\/figure>\n<\/div>\n

\u91cd\u65b0\u62c6\u5c01\u6210\u4e24\u4e2a\u63a5\u53e3\uff0cIUserBO\u8d1f\u8d23\u7528\u6237\u7684\u5c5e\u6027\uff0c\u7b80\u5355\u7684\u8bf4\uff0cIUserBO\u7684\u804c\u8d23\u5c31\u662f\u6536\u96c6\u548c\u53cd\u9988\u7528\u6237\u7684\u5c5e\u6027\u4fe1\u606f\uff1bIUserBiz\u8d1f\u8d23\u7528\u6237\u7684\u884c\u4e3a\uff0c\u5b8c\u6210\u7528\u6237\u4fe1\u606f\u7684\u7ef4\u62a4\u548c\u53d8\u66f4\u3002\u8fd9\u4e2a\u5176\u5b9e\u4e0e\u6211\u4eec\u5b9e\u9645\u5de5\u4f5c\u4e2d\u7528\u5230\u7684User\u7c7b\u8fd8\u662f\u6709\u5dee\u522b\u7684\uff0c\u4e0d\u7528\u7740\u6025\uff0c\u6211\u4eec\u5148\u6765\u770b\u4e00\u770b\u5206\u62c6\u6210\u4e24\u4e2a\u63a5\u53e3\u600e\u4e48\u4f7f\u7528\u3002\u6211\u4eec\u73b0\u5728\u662f\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff0c\u6240\u4ee5\u4ea7\u751f\u4e86\u8fd9\u4e2aUserInfo\u5bf9\u8c61\u4e4b\u540e\uff0c\u5f53\u7136\u53ef\u4ee5\u628a\u5b83\u5f53IUserBO\u63a5\u53e3\u4f7f\u7528\u3002\u4e5f\u53ef\u4ee5\u5f53IUserBiz\u63a5\u53e3\u4f7f\u7528\uff0c\u8fd9\u8981\u770b\u4f60\u5728\u4ec0\u4e48\u5730\u65b9\u7528\u4e86\u3002\u8981\u83b7\u5f97\u7528\u6237\u4fe1\u606f\uff0c\u5c31\u5f53\u662fIUserBO\u7684\u5b9e\u73b0\u7c7b\uff1b\u8981\u662f\u5e0c\u671b\u7ef4\u62a4\u7528\u6237\u4fe1\u606f\uff0c\u5c31\u628a\u5b83\u5f53\u4f5cIUserBiz\u7684\u5b9e\u73b0\u7c7b\u5c31\u6210\u4e86\uff0c\u5982\u4e0b\u4ee3\u7801\u6240\u793a\u3002<\/p>\n

\u2026\u2026 IUserInfo userInfo = new UserInfo(); \/\/\u6211\u8981\u8d4b\u503c\u4e86\uff0c\u6211\u5c31\u8ba4\u4e3a\u5b83\u662f\u4e00\u4e2a\u7eaf\u7cb9\u7684BO IUserBO userBo = (IUserBo) userInfo; userBo.setPassword(\"abc\"); \/\/\u6211\u8981\u6267\u884c\u52a8\u4f5c\u4e86\uff0c\u6211\u5c31\u8ba4\u4e3a\u8fd9\u662f\u4e00\u4e2a\u4e1a\u52a1\u903b\u8f91\u7c7b IUserBiz userBiz = (IUserBiz) userInfo; userBiz.deleteUser(); \u2026\u2026<\/code><\/pre>\n

\u786e\u5b9e\u53ef\u4ee5\u5982\u6b64\uff0c\u95ee\u9898\u4e5f\u89e3\u51b3\u4e86\uff0c\u4f46\u6211\u4eec\u5206\u6790\u4e00\u4e0b\u521a\u624d\u7684\u52a8\u4f5c\uff0c\u4e3a\u4ec0\u4e48\u8981\u628a\u4e00\u4e2a\u63a5\u53e3\u62c6\u5206\u6210\u4e24\u4e2a\u5462\uff1f\u5176\u5b9e\uff0c\u5728\u5b9e\u9645\u7684\u4f7f\u7528\u4e2d\uff0c\u6211\u4eec\u66f4\u503e\u5411\u4e8e\u4f7f\u7528\u4e24\u4e2a\u7c7b\u6216\u63a5\u53e3\uff1a\u4e00\u4e2a\u662fIUserBO\uff0c\u4e00\u4e2a\u662fIUserBiz\uff0c\u7c7b\u56fe\u5982\u56fe1-3\u6240\u793a\u3002<\/p>\n

\n
\n \"\u8bbe\u8ba1\u539f\u5219
\n \u56fe1-3 \u9879\u76ee\u4e2d\u7ecf\u5e38\u91c7\u7528\u7684SRP\u7c7b\u56fe
\n <\/figcaption><\/figure>\n<\/div>\n

 <\/p>\n

\u4ee5\u4e0a\u6211\u4eec\u628a\u4e00\u4e2a\u63a5\u53e3\u62c6\u5206\u6210\u4e24\u4e2a\u63a5\u53e3\u7684\u52a8\u4f5c\uff0c\u5c31\u662f\u4f9d\u8d56\u4e86\u5355\u4e00\u804c\u8d23\u539f\u5219\uff0c\u90a3\u4e48\u4ec0\u4e48\u662f\u5355\u4e00\u804c\u8d23\u539f\u5219\u5462\uff1f\u5355\u4e00\u804c\u8d23\u539f\u5219\u7684\u5b9a\u4e49\u662f\uff1a\u5e94\u8be5\u6709\u4e14\u4ec5\u6709\u4e00\u4e2a\u539f\u56e0\u5f15\u8d77\u7c7b\u7684\u53d8\u66f4<\/strong>\u3002<\/p>\n

SRP\u7684\u539f\u8bdd\u89e3\u91ca\u662f\uff1aThere should never be more than one reason for a class to change.<\/p>\n

\u4e0a\u9762\u7684\u4f8b\u5b50\u5f88\u597d\u7406\u89e3\uff0c\u5728\u5b9e\u9645\u7684\u9879\u76ee\u4e2d\u5927\u5bb6\u90fd\u5df2\u7ecf\u8fd9\u4e48\u505a\u4e86\uff0c\u90a3\u4e48\u6211\u4eec\u5728\u6765\u770b\u770b\u4e0b\u9762\u7684\u8fd9\u4e2a\u4f8b\u5b50\u662f\u5426\u597d\u7406\u89e3\u3002\u7535\u8bdd\uff0c\u662f\u73b0\u4ee3\u4eba\u90fd\u79bb\u5f00\u4e0d\u4e86\u7684\uff0c\u7535\u8bdd\u901a\u8bdd\u7684\u65f6\u5019\u67094\u4e2a\u8fc7\u7a0b\u53d1\u751f\uff1a\u62e8\u53f7\uff0c\u901a\u8bdd\uff0c\u56de\u5e94\uff0c\u6302\u673a\u3002\u90a3\u6211\u4eec\u5199\u4e00\u4e2a\u63a5\u53e3\uff0c\u5176\u7c7b\u56fe\u5982\u56fe1-4\u6240\u793a\u3002<\/p>\n

\n
\n \"\u8bbe\u8ba1\u539f\u5219
\n \u56fe1-4 \u7535\u8bdd\u7c7b\u56fe
\n <\/figcaption><\/figure>\n<\/div>\n

 <\/p>\n

\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8fc7\u7a0b\u7684\u4ee3\u7801\uff0c\u5982\u4e0b\u4ee3\u7801\u6240\u793a\u3002<\/p>\n

public interface IPhone{ \/\/\u62e8\u901a\u7535\u8bdd public void dial(String phoneNumber); \/\/\u901a\u8bdd public void chat(Object o); \/\/\u901a\u8bdd\u5b8c\u6bd5\uff0c\u6302\u7535\u8bdd public void hangup(); }<\/code><\/pre>\n

\u5b9e\u73b0\u7c7b\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u5c31\u4e0d\u518d\u5199\u4e86\uff0c\u5927\u5bb6\u770b\u770b\u8fd9\u4e2a\u63a5\u53e3\u6709\u6ca1\u6709\u95ee\u9898\uff1f\u6211\u76f8\u4fe1\u5927\u90e8\u5206\u7684\u8bfb\u8005\u90fd\u4f1a\u8bf4\u8fd9\u4e2a\u6ca1\u6709\u95ee\u9898\u5440\uff0c\u662f\u7684\uff0c\u8fd9\u4e2a\u63a5\u53e3\u63a5\u8fd1\u4e8e\u5b8c\u7f8e\uff0c\u770b\u6e05\u695a\u4e86\uff0c\u662f\u201c\u63a5\u8fd1\u201d\uff01\u5355\u4e00\u804c\u8d23\u539f\u5219\u8981\u6c42\u4e00\u4e2a\u63a5\u53e3\u6216\u7c7b\u53ea\u6709\u4e00\u4e2a\u539f\u56e0\u5f15\u8d77\u53d8\u5316\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a\u63a5\u53e3\u6216\u7c7b\u53ea\u6709\u4e00\u4e2a\u804c\u8d23\uff0c\u5b83\u5c31\u8d1f\u8d23\u4e00\u4ef6\u4e8b\u60c5\uff0c\u770b\u770b\u4e0a\u9762\u7684\u63a5\u53e3\u53ea\u8d1f\u8d23\u4e00\u4ef6\u4e8b\u60c5\u5417\uff1f\u662f\u53ea\u6709\u4e00\u4e2a\u539f\u56e0\u5f15\u8d77\u53d8\u5316\u5417\uff1f\u597d\u50cf\u4e0d\u662f\uff01<\/p>\n

IPhone\u8fd9\u4e2a\u63a5\u53e3\u53ef\u4e0d\u662f\u53ea\u6709\u4e00\u4e2a\u804c\u8d23\uff0c\u5b83\u5305\u542b\u4e86\u4e24\u4e2a\u804c\u8d23\uff1a\u4e00\u4e2a\u662f\u534f\u8bae\u7ba1\u7406\uff0c\u4e00\u4e2a\u662f\u6570\u636e\u4f20\u9001\u3002dial()\u548changup()\u4e24\u4e2a\u65b9\u6cd5\u5b9e\u73b0\u7684\u662f\u534f\u8bae\u7ba1\u7406\uff0c\u5206\u522b\u8d1f\u8d23\u62e8\u53f7\u63a5\u901a\u548c\u6302\u673a\uff1bchat()\u5b9e\u73b0\u7684\u662f\u6570\u636e\u7684\u4f20\u9001\uff0c\u628a\u6211\u4eec\u8bf4\u7684\u8bdd\u8f6c\u6362\u6210\u6a21\u62df\u4fe1\u53f7\u6216\u6570\u5b57\u4fe1\u53f7\u4f20\u9012\u7ed9\u5bf9\u65b9\uff0c\u7136\u540e\u518d\u628a\u5bf9\u65b9\u4f20\u9012\u8fc7\u6765\u7684\u4fe1\u53f7\u8fd8\u539f\u6210\u6211\u4eec\u542c\u5f97\u61c2\u7684\u8bed\u8a00\u3002\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u8003\u8651\u8fd9\u4e2a\u95ee\u9898\uff0c\u534f\u8bae\u63a5\u901a\u7684\u53d8\u5316\u4f1a\u5f15\u8d77\u8fd9\u4e2a\u63a5\u53e3\u6216\u8005\u5b9e\u73b0\u7c7b\u7684\u53d8\u5316\u5417\uff1f\u4f1a\u7684\uff01\u90a3\u6570\u636e\u4f20\u9001\uff08\u60f3\u60f3\u770b\uff0c\u7535\u8bdd\u4e0d\u4ec5\u4ec5\u53ef\u4ee5\u901a\u8bdd\uff0c\u8fd8\u53ef\u4ee5\u4e0a\u7f51\uff09\u7684\u53d8\u5316\u4f1a\u5f15\u8d77\u8fd9\u4e2a\u63a5\u53e3\u6216\u8005\u5b9e\u73b0\u7c7b\u7684\u53d8\u5316\u5417\uff1f\u4f1a\u7684\uff01\u90a3\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u8fd9\u91cc\u6709\u4e24\u4e2a\u539f\u56e0\u90fd\u5f15\u8d77\u4e86\u7c7b\u7684\u53d8\u5316\u3002\u8fd9\u4e24\u4e2a\u804c\u8d23\u4f1a\u4e92\u76f8\u5f71\u54cd\u5417\uff1f\u7535\u8bdd\u62e8\u53f7\uff0c\u6211\u53ea\u8981\u80fd\u63a5\u901a\u5c31\u884c\uff0c\u4e0d\u7ba1\u4ed6\u662f\u7535\u4fe1\u7684\u8fd8\u662f\u7f51\u901a\u3001\u79fb\u52a8\u7684\u534f\u8bae\uff1b\u7535\u8bdd\u63a5\u901a\u540e\u8fd8\u5173\u5fc3\u4f20\u9001\u7684\u662f\u4ec0\u4e48\u6570\u636e\u5417\uff1f\u901a\u8fc7\u8fd9\u6837\u7684\u5206\u6790\uff0c\u6211\u4eec\u53d1\u73b0\u7c7b\u56fe\u4e0a\u7684IPhone\u63a5\u53e3\u5305\u542b\u4e86\u4e24\u79cd\u804c\u8d23\uff0c\u800c\u4e14\u8fd9\u4e24\u79cd\u804c\u8d23\u7684\u53d8\u5316\u4e0d\u4e92\u76f8\u5f71\u54cd\uff0c\u90a3\u5c31\u8003\u8651\u5206\u6210\u4e24\u4e2a\u63a5\u53e3\uff0c\u5176\u7c7b\u56fe\u5982\u56fe1-5\u6240\u793a\u3002<\/p>\n

\n
\n \"\u8bbe\u8ba1\u539f\u5219
\n \u56fe1-5 \u804c\u8d23\u5206\u660e\u7684\u7535\u8bdd\u7c7b\u56fe
\n <\/figcaption><\/figure>\n<\/div>\n

 <\/p>\n

\u8fd9\u4e2a\u7c7b\u56fe\u770b\u8d77\u6765\u6709\u70b9\u590d\u6742\u4e86\uff0c\u5b8c\u5168\u6ee1\u8db3\u4e86\u5355\u4e00\u804c\u8d23\u539f\u5219\u7684\u8981\u6c42\uff0c\u6bcf\u4e2a\u63a5\u53e3\u804c\u8d23\u5206\u660e\uff0c\u7ed3\u6784\u6e05\u6670\uff0c\u4f46\u6211\u4eec\u5728\u8bbe\u8ba1\u7684\u65f6\u5019\u901a\u5e38\u4e0d\u4f1a\u53c2\u7528\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4e00\u4e2a\u624b\u673a\u7c7b\u8981\u628aConnectionManager\u548cDataTransfer\u7ec4\u5408\u5728\u4e00\u8d77\u624d\u80fd\u4f7f\u7528\u3002\u7ec4\u5408\u662f\u4e00\u79cd\u5f3a\u8026\u5408\u5173\u7cfb\uff0c\u4f60\u548c\u6211\u90fd\u6709\u5171\u540c\u7684\u751f\u547d\u5468\u671f\uff0c\u8fd9\u6837\u7684\u5f3a\u8026\u5408\u5173\u7cfb\u8fd8\u4e0d\u5982\u4f7f\u7528\u63a5\u53e3\u5b9e\u73b0\u7684\u65b9\u5f0f\u5462\uff0c\u800c\u4e14\u8fd8\u589e\u52a0\u4e86\u7c7b\u7684\u590d\u6742\u6027\uff0c\u591a\u4e86\u4e24\u4e2a\u7c7b\uff0c\u7ecf\u8fc7\u8fd9\u6837\u7684\u601d\u8003\uff0c\u6211\u4eec\u5728\u4fee\u6539\u4e00\u4e0b\u7c7b\u56fe\uff0c\u5982\u56fe1-6\u6240\u793a\u3002<\/p>\n

\n
\n \"\u8bbe\u8ba1\u539f\u5219
\n \u56fe1-6 \u7b80\u6d01\u6e05\u6670\u3001\u804c\u8d23\u5206\u660e\u7684\u7535\u8bdd\u7c7b\u56fe
\n <\/figcaption><\/figure>\n<\/div>\n

\u8fd9\u6837\u7684\u8bbe\u8ba1\u624d\u662f\u5b8c\u7f8e\u7684\uff0c\u4e00\u4e2a\u7c7b\u5b9e\u73b0\u4e86\u4e24\u4e2a\u63a5\u53e3\uff0c\u628a\u4e24\u4e2a\u804c\u8d23\u878d\u5408\u5728\u4e00\u4e2a\u7c7b\u4e2d\u3002\u4f60\u4f1a\u89c9\u5f97\u8fd9\u4e2aPhone\u6709\u4e24\u4e2a\u539f\u56e0\u5f15\u8d77\u53d8\u5316\u4e86\u5440\uff0c\u662f\u7684\uff0c\u4f46\u662f\u522b\u5fd8\u4e86\u6211\u4eec\u662f\u9762\u5411\u63a5\u53e3\u7f16\u7a0b\uff0c\u6211\u4eec\u5bf9\u5916\u516c\u5e03\u7684\u662f\u63a5\u53e3\u800c\u4e0d\u662f\u5b9e\u73b0\u7c7b\u3002\u800c\u4e14\uff0c\u5982\u679c\u771f\u8981\u5b9e\u73b0\u7c7b\u7684\u5355\u4e00\u804c\u8d23\uff0c\u8fd9\u4e2a\u5c31\u5fc5\u987b\u4f7f\u7528\u4e0a\u9762\u7684\u7ec4\u5408\u6a21\u5f0f\u4e86\uff0c\u8fd9\u4f1a\u5f15\u8d77\u7c7b\u95f4\u8026\u5408\u8fc7\u91cd\u3001\u7c7b\u7684\u6570\u91cf\u589e\u52a0\u7b49\u95ee\u9898\uff0c\u4eba\u4e3a\u5730\u589e\u52a0\u4e86\u8bbe\u8ba1\u7684\u590d\u6742\u6027\u3002<\/p>\n

\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\u6211\u4eec\u603b\u7ed3\u4e00\u4e0b\u5355\u4e00\u804c\u8d23\u539f\u5219\u6709\u4ec0\u4e48\u597d\u5904\uff1a<\/p>\n

    \n
  • \u7c7b\u7684\u590d\u6742\u6027\u964d\u4f4e\uff0c\u5b9e\u73b0\u4ec0\u4e48\u804c\u8d23\u90fd\u6709\u6e05\u6670\u660e\u786e\u7684\u5b9a\u4e49\uff1b<\/li>\n
  • \u53ef\u8bfb\u6027\u63d0\u9ad8\uff0c\u590d\u6742\u6027\u964d\u4f4e\uff0c\u90a3\u5f53\u7136\u53ef\u8bfb\u6027\u63d0\u9ad8\u4e86\uff1b<\/li>\n
  • \u53ef\u7ef4\u62a4\u6027\u63d0\u9ad8\uff0c\u53ef\u8bfb\u6027\u63d0\u9ad8\uff0c\u90a3\u5f53\u7136\u66f4\u5bb9\u6613\u7ef4\u62a4\uff1b<\/li>\n
  • \u53d8\u66f4\u5f15\u8d77\u7684\u98ce\u9669\u964d\u4f4e\uff0c\u53d8\u66f4\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\uff0c\u5982\u679c\u63a5\u53e3\u7684\u5355\u4e00\u804c\u8d23\u505a\u7684\u597d\uff0c\u4e00\u4e2a\u63a5\u53e3\u4fee\u6539\u53ea\u5bf9\u76f8\u5e94\u5b9e\u73b0\u7c7b\u6709\u5f71\u54cd\uff0c\u5bf9\u5176\u4ed6\u63a5\u53e3\u65e0\u5f71\u54cd\uff0c\u8fd9\u5bf9\u7cfb\u7edf\u7684\u6269\u5c55\u6027\u3001\u7ef4\u62a4\u6027\u90fd\u6709\u975e\u5e38\u5927\u7684\u5e2e\u52a9\u3002<\/li>\n<\/ul>\n

    \u770b\u8fc7\u7535\u8bdd\u8fd9\u4e2a\u4f8b\u5b50\u540e\uff0c\u662f\u4e0d\u662f\u60f3\u53cd\u601d\u4e00\u4e0b\u4e86\uff0c\u6211\u4ee5\u524d\u7684\u8bbe\u8ba1\u662f\u4e0d\u662f\u6709\u70b9\u95ee\u9898\uff1f\u4e0d\uff0c\u4e0d\u662f\u7684\uff0c\u4e0d\u8981\u6000\u7591\u81ea\u5df1\u7684\u6280\u672f\u80fd\u529b\uff0c\u5355\u4e00\u804c\u8d23\u539f\u5219\u6700\u96be\u5212\u5206\u7684\u5c31\u662f\u804c\u8d23\u3002\u4e00\u4e2a\u804c\u8d23\u4e00\u4e2a\u63a5\u53e3\uff0c\u4f46\u95ee\u9898\u662f\u804c\u8d23\u6ca1\u6709\u4e00\u4e2a\u91cf\u5316\u7684\u6807\u51c6\uff0c\u4e00\u4e2a\u7c7b\u5230\u5e95\u8981\u8d1f\u8d23\u90a3\u4e9b\u804c\u8d23\uff1f\u8fd9\u4e9b\u804c\u8d23\u8be5\u600e\u4e48\u7ec6\u5316\uff1f\u7ec6\u5316\u540e\u662f\u5426\u90fd\u8981\u6709\u4e00\u4e2a\u63a5\u53e3\u6216\u7c7b\uff1f\u8fd9\u4e9b\u90fd\u9700\u8981\u4ece\u5b9e\u9645\u7684\u9879\u76ee\u53bb\u8003\u8651\uff0c\u4ece\u529f\u80fd\u4e0a\u6765\u8bf4\uff0c\u5b9a\u4e49\u4e00\u4e2aIPhone\u7c7b\u4e5f\u6ca1\u6709\u9519\uff0c\u5b9e\u73b0\u4e86\u7535\u8bdd\u7684\u529f\u80fd\uff0c\u800c\u4e14\u8bbe\u8ba1\u8fd8\u975e\u5e38\u7b80\u5355\uff0c\u4ec5\u4ec5\u4e00\u4e2a\u63a5\u53e3\u4e0d\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u5b9e\u9645\u7684\u9879\u76ee\u6211\u60f3\u5927\u5bb6\u90fd\u4f1a\u8fd9\u4e48\u8bbe\u8ba1\u3002\u9879\u76ee\u8981\u8003\u8651\u53ef\u53d8\u56e0\u7d20\u548c\u4e0d\u53ef\u53d8\u56e0\u7d20\uff0c\u4ee5\u53ca\u76f8\u5173\u7684\u6536\u76ca\u6210\u672c\u6bd4\u7387\uff0c\u56e0\u6b64\u8bbe\u8ba1\u4e00\u4e2aIPhone\u63a5\u53e3\u4e5f\u53ef\u80fd\u662f\u6ca1\u6709\u9519\u7684\u3002\u4f46\u662f\uff0c\u5982\u679c\u7eaf\u4ece\u201c\u5b66\u7a76\u201d\u7406\u8bba\u4e0a\u5206\u6790\u5c31\u6709\u95ee\u9898\u4e86\uff0c\u6709\u4e24\u4e2a\u53ef\u4ee5\u53d8\u5316\u7684\u539f\u56e0\u653e\u5230\u4e86\u4e00\u4e2a\u63a5\u53e3\u4e2d\uff0c\u8fd9\u5c31\u4e3a\u4ee5\u540e\u7684\u53d8\u5316\u5e26\u6765\u4e86\u98ce\u9669\u5982\u679c\u4ee5\u540e\u6a21\u62df\u7535\u8bdd\u5347\u7ea7\u5230\u4e86\u6570\u5b57\u7535\u8bdd\uff0c\u6211\u4eec\u63d0\u4f9b\u7684\u63a5\u53e3IPhone\u662f\u4e0d\u662f\u8981\u4fee\u6539\u4e86\uff1f\u63a5\u53e3\u4fee\u6539\u5bf9\u5176\u4ed6\u7684Invoker\u7c7b\u662f\u4e0d\u662f\u6709\u5f88\u5927\u5f71\u54cd\uff1f<\/p>\n

    \u6ce8\u610f<\/strong>\uff1a\u5355\u4e00\u804c\u8d23\u539f\u5219\u63d0\u51fa\u4e86\u4e00\u4e2a\u7f16\u5199\u7a0b\u5e8f\u7684\u6807\u51c6\uff0c\u7528\u201c\u804c\u8d23\u201d\u6216\u201c\u53d8\u5316\u539f\u56e0\u201d\u6765\u8861\u91cf\u63a5\u53e3\u6216\u7c7b\u8bbe\u8ba1\u7684\u662f\u5426\u4f18\u826f\uff0c\u4f46\u662f\u201c\u804c\u8d23\u201d\u548c\u201c\u53d8\u5316\u539f\u56e0\u201d\u90fd\u662f\u4e0d\u53ef\u5ea6\u91cf\u7684\uff0c\u56e0\u9879\u76ee\u800c\u5f02\uff0c\u56e0\u73af\u5883\u800c\u5f02\u3002<\/em><\/p>\n

    \u5bf9\u4e8e\u63a5\u53e3\uff0c\u6211\u4eec\u5728\u8bbe\u8ba1\u7684\u65f6\u5019\u4e00\u5b9a\u8981\u505a\u5230\u5355\u4e00\uff0c\u4f46\u662f\u5bf9\u4e8e\u5b9e\u73b0\u7c7b\u5c31\u9700\u8981\u591a\u65b9\u9762\u7684\u8003\u8651\u4e86\u3002\u751f\u642c\u786c\u5957\u5355\u4e00\u804c\u8d23\u539f\u5219\u4f1a\u5f15\u8d77\u7c7b\u7684\u5267\u589e\uff0c\u7ed9\u7ef4\u62a4\u5e26\u6765\u975e\u5e38\u591a\u7684\u9ebb\u70e6\uff0c\u800c\u4e14\u8fc7\u5206\u7ec6\u5206\u7c7b\u7684\u804c\u8d23\u4e5f\u4f1a\u4eba\u4e3a\u5730\u589e\u52a0\u7cfb\u7edf\u7684\u590d\u6742\u6027\u3002\u672c\u6765\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u5b9e\u73b0\u7684\u884c\u4e3a\u786c\u8981\u62c6\u5206\u6210\u4e24\u4e2a\u7c7b\uff0c\u7136\u540e\u5728\u4f7f\u7528\u805a\u5408\u6216\u8005\u7ec4\u5408\u7684\u65b9\u5f0f\u8026\u5408\u5728\u4e00\u8d77\uff0c\u4eba\u4e3a\u5236\u9020\u4e86\u7cfb\u7edf\u7684\u590d\u6742\u6027\u3002\u6240\u4ee5\uff0c\u539f\u5219\u662f\u6b7b\u7684\uff0c\u4eba\u662f\u6d3b\u7684\uff0c\u8fd9\u53e5\u8bdd\u5f88\u6709\u9053\u7406\u3002<\/p>\n

    \u5355\u4e00\u804c\u8d23\u9002\u7528\u4e8e\u63a5\u53e3\uff0c\u7c7b\uff0c\u540c\u65f6\u4e5f\u9002\u7528\u4e8e\u65b9\u6cd5\uff0c\u4ec0\u4e48\u610f\u601d\u5462\uff1f\u4e00\u4e2a\u65b9\u6cd5\u5c3d\u53ef\u80fd\u53bb\u505a\u4e00\u4ef6\u4e8b\u60c5\uff0c\u6bd4\u5982\u4e00\u4e2a\u65b9\u6cd5\u4fee\u6539\u7528\u6237\u5bc6\u7801\uff0c\u4e0d\u8981\u628a\u8fd9\u4e2a\u65b9\u6cd5\u653e\u5728\u201c\u4fee\u6539\u7528\u6237\u4fe1\u606f\u201d\u65b9\u6cd5\u4e2d\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7684\u9897\u7c92\u5ea6\u5f88\u7c97\uff0c\u6bd4\u5982\u56fe1-7\u6240\u793a\u7684\u65b9\u6cd5\u3002<\/p>\n

    \n
    \n \"\u8bbe\u8ba1\u539f\u5219
    \n \u56fe1-7 \u4e00\u4e2a\u65b9\u6cd5\u627f\u62c5\u591a\u4e2a\u804c\u8d23
    \n <\/figcaption><\/figure>\n<\/div>\n

    \u5728IUserManager\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e2a\u65b9\u6cd5changeUser\uff0c\u6839\u636e\u4f20\u9012\u7684\u7c7b\u578b\u4e0d\u540c\uff0c\u628a\u53ef\u53d8\u957f\u5ea6\u53c2\u6570changeOptions\u4fee\u6539\u5230userBO\u8fd9\u4e2a\u5bf9\u8c61\u4e0a\uff0c\u5e76\u8c03\u7528\u6301\u4e45\u5c42\u7684\u65b9\u6cd5\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u4e2d\u3002\u8fd9\u6837\u7684\u65b9\u6cd5\uff0c\u804c\u8d23\u4e0d\u6e05\u6670\uff0c\u4e0d\u5355\u4e00\u3002\u4e0d\u8981\u8ba9\u522b\u4eba\u731c\u6d4b\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u80fd\u662f\u5904\u7406\u4ec0\u4e48\u903b\u8f91\u7684\u3002\u6bd4\u8f83\u597d\u7684\u8bbe\u8ba1\u5982\u56fe1-8\u6240\u793a\u3002<\/p>\n

    \n
    \n \"\u8bbe\u8ba1\u539f\u5219
    \n \u56fe1-8 \u4e00\u4e2a\u65b9\u6cd5\u627f\u62c5\u4e00\u4e2a\u804c\u8d23
    \n <\/figcaption><\/figure>\n<\/div>\n

    \u901a\u8fc7\u7c7b\u56fe\u53ef\u77e5\uff0c\u5982\u679c\u8981\u4fee\u6539\u7528\u6237\u540d\u79f0\uff0c\u5c31\u8981\u8c03\u7528changeUserName\u65b9\u6cd5\uff1b\u8981\u4fee\u6539\u5bb6\u5ead\u5730\u5740\uff0c\u5c31\u8c03\u7528changeHomeAddress\u65b9\u6cd5\uff1b\u8981\u4fee\u6539\u5355\u4f4d\u7535\u8bdd\uff0c\u5c31\u8c03\u7528changeOfficeTel\u65b9\u6cd5\u3002\u6bcf\u4e2a\u65b9\u6cd5\u7684\u804c\u8d23\u975e\u5e38\u6e05\u6670\u660e\u786e\uff0c\u4e0d\u4ec5\u5f00\u53d1\u7b80\u5355\uff0c\u800c\u4e14\u65e5\u540e\u7684\u7ef4\u62a4\u4e5f\u975e\u5e38\u7b80\u5355\u3002<\/p>\n

    \u9605\u8bfb\u5230\u8fd9\u91cc\uff0c\u53ef\u80fd\u6709\u4eba\u60f3\u95ee\uff0c\u5199\u7684\u662f\u7c7b\u7684\u8bbe\u8ba1\u539f\u5219\u5417\uff1f\u4f60\u901a\u7bc7\u90fd\u5728\u8bf4\u63a5\u53e3\u7684\u5355\u4e00\u804c\u8d23\uff0c\u7c7b\u7684\u5355\u4e00\u804c\u8d23\u4f60\u90fd\u8fdd\u80cc\u4e86\u5440\uff01\u8fd9\u4e2a\u8fd8\u771f\u662f\u7684\uff0c\u6211\u7684\u672c\u610f\u662f\u628a\u8fd9\u4e2a\u539f\u5219\u8bf4\u6e05\u695a\uff0c\u7c7b\u7684\u5355\u4e00\u804c\u8d23\u561b\uff0c\u8fd9\u4e2a\u5f88\u7b80\u5355\uff0c\u4f46\u5f53\u56de\u5934\u5199\u7684\u65f6\u5019\uff0c\u53d1\u89c9\u5e76\u4e0d\u662f\u8fd9\u4e48\u56de\u4e8b\uff0c\u7ffb\u770b\u4e86\u4ee5\u524d\u7684\u4ee3\u7801\u548c\u8bbe\u8ba1\uff0c\u57fa\u672c\u4e0a\u62ff\u5f97\u51fa\u624b\u7684\u7c7b\u8bbe\u8ba1\u90fd\u662f\u4e0e\u5355\u4e00\u804c\u8d23\u8fdd\u80cc\u7684\u3002\u9759\u4e0b\u5fc3\u6765\u56de\u5fc6\uff0c\u53d1\u89c9\u6bcf\u4e00\u4e2a\u7c7b\u8fd9\u6837\u8bbe\u8ba1\u90fd\u662f\u6709\u539f\u56e0\u7684\u3002Wikipedia\u3001OODesign\u7b49\u51e0\u4e2a\u7f51\u7ad9\uff0c\u4e13\u5bb6\u4e5f\u6709\u7c7b\u4f3c\u7684\u7ecf\u9a8c\uff0c\u57fa\u672c\u4e0a\u7c7b\u7684\u5355\u4e00\u804c\u8d23\u90fd\u7528\u4e86\u7c7b\u4f3c\u4e00\u53e5\u8bdd\u6765\u8bf4\u201cThis is sometimes hard to see\u201d\uff0c\u8fd9\u53e5\u8bdd\u7ffb\u8bd1\u8fc7\u6765\u5c31\u662f\u201c\u8fd9\u4e2a\u6709\u65f6\u5019\u5f88\u96be\u8bf4\u201d\u3002\u662f\u7684\uff0c\u7c7b\u7684\u5355\u4e00\u804c\u8d23\u786e\u5b9e\u53d7\u975e\u5e38\u591a\u7684\u56e0\u7d20\u5236\u7ea6\uff0c\u7eaf\u7406\u8bba\u4e0a\u6765\u8bb2\uff0c\u8fd9\u4e2a\u539f\u5219\u662f\u975e\u5e38\u4f18\u79c0\u7684\uff0c\u4f46\u73b0\u5b9e\u53c8\u73b0\u5b9e\u7684\u96be\u5904\uff0c\u4f60\u5fc5\u987b\u8003\u8651\u9879\u76ee\u7684\u5de5\u671f\u3001\u6210\u672c\u3001\u4eba\u5458\u6280\u672f\u6c34\u5e73\u3001\u786c\u4ef6\u60c5\u51b5\u3001\u7f51\u7edc\u60c5\u51b5\u751a\u81f3\u8fd8\u8981\u8003\u8651\u653f\u5e9c\u653f\u7b56\u3001\u5784\u65ad\u534f\u8bae\u7b49\u56e0\u7d20\u3002<\/p>\n

    \u5bf9\u4e8e\u5355\u4e00\u804c\u8d23\u539f\u5219\uff0c\u5efa\u8bae\u63a5\u53e3\u4e00\u5b9a\u8981\u505a\u5230\u5355\u4e00\u804c\u8d23\uff0c\u7c7b\u7684\u8bbe\u8ba1\u5c3d\u91cf\u505a\u5230\u53ea\u6709\u4e00\u4e2a\u539f\u56e0\u5f15\u8d77\u53d8\u5316\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8bbe\u8ba1\u539f\u5219 \u5355\u4e00\u804c\u8d23_\u8bbe\u8ba1\u7684\u56db\u5927\u57fa\u672c\u539f\u5219\u5355\u4e00\u804c\u8d23\u539f\u5219\u7684\u82f1\u6587\u540d\u79f0\u662fSingleResponsibilityPrinciple\uff0c\u7b80\u79f0\u662fSRP","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/4903"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=4903"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/4903\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=4903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=4903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=4903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}