5

Ok, i'd like to firstly make you notice that i have looked for "php mvc design patterns" and so and i haven't really found what i was looking for; still now, writing my question, i cannot find any related and so specific question as i am going to ask. But i know i'm probably wrong, anyway consider this question and a question pack that could be usefull togheter.

Question

  1. I was wondering how we should consider the design patterns. I mean: What are they? Are they simply binaries that help us designing consistent application? Are they so used? Why?
  2. Where could i find a list about every design patterns on the web? Or at least the 5-10 most used design patterns?
  3. Do Phpbb, Wordpress or Joomla (that i know pretty well) use a design pattern? If yes, which?
  4. I googled MCV PHP and found about 3 italian articles and read about 5 of the first pages ranked and i didn't understand pretty much nothing. They were conflicting and seemed to me confusing. I did understand that it is usefull to separate business login, script and view (?) but i didn't got anything else. I am probably stupid or something but where could i find a nice and official (means written by the Gang of Four or someone who actually know what he is talking about) mvc tutorial or documentation related to php?
  5. Are there simple examples about design patterns and how they are better then (normal) writing styles? Are there simple examples about a mvc or other design pattern? For example a simple blog written with a design pattern?

Tips

I'd prefer free solution first. I don't like frameworks, so please don't refer to them even if (i know) they have mvc and other valid design patterns and benefits. I still don't like them. Thanks

Notice

I'll choose my accepted answer after tomorrow, so, please, take your time to answer.

5
  • 3
    Pigarelli - tried google MVC PHP ... this give me About 4,090,000 results (0.09 seconds) Commented Dec 3, 2010 at 19:04
  • 1
    1. Design patterns are... patterns. They are abstract concepts, not concrete things. You can build an application that follows the pattern but the patterns themselves are not your application. Using an analogy, an architectural blueprint is not a house, but tells you how a house could be built. Commented Dec 3, 2010 at 19:05
  • Does the first 20 results give the answers i need? Commented Dec 3, 2010 at 19:05
  • @ajreal: Y'know it would be helpful if you posted a link instead of just saying things! :P Commented Dec 3, 2010 at 19:06
  • @FrustratedWithFormsDesigner - not sure is there MVC PHP without framework ... sorry for being stupid Commented Dec 3, 2010 at 19:08

4 Answers 4

17

What are they?

Design patterns are language-agnostic blueprint solutions for common problems. They are not downloadable code or readymade implementations, but a theoretical approach you can implement/translate into working solutions.

Design Patterns also allow for easier communication between developers who know patterns, because when developer A says: this is a Factory, developer B will know what is meant.

Where could i find a list about every design patterns on the web? Or at least the 5-10 most used design patterns?

There is also a recommendable book called PHP Design Patterns (german only) for which you can download the code samples at http://www.phpdesignpatterns.de/auflage-2/#beispiele

Do phpbb, wordpress or joomla (that i know pretty well) use a design pattern? If yes, then which?

Probably, but listing each and every pattern an application uses is rather pointless. Some patterns are tiny, some are more complex. You dont use them to use them, but to solve problems.

Let me stress that: you dont use them to use them. They are not some sort of status symbol. You dont want to amass them. You even don't have to implement them by the book. Use them where appropriate with every variation required to solve a concrete problem in your application.

I googled MCV PHP and found about 3 italian articles and read about 5 of the first pages ranked and i didn't understand pretty much nothing. They were conflicting and seemed to me confusing. I did understand that it is usefull to separate business login, script and view (?) but i didn't got anything.

MVC is not a GOF pattern. It is listed in POEAA but it's way older than that. The MVC you usually see on the web has nothing to do with the "classic" MVC because there is the internet between view and the other two.

Basically, there is not much to know about MVC. It's very simple pattern. The idea is to split a UI into three distinct roles. The model is all your business logic. Your controller handles any requests from the view and delegates to the model. Your view displays the model. You should be able to replace the controller and views without having to touch your model.

Are there simple examples about design patterns and how they are better then (normal) writing styles?

Plenty. See the links above for some examples. If they are not clear enough, have a look around StackOverflow searching for their names.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 for "You dont use them to use them, but to solve problems."
3

You would probably get better results googling for MVC PHP instead of MCV PHP. Design patterns can be applied to all object oriented languages so you might be best advised to look into THE design pattern book and into Object Oriented Programming with PHP.

There also is an article series on DZone about practical PHP patterns.

3 Comments

Most design patterns work wonderfully in every language, not just the OOP ones.
Yeah... I'm confused about why OP would search "MCV" instead of "MVC"... I would not have expected they would give the same results.
Yes you can apply patterns to any paradigm, but imho the newer versions of PHP work best with an object oriented paradigm.
0

Here is a list of design pattern (not only for PHP): Wikipedia

Comments

0

I would also advise to take a look at php design patterns list. I hope you will find it useful.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.