{"id":862,"date":"2024-08-29T23:40:52","date_gmt":"2024-08-29T15:40:52","guid":{"rendered":"http:\/\/lingbo.online\/?p=862"},"modified":"2024-09-15T13:40:18","modified_gmt":"2024-09-15T05:40:18","slug":"simple_factory","status":"publish","type":"post","link":"https:\/\/lingbo.online\/index.php\/software_building\/design-pattern\/simple_factory\/","title":{"rendered":"[\u8bbe\u8ba1\u6a21\u5f0f]\u7b80\u5355\u5de5\u5382"},"content":{"rendered":"<h3>\u8bbe\u8ba1\u6a21\u5f0f\u2014\u2014\u7b80\u5355\u5de5\u5382<\/h3>\n<h4>\u6982\u8ff0<\/h4>\n<p>\u7b80\u5355\u5de5\u5382\uff08Simple Factory Pattern\uff09\u6a21\u5f0f\u662f\u4e00\u79cd\u521b\u5efa\u578b\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5728\u5b83\u63d0\u4f9b\u4e86\u521b\u5efa\u5bf9\u8c61\u8fc7\u7a0b\u548c\u4f7f\u7528\u5bf9\u8c61\u8fc7\u7a0b\u5206\u79bb\u7684\u80fd\u529b\uff0c\u5177\u4f53\u6765\u8bf4\uff0c\u5176\u5728\u7236\u7c7b\u4e2d\u63d0\u4f9b\u521b\u5efa\u5bf9\u8c61\u65b9\u6cd5\uff0c\u5e76\u4e14\u5728\u5b50\u7c7b\u4e2d\u5b8c\u6210\u5b9e\u4f8b\u5316\u5bf9\u8c61\u7684\u7c7b\u578b\u3002\u4e8b\u5b9e\u4e0a\uff0c\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u5e76\u4e0d\u662f\u6b63\u5f0f\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u4e5f\u6709\u4eba\u5c06\u5176\u79f0\u4e4b\u4e3a\u4e00\u79cd\u7f16\u7a0b\u4e60\u60ef\u3002\u4f46\u65e0\u53ef\u975e\u8bae\u7684\u662f\uff0c\u7b80\u5355\u5de5\u5382\u662f\u5de5\u5382\u6a21\u5f0f\u7684\u57fa\u7840\uff0c\u5b83\u4f7f\u7528\u4e00\u4e2a\u5355\u72ec\u7684\u5de5\u5382\u7c7b\u521b\u5efa\u4e0d\u540c\u7684\u5bf9\u8c61\uff0c\u5e76\u4f9d\u636e\u4f20\u5165\u7684\u53c2\u6570\u51b3\u5b9a\u521b\u5efa\u90a3\u79cd\u7c7b\u578b\u7684\u5bf9\u8c61\u3002<\/p>\n<p>\u7b80\u5355\u5de5\u5382\u9002\u7528\u4e8e\u751f\u6210\u590d\u6742\u5bf9\u8c61\u7684\u573a\u666f\uff0c\u5982\u679c\u751f\u6210\u5bf9\u8c61\u8f83\u4e3a\u7b80\u5355\uff0c\u901a\u8fc7new\u5373\u53ef\u5b8c\u6210\u521b\u5efa\uff0c\u4e0d\u5fc5\u4f7f\u7528\u5de5\u5382\u6a21\u5f0f\u3002\u5f53\u4f7f\u7528\u5de5\u5382\u6a21\u5f0f\u65f6\uff0c\u52bf\u5fc5\u9700\u8981\u5f15\u5165\u4e00\u4e2a\u5de5\u5382\u7c7b\uff0c\u7cfb\u7edf\u603b\u4f53\u590d\u6742\u5ea6\u589e\u52a0\u3002<\/p>\n<h4>\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u7ed3\u6784<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/lingbo.online\/wp-content\/uploads\/2024\/08\/1724946023-image-20240829222444945.png\" alt=\"\" \/><\/p>\n<p>\u5728\u7b80\u5355\u5de5\u5382\u4e2d\uff0c\u901a\u5e38\u5305\u542b\u4ee5\u4e0b\u89d2\u8272\uff1a<\/p>\n<ul>\n<li>\u62bd\u8c61\u4ea7\u54c1\uff08Product)\uff1a\u5b9a\u4e49\u4ea7\u54c1\u7684\u89c4\u8303\uff0c\u63cf\u8ff0\u4ea7\u54c1\u7684\u4e3b\u8981\u7279\u6027\u548c\u529f\u80fd\u3002\u4ea7\u54c1\u4f1a\u5bf9\u63a5\u53e3\u8fdb\u884c\u58f0\u660e\u3002\u5bf9\u4e8e\u6240\u6709\u7531\u521b\u5efa\u8005\u53ca\u5176\u5b50\u7c7b\u7ed3\u6784\u7684\u5bf9\u8c61\uff0c\u62bd\u8c61\u4ea7\u54c1\u63a5\u53e3\u90fd\u662f\u901a\u7528\u7684\u3002<\/li>\n<li>\u5177\u4f53\u4ea7\u54c1\uff08Concrete Products\uff09\uff1a\u5b9e\u73b0\u6216\u8005\u7ee7\u627f\u62bd\u8c61\u4ea7\u54c1\u7684\u5b50\u7c7b\uff0c\u662f\u5bf9\u4ea7\u54c1\u63a5\u53e3\u7684\u4e0d\u540c\u5b9e\u73b0<\/li>\n<li>\u521b\u5efa\u8005\uff08Creator\uff09\uff1a\u58f0\u660e\u8fd4\u56de\u4ea7\u54c1\u5bf9\u8c61\u7684\u5de5\u5382\u65b9\u6cd5\u3002\u8be5\u65b9\u6cd5\u8fd4\u56de\u7684\u5bf9\u8c61\u7c7b\u578b\u5fc5\u987b\u548c\u4ea7\u54c1\u63a5\u53e3\u76f8\u5339\u914d\u3002<\/li>\n<li>\u5177\u4f53\u5de5\u5382\uff08Concrete Creator\uff09\uff1a\u63d0\u4f9b\u521b\u5efa\u4ea7\u54c1\u7684\u65b9\u6cd5\uff0c\u8c03\u7528\u8005\u901a\u8fc7\u8be5\u65b9\u6cd5\u6765\u83b7\u53d6\u4ea7\u54c1\u3002\u5b8c\u6210\u5bf9\u57fa\u7840\u5de5\u5382\u65b9\u6cd5\u7684\u91cd\u5199\uff0c\u4f7f\u5176\u8fd4\u56de\u4e0d\u540c\u7c7b\u578b\u7684\u4ea7\u54c1\u3002<\/li>\n<\/ul>\n<h4>\u7b80\u5355\u5de5\u5382\u7684\u4f18\u7f3a\u70b9<\/h4>\n<h5>\u4f18\u70b9<\/h5>\n<ul>\n<li>\u8c03\u7528\u8005\u53ea\u9700\u8981\u77e5\u9053\u5bf9\u8c61\u7684\u540d\u79f0\u5c31\u53ef\u4ee5\u987a\u5229\u521b\u5efa\u5bf9\u8c61\uff0c\u907f\u514d\u4e86\u521b\u5efa\u8005\u548c\u5177\u4f53\u4ea7\u54c1\u4e4b\u95f4\u7684\u7d27\u5bc6\u8026\u5408<\/li>\n<li>\u7b26\u5408<strong>\u5f00\u95ed\u539f\u5219<\/strong>\uff0c\u62d3\u5c55\u6027\u80fd\u9ad8\uff0c\u5f53\u9700\u8981\u589e\u52a0\u65b0\u7684\u4ea7\u54c1\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u62d3\u5c55\u4e00\u4e2a\u5de5\u5382\u7c7b\u5c31\u53ef\u4ee5\u5b9e\u73b0<\/li>\n<li>\u5c4f\u853d\u4e86\u4ea7\u54c1\u5b9e\u73b0\u7684\u5177\u4f53\u7ec6\u8282\uff0c\u8c03\u7528\u8005\u901a\u8fc7\u8c03\u7528\u4ea7\u54c1\u7684\u63a5\u53e3\u5373\u53ef\u5b9e\u73b0\u76f8\u5173\u529f\u80fd<\/li>\n<li>\u7b26\u5408<strong>\u5355\u4e00\u804c\u8d23\u539f\u5219<\/strong>\uff0c\u53ef\u4ee5\u5c06\u4ea7\u54c1\u521b\u5efa\u4ee3\u7801\u653e\u5728\u7a0b\u5e8f\u7684\u5355\u4e00\u4f4d\u7f6e\uff0c\u4f7f\u5f97\u4ee3\u7801\u66f4\u52a0\u5bb9\u6613\u7ef4\u62a4<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9<\/h5>\n<ul>\n<li>\u5f53\u4ea7\u54c1\u589e\u52a0\u65f6\uff0c\u5fc5\u987b\u589e\u52a0\u5177\u4f53\u7684\u561e\u548c\u5bf9\u5e94\u7684\u5de5\u5382\uff0c\u9020\u6210\u7cfb\u7edf\u4e2d\u7c7b\u7684\u6570\u91cf\u6210\u500d\u589e\u52a0\uff0c\u7cfb\u7edf\u7684\u590d\u6742\u5ea6\u548c\u5177\u4f53\u7c7b\u7684\u4f9d\u8d56\u540c\u6b65\u52a0\u5927\u3002<\/li>\n<\/ul>\n<h4>\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u7684\u9002\u7528\u573a\u666f<\/h4>\n<ul>\n<li>\n<p>\u5728\u7f16\u5199\u4ee3\u7801\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u65e0\u6cd5\u9884\u77e5\u5bf9\u8c61\u786e\u5207\u7c7b\u522b\u53ca\u5176\u4f9d\u8d56\u5173\u7cfb\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5de5\u5382\u65b9\u6cd5\u3002<\/p>\n<blockquote>\n<p>\u4f8b\u5982\uff0c\u5f53\u9700\u8981\u5728\u5e94\u7528\u4e2d\u6dfb\u52a0\u67d0\u4e2a\u65b0\u4ea7\u54c1\u65f6\uff0c\u53ea\u9700\u8981\u5f00\u53d1\u65b0\u7684\u521b\u5efa\u8005\u5b50\u7c7b\uff0c\u7136\u540e\u91cd\u5199\u5176\u5de5\u5382\u65b9\u6cd5\u5373\u53ef<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>\u5982\u679c\u5e0c\u671b\u5176\u4ed6\u4eba\u53ef\u4ee5\u62d3\u5c55\u8f6f\u4ef6\u6216\u6846\u67b6\u7684\u5185\u90e8\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5de5\u5382\u65b9\u6cd5<\/p>\n<blockquote>\n<p>\u4f8b\u5982\uff0c\u5047\u8bbe\u6807\u51c6\u5e93\u4e2d\u53ea\u6709\u77e9\u5f62\uff0c\u82e5\u5e0c\u671b\u7ed8\u5236\u539f\u578b\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528RoundShape\u5b50\u7c7b\u7ee7\u627fShape\u7c7b\uff0c\u5e76\u91cd\u5199createShape\u65b9\u6cd5\uff0c\u4f7f\u5176\u8fd4\u56de\u7684\u5bf9\u8c61\u4e3aRoundShape\u3002\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86\u77e9\u5f62\u548c\u5706\u5f62\u7684\u5feb\u901f\u66ff\u4ee3\u3002<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>\u5982\u679c\u5e0c\u671b\u590d\u7528\u73b0\u6709\u5bf9\u8c61\u800c\u4e0d\u662f\u6bcf\u6b21\u521b\u5efa\u65b0\u5bf9\u8c61\u4ee5\u8282\u7701\u7cfb\u7edf\u8d44\u6e90\uff0c\u53ef\u4ee5\u4f7f\u7528\u7b80\u5355\u5de5\u5382\u65b9\u6cd5<\/p>\n<blockquote>\n<p>\u5728\u5904\u7406\u5927\u578b\u8d44\u6e90\u5bc6\u96c6\u578b\u5bf9\u8c61\uff08\u6bd4\u5982\u6570\u636e\u5e93\u8fde\u3001\u6587\u4ef6\u7cfb\u7edf\u548c\u7f51\u7edc\u8d44\u6e90\u7b49\uff09\uff0c\u9700\u8981\u4e00\u4e2a\u65e2\u80fd\u591f\u521b\u5efa\u65b0\u5bf9\u8c61\uff0c\u53c8\u53ef\u4ee5\u590d\u7528\u73b0\u6709\u5bf9\u8c61\u7684\u666e\u901a\u65b9\u6cd5\uff0c\u663e\u7136\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u975e\u5e38\u9002\u7528\u4e8e\u8fd9\u4e00\u573a\u666f\u3002<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<h4>\u5b9e\u73b0\u65b9\u5f0f<\/h4>\n<ul>\n<li>\u8ba9\u6240\u6709\u4ea7\u54c1\u90fd\u9075\u5faa\u540c\u4e00\u63a5\u53e3\uff0c\u8be5\u63a5\u53e3\u5fc5\u987b\u58f0\u660e\u5bf9\u6240\u6709\u4ea7\u54c1\u90fd\u6709\u610f\u4e49\u7684\u65b9\u6cd5<\/li>\n<li>\u5728\u521b\u5efa\u7c7b\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u7a7a\u7684\u5de5\u5382\u65b9\u6cd5\u3002\u8be5\u65b9\u6cd5\u7684\u8fd4\u56de\u7c7b\u578b\u9075\u5faa\u901a\u7528\u7684\u4ea7\u54c1\u63a5\u53e3<\/li>\n<li>\u5728\u521b\u5efa\u8005\u4ee3\u7801\u4e2d\u627e\u5230\u5bf9\u4e8e\u4ea7\u54c1\u6784\u9020\u51fd\u6570\u7684\u6240\u6709\u5f15\u7528\uff0c\u5c06\u4ed6\u4eec\u4f9d\u6b21\u66ff\u6362\u4e3a\u5bf9\u4e8e\u5de5\u5382\u65b9\u6cd5\u7684\u8c03\u7528\uff0c\u540c\u65f6\u5c06\u521b\u5efa\u4ea7\u54c1\u7684\u4ee3\u7801\u79fb\u690d\u8fdb\u5165\u5de5\u5382\u65b9\u6cd5\u3002<\/li>\n<li>\u4e3a\u5de5\u5382\u65b9\u6cd5\u7684\u6bcf\u4e2a\u4ea7\u54c1\u521b\u5efa\u4e00\u4e2a\u5b50\u7c7b\uff0c\u7136\u540e\u5728\u5b50\u7c7b\u4e2d\u91cd\u5199\u5de5\u5382\u65b9\u6cd5\uff0c\u5c06\u57fa\u672c\u65b9\u6cd5\u4e2d\u7684\u76f8\u5173\u521b\u5efa\u4ee3\u7801\u79fb\u52a8\u5230\u5de5\u5382\u65b9\u6cd5\u4e2d<\/li>\n<\/ul>\n<h4>\u5e94\u7528\u573a\u666f<\/h4>\n<ul>\n<li>\u65e5\u5fd7\u8bb0\u5f55\uff1a\u65e5\u5fd7\u53ef\u80fd\u8bb0\u5f55\u5230\u672c\u5730\u786c\u76d8\u3001\u7cfb\u7edf\u4e8b\u4ef6\u3001\u8fdc\u7a0b\u670d\u52a1\u5668\u7b49<\/li>\n<li>\u6570\u636e\u5e93\u8bbf\u95ee\uff1a\u5f53\u7528\u6237\u4e0d\u77e5\u9053\u7cfb\u7edf\u6700\u7ec8\u4f7f\u7528\u54ea\u79cd\u6570\u636e\u5e93\uff0c\u6216\u4f7f\u7528\u7684\u6570\u636e\u5e93\u53ef\u80fd\u53d1\u751f\u53d8\u5316\u65f6<\/li>\n<li>\u8fde\u63a5\u670d\u52a1\u5668\u7684\u6846\u67b6\u8bbe\u8ba1\uff1a\u9700\u8981\u652f\u6301\u201cPOP3&quot;\u3001&quot;IMAP&quot;\u3001&quot;HTTP&quot;\u4e09\u79cd\u534f\u8bae\uff0c\u53ef\u4ee5\u5c06\u8fd9\u4e09\u79cd\u534f\u8bae\u4f5c\u4e3a\u4ea7\u54c1\u7c7b\uff0c\u5171\u540c\u5b9e\u73b0\u4e00\u4e2a\u63a5\u53e3\u3002<\/li>\n<\/ul>\n<h4>\u4e0e\u5176\u4ed6\u8bbe\u8ba1\u6a21\u5f0f\u7684\u5173\u7cfb<\/h4>\n<ul>\n<li>\u8bb8\u591a\u8bbe\u8ba1\u5de5\u4f5c\u7684\u521d\u671f\u90fd\u4f1a\u91c7\u7528\u7b80\u5355\u5de5\u5382\uff08\u8f83\u4e3a\u7b80\u5355\uff0c\u53ef\u4ee5\u65b9\u4fbf\u7684\u901a\u8fc7\u5b50\u7c7b\u8fdb\u884c\u5b9a\u5236\uff09\uff0c\u968f\u540e\u6f14\u5316\u4e3a\u4f7f\u7528\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f\u3001\u539f\u578b\u6a21\u5f0f\u548c\u751f\u6210\u5668\u6a21\u5f0f\uff08\u66f4\u7075\u6d3b\u4f46\u662f\u66f4\u590d\u6742\uff09<\/li>\n<li>\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f\u901a\u5e38\u57fa\u4e8e\u4e00\u7ec4\u7b80\u5355\u5de5\u5382\u65b9\u6cd5\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u4f7f\u7528\u539f\u578b\u6a21\u5f0f\u6765\u751f\u6210\u8fd9\u4e9b\u7c7b\u7684\u65b9\u6cd5\u3002<\/li>\n<li>\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u7b80\u5355\u5de5\u5382\u548c\u8fed\u4ee3\u5668\u6a21\u5f0f\uff0c\u8ba9\u5b50\u7c7b\u96c6\u5408\u8fd4\u56de\u4e0d\u540c\u7c7b\u578b\u7684\u8fed\u4ee3\u5668<\/li>\n<li>\u539f\u578b\u5e76\u4e0d\u57fa\u4e8e\u7ee7\u627f\uff0c\u6ca1\u6709\u7ee7\u627f\u7684\u7f3a\u70b9\uff0c\u4f46\u662f\u9700\u8981\u5bf9\u88ab\u590d\u5236\u5bf9\u8c61\u8fdb\u884c\u590d\u6742\u7684\u521d\u59cb\u5316\u3002\u7b80\u5355\u5de5\u5382\u57fa\u4e8e\u7ee7\u627f\uff0c\u4f46\u662f\u5176\u4e0d\u9700\u8981\u8fdb\u884c\u521d\u59cb\u5316\u6b65<\/li>\n<\/ul>\n<h4>\u4ee3\u7801\u6846\u67b6<\/h4>\n<pre><code class=\"language-python\">from __future__ import annotations\nfrom abc import ABC,abstractmethod\n\nclass Creator(ABC):\n    @abstractmethod\n    def factory_method(self):\n        pass\n\n    def some_operation(self):\n        product = self.factory_method()\n        result = f&quot;Creator: The same creator&#039;s code has just worked with {product.operation()}&quot;\n        return result\n\nclass ConcreteCreator1(Creator):\n    def factory_method(self):\n        return ConcreteProduct1()\n\nclass ConcreteCreator2(Creator):\n    def factory_method(self) -&gt; Product:\n        return ConcreteProduct2()\n\nclass Product(ABC):\n    def operation(self):\n        pass\n\nclass ConcreteProduct1(Product):\n    def operation(self) -&gt; str:\n        return &quot;{Result of the ConcreteProduct1}&quot;\n\nclass ConcreteProduct2(Product):\n    def operation(self) -&gt; str:\n        return &quot;{Result of the ConcreteProduct2}&quot;\n\ndef client_code(creator):\n    print(f&quot;Client: I&#039;m not aware of the creator&#039;s class, but it still works.\\n&quot;\n          f&quot;{creator.some_operation()}&quot;, end=&quot;&quot;)\n\nif __name__ == &quot;__main__&quot;:\n    print(&quot;App: Launched with the ConcreteCreator1.&quot;)\n    client_code(ConcreteCreator1())\n    print(&quot;\\n&quot;)\n\n    print(&quot;App: Launched with the ConcreteCreator2.&quot;)\n    client_code(ConcreteCreator2())<\/code><\/pre>\n<h4>\u4ee3\u7801\u793a\u4f8b<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/lingbo.online\/wp-content\/uploads\/2024\/08\/1724946041-image-20240829232459979.png\" alt=\"\" \/><\/p>\n<pre><code class=\"language-python\"># \u62bd\u8c61\u4ea7\u54c1\nclass BaseOperate:\n\n    def __init__(self):\n        self.result = 0\n\n    def get_result(self):\n        return self.result\n\n# \u5177\u4f53\u4ea7\u54c1\nclass OperationAdd(BaseOperate):\n    def __init__(self, num1, num2):\n        self.result = num1 + num2\n\n    def get_result(self):\n        return self.result\n\nclass OperationDiv(BaseOperate):\n    def __init__(self, num1, num2):\n        self.result = num1 \/ num2\n\n    def get_result(self):\n        return self.result\n\nclass OperationSub(BaseOperate):\n    def __init__(self, num1, num2):\n        self.result = num1 - num2\n\n    def get_result(self):\n        return self.result\n\nclass OperationMult(BaseOperate):\n    def __init__(self, num1, num2):\n        self.result = num1 * num2\n\n    def get_result(self):\n        return self.result\n\n# \u7b80\u5355\u5de5\u5382\nclass OperationFactory:\n    @staticmethod\n    def createOperate(operate, num1, num2):\n        optdict = {\n            &#039;+&#039;: OperationAdd,\n            &#039;-&#039;: OperationSub,\n            &#039;*&#039;: OperationMult,\n            &#039;\/&#039;: OperationSub\n        }\n        oper = BaseOperate()\n        if (operate in optdict):\n            oper = optdict[operate](num1, num2)\n        return oper\n\n# \u521b\u5efa\u8005\ndef clientUI():\n    opt = input(&quot;please input a operation&quot;)\n    num1 = int(input(&quot;please input a number&quot;))\n    num2 = int(input(&quot;please input a number&quot;))\n    oper = OperationFactory.createOperate(opt, num1, num2)\n    print(oper.get_result())\n    return\n\nif __name__ == &#039;__main__&#039;:\n    clientUI()<\/code><\/pre>\n<h4>\u53c2\u8003\u94fe\u63a5<\/h4>\n<ol>\n<li><a href=\"https:\/\/m.runoob.com\/design-pattern\/factory-pattern.html\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/m.runoob.com\/design-pattern\/factory-pattern.html<\/a><\/li>\n<li><a href=\"https:\/\/refactoringguru.cn\/design-patterns\/factory-method\/python\/example\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/refactoringguru.cn\/design-patterns\/factory-method\/python\/example<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/m0_62410482\/article\/details\/129989726\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/blog.csdn.net\/m0_62410482\/article\/details\/129989726<\/a><\/li>\n<li><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/671426189\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/zhuanlan.zhihu.com\/p\/671426189<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u8bbe\u8ba1\u6a21\u5f0f\u2014\u2014\u7b80\u5355\u5de5\u5382 \u6982\u8ff0 \u7b80\u5355\u5de5\u5382\uff08Simple Factory Pattern\uff09\u6a21\u5f0f\u662f\u4e00\u79cd\u521b\u5efa\u578b\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5728\u5b83\u63d0\u4f9b\u4e86\u521b\u5efa\u5bf9\u8c61\u8fc7 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":876,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[47],"tags":[],"class_list":["post-862","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-design-pattern"],"_links":{"self":[{"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/posts\/862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/comments?post=862"}],"version-history":[{"count":1,"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"predecessor-version":[{"id":865,"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/posts\/862\/revisions\/865"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/media\/876"}],"wp:attachment":[{"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lingbo.online\/index.php\/wp-json\/wp\/v2\/tags?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}