Closed codeguy closed 6 years ago
I really like how http://sourcemaking.com/ covers this. I think they're trying to sell a book so I'm not sure how comfortable people would be linking to them directly but it's possibly a good start?.
n.b. I am not affiliated with them in any way at all.
@adambrett Thanks. The goal here is to provide a basic definition and synopsis of each pattern with a simple example. We will provide links to external resources for more in-depth coverage.
This is a list straight from Wikipedia referenced from the Gang of Four book. The goal is to cover each of these with a definition/synopsis and a brief example. We can provide outbound links for each pattern to more in-depth tutorials and articles.
http://en.wikipedia.org/wiki/Design_Patterns
The goal here is to provide a description, simple example, and a list of external references for each design pattern. A visitor should walk away from PHP The Right Way with a good understanding of a design pattern with a list of more in-depth external references to explore later.
If you want to claim a pattern, open a separate issue titled "[X] Pattern" and link to that issue in this thread. Each Design Pattern should have it's own stand-alone child page that lives in the pages/ subdirectory. We will link to this page from the front page.
Creational patterns are ones that create objects for you, rather than having you instantiate objects directly. This gives your program more flexibility in deciding which objects need to be created for a given case.
These concern class and object composition. They use inheritance to compose interfaces and define ways to compose objects to obtain new functionality.
Most of these design patterns are specifically concerned with communication between objects.
I wrote a book on this recently. In my experience, you can drop Flyweight, Interpreter, Memento, and I would add MVC and Domain Modeling, as well as Active Record.
/me raises my hand to contribute to Decorator. I'm a big fan of the Decorator pattern. I got this: #372.
ALL: If you want to claim a given pattern, open a separate issue titled "[X] Pattern" and link to that issue in this thread.
@codeguy I'd love to get involved with this as the books we pull patterns from are not always helpful for beginners.
It is a massive undertaking though. I will keep an eye on this thread and if you want a chat about anything just shoot me a DM or an email.
Further clarification. Each Design Pattern should have it's own stand-alone child page that lives in the pages/
subdirectory. We will link to this page from the front page.
I will take Chain of Command if nobody has any objections - Issue #373
NOTE: The goal here is to provide a description, simple example, and a list of external references for each design pattern. A visitor should walk away from PHP The Right Way with a good understanding of a design pattern with a list of more in-depth external references to explore later.
I'll take Singleton.
I want to take factory method
I'll take Observer.
@codeguy Observer is a fun one, and brings back good memories.
I'll take Facade, Bridge and Adapter. They're actually all related.
@brandonsavage Thanks! Re: your earlier comment, I prefer to keep all of the patterns even if we just provide a very simple description and a note that they are not used often. I'm fine adding MVC, Domain Modeling, and Active Record :+1:
You won't get any argument from me, that's for sure!
Onxe everyone is done with their sections we'll have a 30 minute break then pass the issues one to the right.
We'll all mark somebody else's answers and the winner gets a bottle of wine.
Josh is paying. — Sent from Mailbox for iPhone
On Thu, Mar 6, 2014 at 9:12 PM, brandonsavage notifications@github.com wrote:
You won't get any argument from me, that's for sure!
Reply to this email directly or view it on GitHub: https://github.com/codeguy/php-the-right-way/issues/370#issuecomment-36961411
2 buck chuck it is.
Its 3 buck in New York. The extortion! But yeah, happy writing folks.
@brandonsavage make issues for your patterns so people know what's up. — Sent from Mailbox for iPhone
On Thu, Mar 6, 2014 at 9:21 PM, Josh Lockhart notifications@github.com wrote:
2 buck chuck it is.
Reply to this email directly or view it on GitHub: https://github.com/codeguy/php-the-right-way/issues/370#issuecomment-36961834
@philsturgeon I filed #377.
On Thu, Mar 6, 2014 at 9:22 PM, Phil Sturgeon notifications@github.comwrote:
Its 3 buck in New York. The extortion! But yeah, happy writing folks.
@brandonsavage make issues for your patterns so people know what's up.
Sent from Mailbox for iPhone
On Thu, Mar 6, 2014 at 9:21 PM, Josh Lockhart notifications@github.com wrote:
2 buck chuck it is.
Reply to this email directly or view it on GitHub:
https://github.com/codeguy/php-the-right-way/issues/370#issuecomment-36961834
Reply to this email directly or view it on GitHubhttps://github.com/codeguy/php-the-right-way/issues/370#issuecomment-36961895 .
Sweet. Missed that. Keep on trucking.— Sent from Mailbox for iPhone
On Thu, Mar 6, 2014 at 9:26 PM, brandonsavage notifications@github.com wrote:
@philsturgeon I filed #377. On Thu, Mar 6, 2014 at 9:22 PM, Phil Sturgeon notifications@github.comwrote:
Its 3 buck in New York. The extortion! But yeah, happy writing folks.
@brandonsavage make issues for your patterns so people know what's up.
Sent from Mailbox for iPhone
On Thu, Mar 6, 2014 at 9:21 PM, Josh Lockhart notifications@github.com wrote:
2 buck chuck it is.
Reply to this email directly or view it on GitHub:
https://github.com/codeguy/php-the-right-way/issues/370#issuecomment-36961834
Reply to this email directly or view it on GitHubhttps://github.com/codeguy/php-the-right-way/issues/370#issuecomment-36961895 .
Reply to this email directly or view it on GitHub: https://github.com/codeguy/php-the-right-way/issues/370#issuecomment-36962090
For starters check out this repo: https://github.com/domnikl/DesignPatternsPHP it has many patterns covered.
i could take proxy
@stormpat That has good examples, but little to no description which is what we will be doing here. That would be a good resource to link to though.
@codeguy what about object persistence patterns? Data Mapper and Active Record are surely worth a mention
Where did we get to with this? I don't remember seeing much in the way of actual results, even though lots of people claimed various patterns. :)
I'm saddened to see the Singleton pattern being included, and even more so by it being the second one on the page.
At least there is this "You should be wary when using the singleton pattern" warning at the end. Though I wonder how many of the people reading this for the first time will actually see that. They probably read the intro, check the code, and implement it.
I'd just kill the Singleton pattern, though making the warning more prominent is already a good first step.
@JeroenDeDauw The singleton pattern has a place in oo in certain use cases, killing it would be the wrong way to go IMHO.
IMHO only patterns should be included which require special implementation in PHP. Everything else is not related to a specific programming language like PHP.
Closing. Linking to https://designpatternsphp.readthedocs.io/ now.
This issue is for discussion on a more detailed Design Patterns section. I think we should first decide which patterns to include, and then open up separate issues for each one for more in-depth discussion on each.