{"id":105,"date":"2008-03-04T16:25:40","date_gmt":"2008-03-04T16:25:40","guid":{"rendered":""},"modified":"2008-03-04T16:25:40","modified_gmt":"2008-03-04T16:25:40","slug":"105","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=105","title":{"rendered":"\u4eab\u5143\u6a21\u5f0f(Flyweight Pattern)"},"content":{"rendered":"<p>\u4e00\u3001 \u4eab\u5143\uff08Flyweight\uff09\u6a21\u5f0f<br \/>Flyweight\u5728\u62f3\u51fb\u6bd4\u8d5b\u4e2d\u6307\u6700\u8f7b\u91cf\u7ea7\uff0c\u5373&#8221;\u8747\u91cf\u7ea7&#8221;\uff0c\u6709\u4e9b\u4f5c\u8005\u7ffb\u8bd1\u4e3a&#8221;\u7fbd\u91cf\u7ea7&#8221;\u3002\u8fd9\u91cc\u4f7f\u7528&#8221;\u4eab\u5143\u6a21\u5f0f&#8221;\u66f4\u80fd\u53cd\u6620\u6a21\u5f0f\u7684\u7528\u610f\u3002<\/p>\n<p>\u4eab\u5143\u6a21\u5f0f\u4ee5\u5171\u4eab\u7684\u65b9\u5f0f\u9ad8\u6548\u5730\u652f\u6301\u5927\u91cf\u7684\u7ec6\u7c92\u5ea6\u5bf9\u8c61\u3002\u4eab\u5143\u5bf9\u8c61\u80fd\u505a\u5230\u5171\u4eab\u7684\u5173\u952e\u662f\u533a\u5206\u5185\u8574\u72b6\u6001\uff08Internal State\uff09\u548c\u5916\u8574\u72b6\u6001\uff08External State\uff09\u3002\u5185\u8574\u72b6\u6001\u662f\u5b58\u50a8\u5728\u4eab\u5143\u5bf9\u8c61\u5185\u90e8\u5e76\u4e14\u4e0d\u4f1a\u968f\u73af\u5883\u6539\u53d8\u800c\u6539\u53d8\u3002\u56e0\u6b64\u5185\u8574\u72b6\u6001\u5e76\u53ef\u4ee5\u5171\u4eab\u3002<\/p>\n<p>\u5916\u8574\u72b6\u6001\u662f\u968f\u73af\u5883\u6539\u53d8\u800c\u6539\u53d8\u7684\u3001\u4e0d\u53ef\u4ee5\u5171\u4eab\u7684\u72b6\u6001\u3002\u4eab\u5143\u5bf9\u8c61\u7684\u5916\u8574\u72b6\u6001\u5fc5\u987b\u7531\u5ba2\u6237\u7aef\u4fdd\u5b58\uff0c\u5e76\u5728\u4eab\u5143\u5bf9\u8c61\u88ab\u521b\u5efa\u4e4b\u540e\uff0c\u5728\u9700\u8981\u4f7f\u7528\u7684\u65f6\u5019\u518d\u4f20\u5165\u5230\u4eab\u5143\u5bf9\u8c61\u5185\u90e8\u3002\u5916\u8574\u72b6\u6001\u4e0e\u5185\u8574\u72b6\u6001\u662f\u76f8\u4e92\u72ec\u7acb\u7684\u3002<\/p>\n<p>\u4eab\u5143\u6a21\u5f0f\u7684\u5e94\u7528<\/p>\n<p>\u4eab\u5143\u6a21\u5f0f\u5728\u7f16\u8f91\u5668\u7cfb\u7edf\u4e2d\u5927\u91cf\u4f7f\u7528\u3002\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5f80\u5f80\u4f1a\u63d0\u4f9b\u5f88\u591a\u79cd\u5b57\u4f53\uff0c\u800c\u901a\u5e38\u7684\u505a\u6cd5\u5c31\u662f\u5c06\u6bcf\u4e00\u4e2a\u5b57\u6bcd\u505a\u6210\u4e00\u4e2a\u4eab\u5143\u5bf9\u8c61\u3002\u4eab\u5143\u5bf9\u8c61\u7684\u5185\u8574\u72b6\u6001\u5c31\u662f\u8fd9\u4e2a\u5b57\u6bcd\uff0c\u800c\u5b57\u6bcd\u5728\u6587\u672c\u4e2d\u7684\u4f4d\u7f6e\u548c\u5b57\u6a21\u98ce\u683c\u7b49\u5176\u4ed6\u4fe1\u606f\u5219\u662f\u5916\u8574\u72b6\u6001\u3002\u6bd4\u5982\uff0c\u5b57\u6bcda\u53ef\u80fd\u51fa\u73b0\u5728\u6587\u672c\u7684\u5f88\u591a\u5730\u65b9\uff0c\u867d\u7136\u8fd9\u4e9b\u5b57\u6bcda\u7684\u4f4d\u7f6e\u548c\u5b57\u6a21\u98ce\u683c\u4e0d\u540c\uff0c\u4f46\u662f\u6240\u6709\u8fd9\u4e9b\u5730\u65b9\u4f7f\u7528\u7684\u90fd\u662f\u540c\u4e00\u4e2a\u5b57\u6bcd\u5bf9\u8c61\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u5b57\u6bcd\u5bf9\u8c61\u5c31\u53ef\u4ee5\u5728\u6574\u4e2a\u7cfb\u7edf\u4e2d\u5171\u4eab\u3002<\/p>\n<p>\u4e8c\u3001 \u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u7684\u7ed3\u6784<br \/><img decoding=\"async\" src=\"http:\/\/www.poloo.org\/wp-content\/attachments\/month_0803\/k200834162336.gif\" \/><br \/>\u5728\u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u4e2d\uff0c\u6240\u6709\u7684\u4eab\u5143\u5bf9\u8c61\u90fd\u662f\u53ef\u4ee5\u5171\u4eab\u7684\u3002\u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u6240\u6d89\u53ca\u7684\u89d2\u8272\u5982\u4e0b\uff1a<\/p>\n<p>\u62bd\u8c61\u4eab\u5143(Flyweight)\u89d2\u8272\uff1a\u6b64\u89d2\u8272\u662f\u6240\u6709\u7684\u5177\u4f53\u4eab\u5143\u7c7b\u7684\u8d85\u7c7b\uff0c\u4e3a\u8fd9\u4e9b\u7c7b\u89c4\u5b9a\u51fa\u9700\u8981\u5b9e\u73b0\u7684\u516c\u5171\u63a5\u53e3\u3002\u90a3\u4e9b\u9700\u8981\u5916\u8574\u72b6\u6001(External State)\u7684\u64cd\u4f5c\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u5546\u4e1a\u65b9\u6cd5\u4ee5\u53c2\u6570\u5f62\u5f0f\u4f20\u5165\u3002<\/p>\n<p>\u5177\u4f53\u4eab\u5143(ConcreteFlyweight)\u89d2\u8272\uff1a\u5b9e\u73b0\u62bd\u8c61\u4eab\u5143\u89d2\u8272\u6240\u89c4\u5b9a\u7684\u63a5\u53e3\u3002\u5982\u679c\u6709\u5185\u8574\u72b6\u6001\u7684\u8bdd\uff0c\u5fc5\u987b\u8d1f\u8d23\u4e3a\u5185\u8574\u72b6\u6001\u63d0\u4f9b\u5b58\u50a8\u7a7a\u95f4\u3002\u4eab\u5143\u5bf9\u8c61\u7684\u5185\u8574\u72b6\u6001\u5fc5\u987b\u4e0e\u5bf9\u8c61\u6240\u5904\u7684\u5468\u56f4\u73af\u5883\u65e0\u5173\uff0c\u4ece\u800c\u4f7f\u5f97\u4eab\u5143\u5bf9\u8c61\u53ef\u4ee5\u5728\u7cfb\u7edf\u5185\u5171\u4eab\u7684\u3002<\/p>\n<p>\u4eab\u5143\u5de5\u5382(FlyweightFactory)\u89d2\u8272\uff1a\u672c\u89d2\u8272\u8d1f\u8d23\u521b\u5efa\u548c\u7ba1\u7406\u4eab\u5143\u89d2\u8272\u3002\u672c\u89d2\u8272\u5fc5\u987b\u4fdd\u8bc1\u4eab\u5143\u5bf9\u8c61\u53ef\u4ee5\u88ab\u7cfb\u7edf\u9002\u5f53\u5730\u5171\u4eab\u3002\u5f53\u4e00\u4e2a\u5ba2\u6237\u7aef\u5bf9\u8c61\u8c03\u7528\u4e00\u4e2a\u4eab\u5143\u5bf9\u8c61\u7684\u65f6\u5019\uff0c\u4eab\u5143\u5de5\u5382\u89d2\u8272\u4f1a\u68c0\u67e5\u7cfb\u7edf\u4e2d\u662f\u5426\u5df2\u7ecf\u6709\u4e00\u4e2a\u590d\u5408\u8981\u6c42\u7684\u4eab\u5143\u5bf9\u8c61\u3002\u5982\u679c\u5df2\u7ecf\u6709\u4e86\uff0c\u4eab\u5143\u5de5\u5382\u89d2\u8272\u5c31\u5e94\u5f53\u63d0\u4f9b\u8fd9\u4e2a\u5df2\u6709\u7684\u4eab\u5143\u5bf9\u8c61\uff1b\u5982\u679c\u7cfb\u7edf\u4e2d\u6ca1\u6709\u4e00\u4e2a\u9002\u5f53\u7684\u4eab\u5143\u5bf9\u8c61\u7684\u8bdd\uff0c\u4eab\u5143\u5de5\u5382\u89d2\u8272\u5c31\u5e94\u5f53\u521b\u5efa\u4e00\u4e2a\u5408\u9002\u7684\u4eab\u5143\u5bf9\u8c61\u3002<\/p>\n<p>\u5ba2\u6237\u7aef(Client)\u89d2\u8272\uff1a\u672c\u89d2\u8272\u9700\u8981\u7ef4\u62a4\u4e00\u4e2a\u5bf9\u6240\u6709\u4eab\u5143\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u672c\u89d2\u8272\u9700\u8981\u81ea\u884c\u5b58\u50a8\u6240\u6709\u4eab\u5143\u5bf9\u8c61\u7684\u5916\u8574\u72b6\u6001\u3002<\/p>\n<p>\u4e09\u3001 \u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u7684\u793a\u610f\u6027\u6e90\u4ee3\u7801<\/p>\n<p><code>\/\/ Flyweight pattern -- Structural example&nbsp;&nbsp;<br \/>using System;<br \/>using System.Collections;<\/p>\n<p>\/\/ \"FlyweightFactory\"<br \/>class FlyweightFactory<br \/>{<br \/>&nbsp;&nbsp;\/\/ Fields<br \/>&nbsp;&nbsp;private Hashtable flyweights = new Hashtable();<\/p>\n<p>&nbsp;&nbsp;\/\/ Constructors<br \/>&nbsp;&nbsp;public FlyweightFactory()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;flyweights.Add(\"X\", new ConcreteFlyweight());<br \/>&nbsp;&nbsp;&nbsp;&nbsp;flyweights.Add(\"Y\", new ConcreteFlyweight());<br \/>&nbsp;&nbsp;&nbsp;&nbsp;flyweights.Add(\"Z\", new ConcreteFlyweight());<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;public Flyweight GetFlyweight(string key)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return((Flyweight)flyweights[ key ]);<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ \"Flyweight\"<br \/>abstract class Flyweight<br \/>{<br \/>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;abstract public void Operation( int extrinsicstate );<br \/>}<\/p>\n<p>\/\/ \"ConcreteFlyweight\"<br \/>class ConcreteFlyweight : Flyweight<br \/>{<br \/>&nbsp;&nbsp;private string intrinsicstate = \"A\";<br \/>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;override public void Operation( int extrinsicstate )<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"ConcreteFlyweight: intrinsicstate {0}, extrinsicstate {1}\", <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;intrinsicstate, extrinsicstate );<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/**\/\/\/\/ &lt;summary&gt;<br \/>\/\/\/ Client test<br \/>\/\/\/ &lt;\/summary&gt;<br \/>public class Client<br \/>{<br \/>&nbsp;&nbsp;public static void Main( string[] args )<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Arbitrary extrisic state<br \/>&nbsp;&nbsp;&nbsp;&nbsp;int extrinsicstate = 22;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;FlyweightFactory f = new FlyweightFactory();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Work with different flyweight instances<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Flyweight fx = f.GetFlyweight(\"X\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;fx.Operation( --extrinsicstate );<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Flyweight fy = f.GetFlyweight(\"Y\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;fy.Operation( --extrinsicstate );<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Flyweight fz = f.GetFlyweight(\"Z\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;fz.Operation( --extrinsicstate );<br \/>&nbsp;&nbsp;}<br \/>}<br \/><\/code><\/p>\n<p>\u56db\u3001 \u590d\u5408\u4eab\u5143\u6a21\u5f0f\u7684\u7ed3\u6784<br \/>\u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u4e2d\uff0c\u6240\u6709\u7684\u4eab\u5143\u5bf9\u8c61\u90fd\u53ef\u4ee5\u76f4\u63a5\u5171\u4eab\u3002\u4e0b\u9762\u8003\u8651\u4e00\u4e2a\u8f83\u4e3a\u590d\u6742\u7684\u60c5\u51b5\uff0c\u5373\u5c06\u4e00\u4e9b\u5355\u7eaf\u4eab\u5143\u4f7f\u7528\u5408\u6210\u6a21\u5f0f\u52a0\u4ee5\u590d\u5408\uff0c\u5f62\u6210\u590d\u5408\u4eab\u5143\u5bf9\u8c61\u3002\u8fd9\u6837\u7684\u590d\u5408\u4eab\u5143\u5bf9\u8c61\u672c\u8eab\u4e0d\u80fd\u5171\u4eab\uff0c\u4f46\u662f\u5b83\u4eec\u53ef\u4ee5\u5206\u89e3\u6210\u5355\u7eaf\u4eab\u5143\u5bf9\u8c61\uff0c\u800c\u540e\u8005\u5219\u53ef\u4ee5\u5171\u4eab\u3002<\/p>\n<p>\u590d\u5408\u4eab\u5143\u6a21\u5f0f\u7684\u7c7b\u56fe\u5982\u4e0b\u56fe\u6240\u793a\uff1a<br \/><img decoding=\"async\" src=\"http:\/\/www.poloo.org\/wp-content\/attachments\/month_0803\/s200834162416.gif\" \/><br \/>\u4eab\u5143\u6a21\u5f0f\u6240\u6d89\u53ca\u7684\u89d2\u8272\u6709\u62bd\u8c61\u4eab\u5143\u89d2\u8272\u3001\u5177\u4f53\u4eab\u5143\u89d2\u8272\u3001\u590d\u5408\u4eab\u5143\u89d2\u8272\u3001\u4eab\u5458\u5de5\u5382\u89d2\u8272\uff0c\u4ee5\u53ca\u5ba2\u6237\u7aef\u89d2\u8272\u7b49\u3002<\/p>\n<p>\u62bd\u8c61\u4eab\u5143\u89d2\u8272\uff1a\u6b64\u89d2\u8272\u662f\u6240\u6709\u7684\u5177\u4f53\u4eab\u5143\u7c7b\u7684\u8d85\u7c7b\uff0c\u4e3a\u8fd9\u4e9b\u7c7b\u89c4\u5b9a\u51fa\u9700\u8981\u5b9e\u73b0\u7684\u516c\u5171\u63a5\u53e3\u3002\u90a3\u4e9b\u9700\u8981\u5916\u8574\u72b6\u6001(External State)\u7684\u64cd\u4f5c\u53ef\u4ee5\u901a\u8fc7\u65b9\u6cd5\u7684\u53c2\u6570\u4f20\u5165\u3002\u62bd\u8c61\u4eab\u5143\u7684\u63a5\u53e3\u4f7f\u5f97\u4eab\u5143\u53d8\u5f97\u53ef\u80fd\uff0c\u4f46\u662f\u5e76\u4e0d\u5f3a\u5236\u5b50\u7c7b\u5b9e\u884c\u5171\u4eab\uff0c\u56e0\u6b64\u5e76\u975e\u6240\u6709\u7684\u4eab\u5143\u5bf9\u8c61\u90fd\u662f\u53ef\u4ee5\u5171\u4eab\u7684\u3002<\/p>\n<p>\u5177\u4f53\u4eab\u5143(ConcreteFlyweight)\u89d2\u8272\uff1a\u5b9e\u73b0\u62bd\u8c61\u4eab\u5143\u89d2\u8272\u6240\u89c4\u5b9a\u7684\u63a5\u53e3\u3002\u5982\u679c\u6709\u5185\u8574\u72b6\u6001\u7684\u8bdd\uff0c\u5fc5\u987b\u8d1f\u8d23\u4e3a\u5185\u8574\u72b6\u6001\u63d0\u4f9b\u5b58\u50a8\u7a7a\u95f4\u3002\u4eab\u5143\u5bf9\u8c61\u7684\u5185\u8574\u72b6\u6001\u5fc5\u987b\u4e0e\u5bf9\u8c61\u6240\u5904\u7684\u5468\u56f4\u73af\u5883\u65e0\u5173\uff0c\u4ece\u800c\u4f7f\u5f97\u4eab\u5143\u5bf9\u8c61\u53ef\u4ee5\u5728\u7cfb\u7edf\u5185\u5171\u4eab\u3002\u6709\u65f6\u5019\u5177\u4f53\u4eab\u5143\u89d2\u8272\u53c8\u53eb\u505a\u5355\u7eaf\u5177\u4f53\u4eab\u5143\u89d2\u8272\uff0c\u56e0\u4e3a\u590d\u5408\u4eab\u5143\u89d2\u8272\u662f\u7531\u5355\u7eaf\u5177\u4f53\u4eab\u5143\u89d2\u8272\u901a\u8fc7\u590d\u5408\u800c\u6210\u7684\u3002<\/p>\n<p>\u590d\u5408\u4eab\u5143(UnsharableFlyweight)\u89d2\u8272\uff1a\u590d\u5408\u4eab\u5143\u89d2\u8272\u6240\u4ee3\u8868\u7684\u5bf9\u8c61\u662f\u4e0d\u53ef\u4ee5\u5171\u4eab\u7684\uff0c\u4f46\u662f\u4e00\u4e2a\u590d\u5408\u4eab\u5143\u5bf9\u8c61\u53ef\u4ee5\u5206\u89e3\u6210\u4e3a\u591a\u4e2a\u672c\u8eab\u662f\u5355\u7eaf\u4eab\u5143\u5bf9\u8c61\u7684\u7ec4\u5408\u3002\u590d\u5408\u4eab\u5143\u89d2\u8272\u53c8\u79f0\u505a\u4e0d\u53ef\u5171\u4eab\u7684\u4eab\u5143\u5bf9\u8c61\u3002<\/p>\n<p>\u4eab\u5143\u5de5\u5382(FlyweightFactoiy)\u89d2\u8272\uff1a\u672c\u89d2\u8272\u8d1f\u8d23\u521b\u5efa\u548c\u7ba1\u7406\u4eab\u5143\u89d2\u8272\u3002\u672c\u89d2\u8272\u5fc5\u987b\u4fdd\u8bc1\u4eab\u5143\u5bf9\u8c61\u53ef\u4ee5\u88ab\u7cfb\u7edf\u9002\u5f53\u5730\u5171\u4eab\u3002\u5f53\u4e00\u4e2a\u5ba2\u6237\u7aef\u5bf9\u8c61\u8bf7\u6c42\u4e00\u4e2a\u4eab\u5143\u5bf9\u8c61\u7684\u65f6\u5019\uff0c\u4eab\u5143\u5de5\u5382\u89d2\u8272\u9700\u8981\u68c0\u67e5\u7cfb\u7edf\u4e2d\u662f\u5426\u5df2\u7ecf\u6709\u4e00\u4e2a\u7b26\u5408\u8981\u6c42\u7684\u4eab\u5143\u5bf9\u8c61\uff0c\u5982\u679c\u5df2\u7ecf\u6709\u4e86\uff0c\u4eab\u5143\u5de5\u5382\u89d2\u8272\u5c31\u5e94\u5f53\u63d0\u4f9b\u8fd9\u4e2a\u5df2\u6709\u7684\u4eab\u5143\u5bf9\u8c61\uff1b\u5982\u679c\u7cfb\u7edf\u4e2d\u6ca1\u6709\u4e00\u4e2a\u9002\u5f53\u7684\u4eab\u5143\u5bf9\u8c61\u7684\u8bdd\uff0c\u4eab\u5143\u5de5\u5382\u89d2\u8272\u5c31\u5e94\u5f53\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5408\u9002\u7684\u4eab\u5143\u5bf9\u8c61\u3002<\/p>\n<p>\u5ba2\u6237\u7aef(Client)\u89d2\u8272\uff1a\u672c\u89d2\u8272\u8fd8\u9700\u8981\u81ea\u884c\u5b58\u50a8\u6240\u6709\u4eab\u5143\u5bf9\u8c61\u7684\u5916\u8574\u72b6\u6001\u3002<\/p>\n<p>\u6ce8\uff1a\u7531\u4e8e\u590d\u5408\u4eab\u5143\u6a21\u5f0f\u6bd4\u8f83\u590d\u6742\uff0c\u8fd9\u91cc\u5c31\u4e0d\u518d\u7ed9\u51fa\u793a\u610f\u6027\u4ee3\u7801\u3002\u901a\u8fc7\u5c06\u4eab\u5143\u6a21\u5f0f\u4e0e\u5408\u6210\u6a21\u5f0f\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u53ef\u4ee5\u786e\u4fdd\u590d\u5408\u4eab\u5143\u4e2d\u6240\u5305\u542b\u7684\u6bcf\u4e2a\u5355\u7eaf\u4eab\u5143\u90fd\u5177\u6709\u76f8\u540c\u7684\u5916\u8574\u72b6\u6001\uff0c\u800c\u8fd9\u4e9b\u5355\u7eaf\u4eab\u5143\u7684\u5185\u8574\u72b6\u6001\u5f80\u5f80\u4e0d\u540c\u3002\u8be5\u90e8\u5206\u5185\u5bb9\u53ef\u4ee5\u53c2\u8003\u300aJava\u4e0e\u6a21\u5f0f\u300b\u7b2c31\u7ae0\u5185\u5bb9\u3002<\/p>\n<p>\u4e94\u3001 \u4e00\u4e2a\u5496\u5561\u644a\u7684\u4f8b\u5b50<br \/>\u5728\u8fd9\u4e2a\u5496\u5561\u644a(Coffee Stall)\u6240\u4f7f\u7528\u7684\u7cfb\u7edf\u91cc\uff0c\u6709\u4e00\u7cfb\u5217\u7684\u5496\u5561&#8221;\u98ce\u5473(Flavor)&#8221;\u3002\u5ba2\u4eba\u5230\u644a\u4f4d\u4e0a\u8d2d\u4e70\u5496\u5561\uff0c\u6240\u6709\u7684\u5496\u5561\u5747\u653e\u5728\u53f0\u5b50\u4e0a\uff0c\u5ba2\u4eba\u81ea\u5df1\u62ff\u5230\u5496\u5561\u540e\u5c31\u79bb\u5f00\u644a\u4f4d\u3002\u5496\u5561\u6709\u5185\u8574\u72b6\u6001\uff0c\u4e5f\u5c31\u662f\u5496\u5561\u7684\u98ce\u5473\uff1b\u5496\u5561\u6ca1\u6709\u73af\u5883\u56e0\u7d20\uff0c\u4e5f\u5c31\u662f\u8bf4\u6ca1\u6709\u5916\u8574\u72b6\u6001\u3002\u5982\u679c\u7cfb\u7edf\u4e3a\u6bcf\u4e00\u676f\u5496\u5561\u90fd\u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684\u5bf9\u8c61\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u521b\u5efa\u51fa\u5f88\u591a\u7684\u7ec6\u5c0f\u5bf9\u8c61\u6765\u3002\u8fd9\u6837\u5c31\u4e0d\u5982\u628a\u5496\u5561\u6309\u7167\u79cd\u7c7b(\u5373&#8221;\u98ce\u5473&#8221;)\u5212\u5206\uff0c\u6bcf\u4e00\u79cd\u98ce\u5473\u7684\u5496\u5561\u53ea\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5e76\u5b9e\u884c\u5171\u4eab\u3002<\/p>\n<p>\u4f7f\u7528\u5496\u5561\u644a\u4e3b\u7684\u8bed\u8a00\u6765\u8bb2\uff0c\u6240\u6709\u7684\u5496\u5561\u90fd\u53ef\u6309&#8221;\u98ce\u5473&#8221;\u5212\u5206\u6210\u5982Capucino\u3001Espresso\u7b49\uff0c\u6bcf\u4e00\u79cd\u98ce\u5473\u7684\u5496\u5561\u4e0d\u8bba\u5356\u51fa\u591a\u5c11\u676f\uff0c\u90fd\u662f\u5168\u540c\u3001\u4e0d\u53ef\u5206\u8fa8\u7684\u3002\u6240\u8c13\u5171\u4eab\uff0c\u5c31\u662f\u5496\u5561\u98ce\u5473\u7684\u5171\u4eab\uff0c\u5236\u9020\u65b9\u6cd5\u7684\u5171\u4eab\u7b49\u3002\u56e0\u6b64\uff0c\u4eab\u5143\u6a21\u5f0f\u5bf9\u5496\u5561\u644a\u6765\u8bf4\uff0c\u5c31\u610f\u5473\u7740\u4e0d\u9700\u8981\u4e3a\u6bcf\u4e00\u4efd\u5355\u72ec\u8c03\u5236\u3002\u644a\u4e3b\u53ef\u4ee5\u5728\u9700\u8981\u65f6\uff0c\u4e00\u6b21\u6027\u5730\u8c03\u5236\u51fa\u8db3\u591f\u4e00\u5929\u51fa\u552e\u7684\u67d0\u4e00\u79cd\u98ce\u5473\u7684\u5496\u5561\u3002<\/p>\n<p>\u5f88\u663e\u7136\uff0c\u8fd9\u91cc\u9002\u5408\u4f7f\u7528\u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u3002\u7cfb\u7edf\u7684\u8bbe\u8ba1\u5982\u4e0b\uff1a<br \/><code>using System;<br \/>using System.Collections;<\/p>\n<p>public abstract class order<br \/>{<br \/>&nbsp;&nbsp;\/\/ \u5c06\u5496\u5561\u5356\u7ed9\u5ba2\u4eba<br \/>&nbsp;&nbsp;public abstract void Serve();<br \/>&nbsp;&nbsp;\/\/ \u8fd4\u56de\u5496\u5561\u7684\u540d\u5b57<br \/>&nbsp;&nbsp;public abstract string GetFlavor();<br \/>}<\/p>\n<p>public class Flavor : order<br \/>{<br \/>&nbsp;&nbsp;private string flavor;<\/p>\n<p>&nbsp;&nbsp;\/\/ \u6784\u9020\u51fd\u6570\uff0c\u5185\u8574\u72b6\u6001\u4ee5\u53c2\u6570\u65b9\u5f0f\u4f20\u5165<br \/>&nbsp;&nbsp;public Flavor(string flavor)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;this.flavor = flavor;<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;\/\/ \u8fd4\u56de\u5496\u5561\u7684\u540d\u5b57<br \/>&nbsp;&nbsp;public override string GetFlavor()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return this.flavor;<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;\/\/ \u5c06\u5496\u5561\u5356\u7ed9\u5ba2\u4eba<br \/>&nbsp;&nbsp;public override void Serve()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"Serving flavor \" + flavor);<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>public class FlavorFactory<br \/>{<br \/>&nbsp;&nbsp;private Hashtable flavors = new Hashtable();<\/p>\n<p>&nbsp;&nbsp;public order GetOrder(string key)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(! flavors.ContainsKey(key))<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flavors.Add(key, new Flavor(key));<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return ((Order)flavors[key]);<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;public int GetTotalFlavorsMade()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return flavors.Count;<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>public class Client<br \/>{<br \/>&nbsp;&nbsp;private static FlavorFactory flavorFactory;<br \/>&nbsp;&nbsp;private static int ordersMade = 0;<\/p>\n<p>&nbsp;&nbsp;public static void Main( string[] args )<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;flavorFactory = new FlavorFactory();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"<br \/>\nTotal orders made: \" + ordersMade);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"<br \/>\nTotal Flavor objects made: \" + <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flavorFactory.GetTotalFlavorsMade());<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;private static void TakeOrder(string aFlavor)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;o&#114;der o = flavorFactory.GetOrder(aFlavor);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ \u5c06\u5496\u5561\u5356\u7ed9\u5ba2\u4eba<br \/>&nbsp;&nbsp;&nbsp;&nbsp;o.Serve();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;o&#114;dersMade++;<br \/>&nbsp;&nbsp;}<br \/>}<br \/><\/code><\/p>\n<p>\u516d\u3001 \u5496\u5561\u5c4b\u7684\u4f8b\u5b50<br \/>\u5728\u524d\u9762\u7684\u5496\u5561\u644a\u9879\u76ee\u91cc\uff0c\u7531\u4e8e\u6ca1\u6709\u4f9b\u5ba2\u4eba\u5750\u7684\u684c\u5b50\uff0c\u6240\u6709\u7684\u5496\u5561\u5747\u6ca1\u6709\u73af\u5883\u7684\u5f71\u54cd\u3002\u6362\u8a00\u4e4b\uff0c\u5496\u5561\u4ec5\u6709\u5185\u8574\u72b6\u6001\uff0c\u4e5f\u5c31\u662f\u5496\u5561\u7684\u79cd\u7c7b\uff0c\u800c\u6ca1\u6709\u5916\u8574\u72b6\u6001\u3002<\/p>\n<p>\u4e0b\u9762\u8003\u8651\u4e00\u4e2a\u89c4\u6a21\u7a0d\u7a0d\u5927\u4e00\u70b9\u7684\u5496\u5561\u5c4b(Coffee Shop)\u9879\u76ee\u3002\u5c4b\u5b50\u91cc\u6709\u5f88\u591a\u7684\u684c\u5b50\u4f9b\u5ba2\u4eba\u5750\uff0c\u7cfb\u7edf\u9664\u4e86\u9700\u8981\u63d0\u4f9b\u5496\u5561\u7684&#8221;\u98ce\u5473&#8221;\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u8ddf\u8e2a\u5496\u5561\u88ab\u9001\u5230\u54ea\u4e00\u4e2a\u684c\u4f4d\u4e0a\uff0c\u56e0\u6b64\uff0c\u5496\u5561\u5c31\u6709\u4e86\u684c\u5b50\u4f5c\u4e3a\u5916\u8574\u72b6\u6001\u3002<\/p>\n<p>\u7531\u4e8e\u5916\u8574\u72b6\u6001\u7684\u5b58\u5728\uff0c\u6ca1\u6709\u5916\u8574\u72b6\u6001\u7684\u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u4e0d\u518d\u7b26\u5408\u8981\u6c42\u3002\u7cfb\u7edf\u7684\u8bbe\u8ba1\u53ef\u4ee5\u5229\u7528\u6709\u5916\u8574\u72b6\u6001\u7684\u5355\u7eaf\u4eab\u5143\u6a21\u5f0f\u3002\u7cfb\u7edf\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<br \/><code>using System;<br \/>using System.Collections;<\/p>\n<p>public abstract class order<br \/>{<br \/>&nbsp;&nbsp;\/\/ \u5c06\u5496\u5561\u5356\u7ed9\u5ba2\u4eba<br \/>&nbsp;&nbsp;public abstract void Serve(Table table);<br \/>&nbsp;&nbsp;\/\/ \u8fd4\u56de\u5496\u5561\u7684\u540d\u5b57<br \/>&nbsp;&nbsp;public abstract string GetFlavor();<br \/>}<\/p>\n<p>public class Flavor : order<br \/>{<br \/>&nbsp;&nbsp;private string flavor;<\/p>\n<p>&nbsp;&nbsp;\/\/ \u6784\u9020\u51fd\u6570\uff0c\u5185\u8574\u72b6\u6001\u4ee5\u53c2\u6570\u65b9\u5f0f\u4f20\u5165<br \/>&nbsp;&nbsp;public Flavor(string flavor)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;this.flavor = flavor;<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;\/\/ \u8fd4\u56de\u5496\u5561\u7684\u540d\u5b57<br \/>&nbsp;&nbsp;public override string GetFlavor()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return this.flavor;<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;\/\/ \u5c06\u5496\u5561\u5356\u7ed9\u5ba2\u4eba<br \/>&nbsp;&nbsp;public override void Serve(Table table)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"Serving table {0} with flavor {1}\", table.Number, flavor);<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>public class FlavorFactory<br \/>{<br \/>&nbsp;&nbsp;private Hashtable flavors = new Hashtable();<\/p>\n<p>&nbsp;&nbsp;public order GetOrder(string key)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(! flavors.ContainsKey(key))<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flavors.Add(key, new Flavor(key));<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return ((Order)flavors[key]);<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;public int GetTotalFlavorsMade()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return flavors.Count;<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>public class Table<br \/>{<br \/>&nbsp;&nbsp;private int number;<\/p>\n<p>&nbsp;&nbsp;public Table(int number)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;this.number = number;<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;public int Number<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;get { return number; }<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>public class Client<br \/>{<br \/>&nbsp;&nbsp;private static FlavorFactory flavorFactory;<br \/>&nbsp;&nbsp;private static int ordersMade = 0;<\/p>\n<p>&nbsp;&nbsp;public static void Main( string[] args )<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;flavorFactory = new FlavorFactory();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Espresso\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Capucino\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;TakeOrder(\"Black Coffee\");<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"<br \/>\nTotal orders made: \" + ordersMade);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"<br \/>\nTotal Flavor objects made: \" + <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flavorFactory.GetTotalFlavorsMade());<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;private static void TakeOrder(string aFlavor)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;o&#114;der o = flavorFactory.GetOrder(aFlavor);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ \u5c06\u5496\u5561\u5356\u7ed9\u5ba2\u4eba<br \/>&nbsp;&nbsp;&nbsp;&nbsp;o.Serve(new Table(++ordersMade));<br \/>&nbsp;&nbsp;}<br \/>}<br \/><\/code><\/p>\n<p>\u4e03\u3001 \u4eab\u5143\u6a21\u5f0f\u5e94\u5f53\u5728\u4ec0\u4e48\u60c5\u51b5\u4e0b\u4f7f\u7528<br \/>\u5f53\u4ee5\u4e0b\u6240\u6709\u7684\u6761\u4ef6\u90fd\u6ee1\u8db3\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4eab\u5143\u6a21\u5f0f\uff1a<\/p>\n<p>\u4e00\u4e2a\u7cfb\u7edf\u6709\u5927\u91cf\u7684\u5bf9\u8c61\u3002 <br \/>\u8fd9\u4e9b\u5bf9\u8c61\u8017\u8d39\u5927\u91cf\u7684\u5185\u5b58\u3002 <br \/>\u8fd9\u4e9b\u5bf9\u8c61\u7684\u72b6\u6001\u4e2d\u7684\u5927\u90e8\u5206\u90fd\u53ef\u4ee5\u5916\u90e8\u5316\u3002 <br \/>\u8fd9\u4e9b\u5bf9\u8c61\u53ef\u4ee5\u6309\u7167\u5185\u8574\u72b6\u6001\u5206\u6210\u5f88\u591a\u7684\u7ec4\uff0c\u5f53\u628a\u5916\u8574\u5bf9\u8c61\u4ece\u5bf9\u8c61\u4e2d\u5254\u9664\u65f6\uff0c\u6bcf\u4e00\u4e2a\u7ec4\u90fd\u53ef\u4ee5\u4ec5\u7528\u4e00\u4e2a\u5bf9\u8c61\u4ee3\u66ff\u3002 <br \/>\u8f6f\u4ef6\u7cfb\u7edf\u4e0d\u4f9d\u8d56\u4e8e\u8fd9\u4e9b\u5bf9\u8c61\u7684\u8eab\u4efd\uff0c\u6362\u8a00\u4e4b\uff0c\u8fd9\u4e9b\u5bf9\u8c61\u53ef\u4ee5\u662f\u4e0d\u53ef\u5206\u8fa8\u7684\u3002 <br \/>\u6ee1\u8db3\u4ee5\u4e0a\u7684\u8fd9\u4e9b\u6761\u4ef6\u7684\u7cfb\u7edf\u53ef\u4ee5\u4f7f\u7528\u4eab\u5143\u5bf9\u8c61\u3002<\/p>\n<p>\u6700\u540e\uff0c\u4f7f\u7528\u4eab\u5143\u6a21\u5f0f\u9700\u8981\u7ef4\u62a4\u4e00\u4e2a\u8bb0\u5f55\u4e86\u7cfb\u7edf\u5df2\u6709\u7684\u6240\u6709\u4eab\u5143\u7684\u8868\uff0c\u800c\u8fd9\u9700\u8981\u8017\u8d39\u8d44\u6e90\u3002\u56e0\u6b64\uff0c\u5e94\u5f53\u5728\u6709\u8db3\u591f\u591a\u7684\u4eab\u5143\u5b9e\u4f8b\u53ef\u4f9b\u5171\u4eab\u65f6\u624d\u503c\u5f97\u4f7f\u7528\u4eab\u5143\u6a21\u5f0f\u3002<\/p>\n<p>\u516b\u3001 \u4eab\u5143\u6a21\u5f0f\u7684\u4f18\u70b9\u548c\u7f3a\u70b9<br \/>\u4eab\u5143\u6a21\u5f0f\u7684\u4f18\u70b9\u5728\u4e8e\u5b83\u5927\u5e45\u5ea6\u5730\u964d\u4f4e\u5185\u5b58\u4e2d\u5bf9\u8c61\u7684\u6570\u91cf\u3002\u4f46\u662f\uff0c\u5b83\u505a\u5230\u8fd9\u4e00\u70b9\u6240\u4ed8\u51fa\u7684\u4ee3\u4ef7\u4e5f\u662f\u5f88\u9ad8\u7684\uff1a<\/p>\n<p>\u4eab\u5143\u6a21\u5f0f\u4f7f\u5f97\u7cfb\u7edf\u66f4\u52a0\u590d\u6742\u3002\u4e3a\u4e86\u4f7f\u5bf9\u8c61\u53ef\u4ee5\u5171\u4eab\uff0c\u9700\u8981\u5c06\u4e00\u4e9b\u72b6\u6001\u5916\u90e8\u5316\uff0c\u8fd9\u4f7f\u5f97\u7a0b\u5e8f\u7684\u903b\u8f91\u590d\u6742\u5316\u3002 <br \/>\u4eab\u5143\u6a21\u5f0f\u5c06\u4eab\u5143\u5bf9\u8c61\u7684\u72b6\u6001\u5916\u90e8\u5316\uff0c\u800c\u8bfb\u53d6\u5916\u90e8\u72b6\u6001\u4f7f\u5f97\u8fd0\u884c\u65f6\u95f4\u7a0d\u5fae\u53d8\u957f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001 \u4eab\u5143\uff08Flyweight\uff09\u6a21\u5f0fFlyweight\u5728\u62f3\u51fb\u6bd4\u8d5b\u4e2d\u6307&#46;&#46;&#46;<\/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-105","post","type-post","status-publish","format-standard","hentry","category-Note"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=105"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}