Page 1 of 1

Programming pattern thread

Posted: Tue Aug 22, 2006 11:09 am
by MrPotatoes
we had a thread on here about the 5 most common PHP programming patterns. i can't seem to find it. does anyone have it bookmarked? apparently i sux at teh internets

Posted: Tue Aug 22, 2006 11:22 am
by Luke
I can't find the thread, but I remember the article (I believe) you are referring to:
http://www-128.ibm.com/developerworks/l ... signptrns/

Re: Programming pattern thread

Posted: Tue Aug 22, 2006 11:54 am
by Chris Corbyn
MrPotatoes wrote:we had a thread on here about the 5 most common PHP programming patterns. i can't seem to find it. does anyone have it bookmarked? apparently i sux at teh internets
Can I guess? :)

1. MVC
2. Factory
3. Singleton
4. Registry
5. Decorator

I'm only guessing though.... I don't remeber the thread :P

Posted: Tue Aug 22, 2006 12:00 pm
by MrPotatoes
you can guess all you want Ninja got it ;)

dude rules at teh searchez

thanx alot. i also went to reaper's site and checked some of those out. good stuffs

Re: Programming pattern thread

Posted: Tue Aug 22, 2006 12:12 pm
by Christopher
d11wtq wrote: 1. MVC
2. Factory
3. Singleton
4. Registry
5. Decorator
I have pestered you elsewhere about this. I think there are many more common ones that those. The Behavioial and Structural patters are far more commonly used. And except the Decorator, I would consider the patterns above to be dangerous in the hands of any programmer who does not already know how to solve problems without them (and I include myself in that group).

Re: Programming pattern thread

Posted: Tue Aug 22, 2006 12:21 pm
by Chris Corbyn
arborint wrote:I have pestered you elsewhere about this. I think there are many more common ones that those. The Behavioial and Structural patters are far more commonly used. And except the Decorator, I would consider the patterns above to be dangerous in the hands of any programmer who does not already know how to solve problems without them (and I include myself in that group).
:( Clearly I'm not familiar with some basic patterns... or rather, I'm probably familiar with them without actually knowing it. I'll read up.

Dangerous? The singleton without doubt yes, registry... hmm... I'm not sure how it could be deemed dangerous... maybe overused needlessly, MVC... ok ok, that can go bad, very bad if not gotten right, and the factory... pretty basic although broad-scoped...

<off-topic>
Do you fancy casting an opinion on what should be in the "Common Patterns" part of the book, and in what order? I know for a fact you'll come up with a better list than me, I was pretty much going on my own gut instinct until last night.
</off-topic>

Posted: Tue Aug 22, 2006 12:36 pm
by sweatje
Here is a list of my guesses at the top 16 :)

I would have to say for top 5:
1) Iterator
2) Proxy
3) Decorator
4) Singleton (unfortunatly - would prefer to see more use of Factories and Registry/Service Locators)
5) ActiveRecord (seems the most popular data access pattern at the moment, though more of my PHP code tends towards TableDataGateways)

Posted: Tue Aug 22, 2006 12:50 pm
by MrPotatoes
i've used singletons but as the main pattern for a system i don't think it's a good way of doing things. especially for PHP where all the objects would be encapsulated into one main object. easier for a smart script kiddie to destroy what you've so diligently worked for

Posted: Tue Aug 22, 2006 1:33 pm
by Chris Corbyn
sweatje wrote:Here is a list of my guesses at the top 16 :)

I would have to say for top 5:
1) Iterator
2) Proxy
3) Decorator
4) Singleton (unfortunatly - would prefer to see more use of Factories and Registry/Service Locators)
5) ActiveRecord (seems the most popular data access pattern at the moment, though more of my PHP code tends towards TableDataGateways)
I'm glad the list I put together elsewhere correlates fairly well with your judgement :) Fancy writing another book with us guys? :lol:

Posted: Tue Aug 22, 2006 3:58 pm
by timvw
Here is my list of php's most common patterns:

- copied straight out of the manual or tutorial
- spaghetti code
- mismash of html, css, sql and php in the same file
- open for sql injection
- open for xss attacks

Posted: Tue Aug 22, 2006 4:01 pm
by Luke
timvw wrote:Here is my list of php's most common patterns:

- copied straight out of the manual or tutorial
- spaghetti code
- mismash of html, css, sql and php in the same file
- open for sql injection
- open for xss attacks
Image

Posted: Tue Aug 22, 2006 4:23 pm
by Chris Corbyn
timvw wrote:Here is my list of php's most common patterns:

- copied straight out of the manual or tutorial
- spaghetti code
- mismash of html, css, sql and php in the same file
- open for sql injection
- open for xss attacks
What do you mean? Are you insulting my abilities? :twisted:

Code: Select all

<!-- PASTE THIS CODE INTO YOUR WEBSITE... Bookmark http://www.<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>-code.com for more scripts -->
<style type="text/css">
body {
    background: <?php

$query = "select ".$_GET['column']." from ".$POST['table']." where ".$_POST['where'];
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo $row[0];

?>
}
</script>
</head>
<script type="text/javascript">
<!-- 

var thisPage = '<?= $_GET['page']; ?>';

//bleh

// -->
</script>
</head>
<body>