473,466 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Create 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 4277
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*****@FluffyCat.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*****@FluffyCat.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*****@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 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*****@FluffyCat.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*****@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 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*****@FluffyCat.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
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.

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

Yes, PHP is certainly behind Java with regard to pattern development.
This is of course partly because PHP 5 is (to me anyway) PHP's first
decent OO implementation. PHP 5 is just starting to become available
at hosting companies, so PHP programmers are just now getting into the
exciting world of OO.

On 28 Nov 2005 01:10:08 -0800, "A. Timurhan Cevik" <at*****@gmail.com>
wrote:
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 29 '05 #11
Thanks for asking, I've been wondering what I'd do after gof myself.
I'm such a huge fan of MVC that I am planning to do an example of
that.

I should add a part to the site so that others can add comments, or
even their own whole examples, but I'm still hashing out the details
of just how that would work on my site.

On 27 Nov 2005 07:56:51 -0800, "A. Timurhan Cevik" <at*****@gmail.com>
wrote:
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 29 '05 #12

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

Similar topics

17
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....
4
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...
33
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...
5
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(); ...
0
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...
16
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...
2
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...
3
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...
4
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.