473,728 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Abstract Factory and Factory Method PHP5 Design Patterns

In Febraury - April of 2002 I put together in Java examples of all 23
of the classic "Gang Of Four" design patterns for my website. Partly
I wanted to get a better understanding of those patterns. They are
still online at
http://www.fluffycat.com/java/patterns.html

Since September 2003 I've mainly been using PHP, and now that PHP 5 is
becoming more available I am going to try the same thing I did in Java
with PHP.

I have only completed my pages for Abstract Factory and Factory
Method thus far and I have a pretty good idea of what I will do for
Composite and Memento. Hopefully I will be adding one or two new
patterns each week until all are complete. If any other pattern
loving PHP enthusiasts want to check it out I'd love your feedback:

http://www.fluffycat.com/SDCMSv2/
Oct 27 '05 #1
11 4304
Hey pattern fans, I just finished my page for the Memento Pattern
using 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 object
was a bit of a struggle. I finally settled on having the memento
called with the originator it was getting or setting, and the memento
would only set or get the originator by calling the originator get and
sets. The downside is that I made the gets and sets on the originator
public, which may not be ideal. The friend class, which is available
in C++ is not availble in PHP, or in Java for that matter. Also not
available is Java's package level accessibility or inner classes. If
I did have to tighten up access on the originator class I might have
looked into either making the memento a child of the originator and
using protected access.

Meanwhile, if there is a nice open source UML tool anyone can
recommend for PHP I'd appreciate it. I'd also be delighted to trade
links and credit on my site for UML class diagrams with a software
company selliing a UML tool for PHP.

-Larry Truett

www.FluffyCat.com

On Wed, 26 Oct 2005 19:39:41 -0700, FluffyCat <LT*****@Fluffy Cat.com>
wrote:
In Febraury - April of 2002 I put together in Java examples of all 23
of the classic "Gang Of Four" design patterns for my website. Partly
I wanted to get a better understanding of those patterns. They are
still online at
http://www.fluffycat.com/java/patterns.html

Since September 2003 I've mainly been using PHP, and now that PHP 5 is
becoming more available I am going to try the same thing I did in Java
with PHP.

I have only completed my pages for Abstract Factory and Factory
Method thus far and I have a pretty good idea of what I will do for
Composite and Memento. Hopefully I will be adding one or two new
patterns each week until all are complete. If any other pattern
loving PHP enthusiasts want to check it out I'd love your feedback:

http://www.fluffycat.com/SDCMSv2/

Nov 1 '05 #2
....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 it
really isn't required for the Composite and partly because I will be
doing one for the Iterator pattern. I like to keep the pattern
examples as pure as I can, and adding an iterator would hav muddied
the waters somewhat.

On Wed, 26 Oct 2005 19:39:41 -0700, FluffyCat <LT*****@Fluffy Cat.com>
wrote:
In Febraury - April of 2002 I put together in Java examples of all 23
of the classic "Gang Of Four" design patterns for my website. Partly
I wanted to get a better understanding of those patterns. They are
still online at
http://www.fluffycat.com/java/patterns.html

Since September 2003 I've mainly been using PHP, and now that PHP 5 is
becoming more available I am going to try the same thing I did in Java
with PHP.

I have only completed my pages for Abstract Factory and Factory
Method thus far and I have a pretty good idea of what I will do for
Composite and Memento. Hopefully I will be adding one or two new
patterns each week until all are complete. If any other pattern
loving PHP enthusiasts want to check it out I'd love your feedback:

http://www.fluffycat.com/SDCMSv2/

Nov 3 '05 #3
Struggled to come up with at least one good example this week, almost
got something I liked for visitor and facade, but finally turned to
the decorator pattern. The decorator pattern is good to keep in mind
when you need to add functionality to a class, but changing that class
simply is not possible.

http://www.fluffycat.com/SDCMSv2/PHP...rns-Decorator/

On Thu, 03 Nov 2005 14:33:57 -0800, FluffyCat <LT*****@Fluffy Cat.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 it
really isn't required for the Composite and partly because I will be
doing one for the Iterator pattern. I like to keep the pattern
examples as pure as I can, and adding an iterator would hav muddied
the waters somewhat.

On Wed, 26 Oct 2005 19:39:41 -0700, FluffyCat <LT*****@Fluffy Cat.com>
wrote:
In Febraury - April of 2002 I put together in Java examples of all 23
of the classic "Gang Of Four" design patterns for my website. Partly
I wanted to get a better understanding of those patterns. They are
still online at
http://www.fluffycat.com/java/patterns.html

Since September 2003 I've mainly been using PHP, and now that PHP 5 is
becoming more available I am going to try the same thing I did in Java
with PHP.

I have only completed my pages for Abstract Factory and Factory
Method thus far and I have a pretty good idea of what I will do for
Composite and Memento. Hopefully I will be adding one or two new
patterns each week until all are complete. If any other pattern
loving PHP enthusiasts want to check it out I'd love your feedback:

http://www.fluffycat.com/SDCMSv2/

Nov 10 '05 #4
New on November 23, 2005 for www.FluffyCat.com PHP 5 Design Pattern
Examples - the Facade Pattern.

This is a pattern that most complex systems use. In the facade a
class hides a comlex susbsystem from the calling class, and also hides
the calling class from the subsystem.

My sample makes extensive use of static functions in the subsystem.
This seems to make sense if the calling class and subsystem can't be
aware of each other.

http://www.fluffycat.com/SDCMSv2/PHP...tterns-Facade/

On Thu, 03 Nov 2005 14:33:57 -0800, FluffyCat <LT*****@Fluffy Cat.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 it
really isn't required for the Composite and partly because I will be
doing one for the Iterator pattern. I like to keep the pattern
examples as pure as I can, and adding an iterator would hav muddied
the waters somewhat.

On Wed, 26 Oct 2005 19:39:41 -0700, FluffyCat <LT*****@Fluffy Cat.com>
wrote:
In Febraury - April of 2002 I put together in Java examples of all 23
of the classic "Gang Of Four" design patterns for my website. Partly
I wanted to get a better understanding of those patterns. They are
still online at
http://www.fluffycat.com/java/patterns.html

Since September 2003 I've mainly been using PHP, and now that PHP 5 is
becoming more available I am going to try the same thing I did in Java
with PHP.

I have only completed my pages for Abstract Factory and Factory
Method thus far and I have a pretty good idea of what I will do for
Composite and Memento. Hopefully I will be adding one or two new
patterns each week until all are complete. If any other pattern
loving PHP enthusiasts want to check it out I'd love your feedback:

http://www.fluffycat.com/SDCMSv2/

Nov 23 '05 #5
FluffyCat said the following on 23/11/2005 22:40:
New on November 23, 2005 for www.FluffyCat.com PHP 5 Design Pattern
Examples - the Facade Pattern.

This is a pattern that most complex systems use. In the facade a
class hides a comlex susbsystem from the calling class, and also hides
the calling class from the subsystem.

My sample makes extensive use of static functions in the subsystem.
This seems to make sense if the calling class and subsystem can't be
aware of each other.

http://www.fluffycat.com/SDCMSv2/PHP...tterns-Facade/


That's not really a pattern as such, is it? It's merely an example of
encapsulation/functional abstraction. Which is one of the fundamental
underlying principles of OO design. To call this a pattern is like
saying that using a function is a pattern.

--
Oli
Nov 23 '05 #6
On Wed, 23 Nov 2005 22:50:57 GMT, Oli Filth <ca***@olifilth .co.uk>
wrote:
FluffyCat said the following on 23/11/2005 22:40:
New on November 23, 2005 for www.FluffyCat.com PHP 5 Design Pattern
Examples - the Facade Pattern.

This is a pattern that most complex systems use. In the facade a
class hides a comlex susbsystem from the calling class, and also hides
the calling class from the subsystem.

My sample makes extensive use of static functions in the subsystem.
This seems to make sense if the calling class and subsystem can't be
aware of each other.

http://www.fluffycat.com/SDCMSv2/PHP...tterns-Facade/


That's not really a pattern as such, is it? It's merely an example of
encapsulatio n/functional abstraction. Which is one of the fundamental
underlying principles of OO design. To call this a pattern is like
saying that using a function is a pattern.

Yes, I completely agree with you. The facade pattern could almost be
called the function pattern. I Ithink it may be included in most
pattern catalogs, including "Design Patterns - Elements of Reusable
Object-Oriented Software" by Gamma, Helm, Johnson and Vlissides,
because it is so prevelant in most systems. Since my intent is to
give examples in PHP 5 of the most commonly accepted patterns, and not
alter or exclude any, I added Facade to my site. It didn't hurt that
it was fairly straight forward to put an example together. I did my
example with statics partly to emphasize that it isn't the most OO of
patterns, which hopefully does capture the way previous works have
documented the facade pattern. Thanks for asking about that, as I
felt more than once while working on the Facade that while it is
certainly common and useful, it isn't as OO as say the Visitor
pattern, which I was working on at the same time.
Nov 25 '05 #7
Are you thinking of putting not only gof patterns but also some
enterprise level patterns such as mvc ? I think it would be great to
include some patterns such as Core J2EE patterns for php. Any study on
that ? I would like to participate, if there is.

Nov 27 '05 #8
framework like cakephp?

http://groups.google.com/group/cake-php?lnk=li

Nov 28 '05 #9
There are a lot of frameworks in php out there. I am not mentioning
building one, promoting one or helping one.

There are many architectural patterns for j2ee, there is so little info
for php. I am not talking about how to build a php framework based on
some architectural pattern documented for java, I am talking about
documenting design patterns for php, helping people to read some
patterns for php, documents that are good enough to help build
frameworks.

Some site named phppatterns (I do not remember the full adress) is
doing quite a job, but there is not any reference like java's core j2ee
patterns or dotnet patterns and designs site for php yet.

Nov 28 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
6643
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products. So I shall have an Abstract Base called 'Car' implemented by Toyota, Ford, and Buick. Further I'd like to enable to client to say Car *factory;
4
2525
by: max | last post by:
Hello, I analyze this design pattern for a long time but I do not understand how this pattern work and what the purpose is? (I looked a this site http://www.dofactory.com/Patterns/PatternAbstract.aspx). Could anybody try to explain me in his own words how this pattern work and what the purpose is? thanks in advance
33
3346
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or near-impossible. It seems like it would be useful. In fact, there's a place in my code that I could make good use of it. So why not? Chris
5
270
by: Frank | last post by:
Hello, a question about abstract classes. Abstract ClassA, inherited classes X and Y. When creating it's something like: if (true) ClassX xx = new ClassX(); else ClassY yy = new ClassY(); Is it in someway possible to put the if statement in the constructor of the
0
2679
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never looked for one on the net (I did browse the boost library though). It doesn't matter right now, anyway. To put it simply, Abstract Iterator is mainly a wrapper class. It helps
16
2645
by: RSH | last post by:
Hi, I am a fairly seasoned developer and have recently started looking at software design patterns. I am starting with the Abstract Factory Pattern and was wondering if someone could help me understand where I might use this Pattern. I get the general concept but I am having a hard time converting that concept into where I might use that in a real world scenerio for a business application or web development project. I appreciate the...
2
2565
by: Duy Lam | last post by:
Hi everyone, Sorry, I don't know what group to post this problem, I think may be this group is suitable. I'm styduing DAO (Data Access Object) pattern in this link http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html. While I've read about implementing Data Access Objects by Factory Method Pattern (http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_07.gif) and Abstract Factory Pattern...
3
4621
by: suresh_rai | last post by:
Hello I am hoping someone can give me very needed help. I am wanting some C+ + code for 'C++ Abstract Factory'. I need code to be free. I am been learning Design patterns. I found some code on web but dont know which is one is ok. http://programmerjoe.com/2007/03/18/the-abstract-factory-pattern-in-c/ http://www.codeproject.com/KB/architecture/DesignPattern.aspx Loki :in text book http://sourceforge.net/projects/papafactory
4
1978
by: C# | last post by:
http://www.questpond.com/FreeDesign1.htm I was going through the above videos. Can i conclude Abstract factory patterns are extensions of factory patterns. I have made the conclusion after viewing the video and reading GOF books. I am confused by these two patterns.
0
8895
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8755
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9191
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9125
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8117
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4523
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3231
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.