Design Patterns

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
timclaason
Forum Commoner
Posts: 77
Joined: Tue Dec 16, 2003 9:06 am
Location: WI

Design Patterns

Post by timclaason »

I've recently been introduced to the idea of design patterns (that may lead everyone to realize what a 2-bit hack I am, but that's ok), in particular, the flyweight pattern.

I'm not really a C#, Java, C++, etc professional (only web), so I've never really thought of design in such complex terms, but I can't help thinking that my PHP code could be significantly improved and simplified if I implemented better design patterns that would work best for the particular type of application I'm working on.

I was wondering if anyone uses any specific design patterns, and if so, if you had any links you could post with different PHP implementations of design patterns.

Thanks in advance.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Good programming practice and design, architecture, etc can be applied to *any* programming language regardless of it's purpose:

Client side JavaScript
Server side PHP

or desktop development in C++/C#/Java

I use as much as I know and as I much as I find fit for a given scenario.

If you want to know about design patterns, youv'e come to the right place, we have a few design pattern geeks on these boards. :)

Long story short: Use them, don't abuse them. Start simple and work your way up, don't apply every technique the minute you learn it, rather understand it's role in system design and look for future opportunities, etc.

Cheers :)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Hockey is dead right however, if I remember correctly, the flyweight pattern doesn't really apply to PHP.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

ole wrote:if I remember correctly, the flyweight pattern doesn't really apply to PHP.
I think its probably more accurate to say that the problems solved by the flyweight pattern are not frequently implemented in web applications. It is one of many techniques to reduce data duplication. The OP expressed interest in the flyweight pattern, but did not give a specific problem that needed to be solved.
Last edited by Christopher on Fri May 25, 2007 4:24 am, edited 1 time in total.
(#10850)
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Oren plugged my site ;). The contents are limited for now since I'm not in article writing mode (lack of time). Also http://www.phppatterns.com

A few article sites like DevShed run a regular design pattern series. Many focus on PHP implementations. Outside that don't be afraid to look for Java examples. The code is likely not portable but the explanations are worth reading since they apply to any language.
the_drizzle
Forum Newbie
Posts: 17
Joined: Fri Jun 01, 2007 11:55 am

Post by the_drizzle »

Check out FluffyCat. It gives some general descriptions of design patterns, using PHP for code examples.
Post Reply