本文介绍了抽象工厂和工厂方法PHP5设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 在Febraury中 - 2002年4月,我在Java中汇总了经典Gang Of Four中所有23 b / b 的例子。我网站的设计模式。部分 我想更好地理解这些模式。 仍然可以在线访问 http ://www.fluffycat.com/java/patterns.html 自2003年9月以来,我主要使用PHP,现在PHP 5已经 变得更有用我将尝试用Java做同样的事情 用PHP。 我只完成了我的页面对于抽象工厂和工厂 方法到目前为止,我非常清楚我要做什么来为 Composite和Memento。希望我每周都会添加一两个新的 模式,直到所有模式完成。如果任何其他模式 爱好的PHP爱好者想要查看它我会喜欢你的反馈: http://www.fluffycat.com/SDCMSv2/ 解决方案 嘿模式粉丝,我刚刚使用PHP 5完成了Memento Pattern的页面 。您可以在以下位置查看: http://www.FluffyCat.com/SDCMSv2/PHP...terns-Memento/ 我发现Memento对象的整个私人辅助功能问题 有点挣扎。我终于决定让纪念品 与它正在接收或设置的发起人一起召唤,并且纪念品 只会通过调用发起人get和 套。不利的一面是我制作了获取并设置了发起人 public,这可能并不理想。朋友类,在C ++中可用的在PHP或Java中是不可用的。也没有 可用的是Java的包级别可访问性或内部类。如果 我确实必须加强对发起人课程的访问权限,我可能会看到看着让纪念品成为发端人的孩子并且 使用受保护的访问权限。 同时,如果有一个很好的开源UML工具,任何人都可以为PHP推荐我会很感激。我也很高兴能在我的网站上用UML类图表交换 链接和信用额度用软件 公司搜索用于PHP的UML工具。 -Larry Truett www.FluffyCat.com 2005年10月26日星期三19:39:41 -0700,FluffyCat< LT ***** @ FluffyCat.com> 写道: 在Febraury - 2002年4月,我把所有23个经典四人帮的Java例子放在一起。我网站的设计模式。部分我想更好地理解这些模式。他们仍然在线 http:// www .fluffycat.com / java / patterns.html 自2003年9月以来,我主要使用PHP,现在PHP 5已经变得更有用了我要去尝试使用PHP在Java中完成同样的事情。 到目前为止,我只完成了抽象工厂和工厂方法的页面,我对它有很好的了解我将为复合材料和纪念品做些什么。希望我每周都会添加一两个新的模式,直到完成。如果任何其他模式爱好PHP爱好者想要查看它我会喜欢你的反馈: http://www.fluffycat.com/SDCMSv2/ ....并且如所承诺的那样,PHP 5中的composte模式的一个例子。 http://www.fluffycat.com/SDCMSv2/PHP...rns-Composite/ 比纪念品容易得多模式。 我没有为复合材料做一个真正的迭代器,部分是因为它确实不需要复合材料,部分是因为我将为bterator模式做一个。我喜欢保持模式 尽可能纯净的例子,添加迭代器会有点混乱 水域。 2005年10月26日星期三19:39:41 -0700,FluffyCat< LT ***** @ FluffyCat.com> 写道: 在Febraury中 - 2002年4月我在Java中汇集了经典四人帮的所有23个例子。我网站的设计模式。部分我想更好地理解这些模式。他们仍然在线 http:// www .fluffycat.com / java / patterns.html 自2003年9月以来,我主要使用PHP,现在PHP 5已经变得更有用了我要去尝试使用PHP在Java中完成同样的事情。 到目前为止,我只完成了抽象工厂和工厂方法的页面,我对它有很好的了解我将为复合材料和纪念品做些什么。希望我每周都会添加一两个新的模式,直到完成。如果任何其他模式爱好PHP爱好者想要查看它我会喜欢你的反馈: http://www.fluffycat.com/SDCMSv2/ 挣扎着上来本周至少有一个很好的例子,几乎 得到了我喜欢的访客和门面,但最后转向 装饰模式。装饰图案很好记住 当你需要为一个类添加功能,但改变那个类 根本不可能。 http://www.fluffycat.com/SDCMSv2 /PHP...rns-Decorator/ 2005年11月3日星期四14:33:57 -0800,FluffyCat< LT *** **@FluffyCat.com>写道: ...正如所承诺的,PHP 5中的composte模式的一个例子。 http://www.fluffycat.com/SDCMSv2/PHP...rns-Composite/ 比memento模式容易得多。 我没有为复合材料做一个真正的迭代器,部分是因为它对复合材料来说真的不是必需的因为我将为Iterator模式做一个。我喜欢尽可能地保持模式的例子,并且添加一个迭代器会在某种程度上混淆水域。 2005年10月26日星期三19:39: 41 -0700,FluffyCat< LT ***** @ FluffyCat.com> 写道: 在Febraury - 2002年4月我在Java中汇集了所有的例子23经典的四人帮我网站的设计模式。部分我想更好地理解这些模式。他们仍然在线 http:// www .fluffycat.com / java / patterns.html 自2003年9月以来,我主要使用PHP,现在PHP 5已经变得更有用了我要去尝试使用PHP在Java中完成同样的事情。 到目前为止,我只完成了抽象工厂和工厂方法的页面,我对它有很好的了解我将为复合材料和纪念品做些什么。希望我每周都会添加一两个新的模式,直到完成。如果任何其他模式爱好PHP爱好者想要查看它我会喜欢你的反馈: http://www.fluffycat.com/SDCMSv2/ In Febraury - April of 2002 I put together in Java examples of all 23of the classic "Gang Of Four" design patterns for my website. PartlyI wanted to get a better understanding of those patterns. They arestill online at http://www.fluffycat.com/java/patterns.htmlSince September 2003 I''ve mainly been using PHP, and now that PHP 5 isbecoming more available I am going to try the same thing I did in Javawith PHP.I have only completed my pages for Abstract Factory and FactoryMethod thus far and I have a pretty good idea of what I will do forComposite and Memento. Hopefully I will be adding one or two newpatterns each week until all are complete. If any other patternloving PHP enthusiasts want to check it out I''d love your feedback: http://www.fluffycat.com/SDCMSv2/ 解决方案 Hey pattern fans, I just finished my page for the Memento Patternusing PHP 5. You can check it out at: http://www.FluffyCat.com/SDCMSv2/PHP...terns-Memento/I found the whole private accessibility issue for the Memento objectwas a bit of a struggle. I finally settled on having the mementocalled with the originator it was getting or setting, and the mementowould only set or get the originator by calling the originator get andsets. The downside is that I made the gets and sets on the originatorpublic, which may not be ideal. The friend class, which is availablein C++ is not availble in PHP, or in Java for that matter. Also notavailable is Java''s package level accessibility or inner classes. IfI did have to tighten up access on the originator class I might havelooked into either making the memento a child of the originator andusing protected access.Meanwhile, if there is a nice open source UML tool anyone canrecommend for PHP I''d appreciate it. I''d also be delighted to tradelinks and credit on my site for UML class diagrams with a softwarecompany selliing a UML tool for PHP.-Larry Truett www.FluffyCat.comOn Wed, 26 Oct 2005 19:39:41 -0700, FluffyCat <LT*****@FluffyCat.com>wrote: In Febraury - April of 2002 I put together in Java examples of all 23of the classic "Gang Of Four" design patterns for my website. PartlyI wanted to get a better understanding of those patterns. They arestill online athttp://www.fluffycat.com/java/patterns.htmlSince September 2003 I''ve mainly been using PHP, and now that PHP 5 isbecoming more available I am going to try the same thing I did in Javawith PHP.I have only completed my pages for Abstract Factory and FactoryMethod thus far and I have a pretty good idea of what I will do forComposite and Memento. Hopefully I will be adding one or two newpatterns each week until all are complete. If any other patternloving PHP enthusiasts want to check it out I''d love your feedback:http://www.fluffycat.com/SDCMSv2/....and as promised, an example of the composte pattern in PHP 5. http://www.fluffycat.com/SDCMSv2/PHP...rns-Composite/Much easier than the memento pattern.I didn''t do a true iterator for the Composite, partly because itreally isn''t required for the Composite and partly because I will bedoing one for the Iterator pattern. I like to keep the patternexamples as pure as I can, and adding an iterator would hav muddiedthe waters somewhat.On Wed, 26 Oct 2005 19:39:41 -0700, FluffyCat <LT*****@FluffyCat.com>wrote: In Febraury - April of 2002 I put together in Java examples of all 23of the classic "Gang Of Four" design patterns for my website. PartlyI wanted to get a better understanding of those patterns. They arestill online athttp://www.fluffycat.com/java/patterns.htmlSince September 2003 I''ve mainly been using PHP, and now that PHP 5 isbecoming more available I am going to try the same thing I did in Javawith PHP.I have only completed my pages for Abstract Factory and FactoryMethod thus far and I have a pretty good idea of what I will do forComposite and Memento. Hopefully I will be adding one or two newpatterns each week until all are complete. If any other patternloving PHP enthusiasts want to check it out I''d love your feedback:http://www.fluffycat.com/SDCMSv2/Struggled to come up with at least one good example this week, almostgot something I liked for visitor and facade, but finally turned tothe decorator pattern. The decorator pattern is good to keep in mindwhen you need to add functionality to a class, but changing that classsimply is not possible. http://www.fluffycat.com/SDCMSv2/PHP...rns-Decorator/ On Thu, 03 Nov 2005 14:33:57 -0800, FluffyCat <LT*****@FluffyCat.com> wrote:...and as promised, an example of the composte pattern in PHP 5.http://www.fluffycat.com/SDCMSv2/PHP...rns-Composite/Much easier than the memento pattern.I didn''t do a true iterator for the Composite, partly because itreally isn''t required for the Composite and partly because I will bedoing one for the Iterator pattern. I like to keep the patternexamples as pure as I can, and adding an iterator would hav muddiedthe waters somewhat. On Wed, 26 Oct 2005 19:39:41 -0700, FluffyCat <LT*****@FluffyCat.com>wrote:In Febraury - April of 2002 I put together in Java examples of all 23of the classic "Gang Of Four" design patterns for my website. PartlyI wanted to get a better understanding of those patterns. They arestill online athttp://www.fluffycat.com/java/patterns.htmlSince September 2003 I''ve mainly been using PHP, and now that PHP 5 isbecoming more available I am going to try the same thing I did in Javawith PHP.I have only completed my pages for Abstract Factory and FactoryMethod thus far and I have a pretty good idea of what I will do forComposite and Memento. Hopefully I will be adding one or two newpatterns each week until all are complete. If any other patternloving PHP enthusiasts want to check it out I''d love your feedback:http://www.fluffycat.com/SDCMSv2/ 这篇关于抽象工厂和工厂方法PHP5设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 09:17
查看更多