Programming pattern thread
Moderator: General Moderators
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
Programming pattern thread
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
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/
http://www-128.ibm.com/developerworks/l ... signptrns/
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Programming pattern thread
Can I guess?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
1. MVC
2. Factory
3. Singleton
4. Registry
5. Decorator
I'm only guessing though.... I don't remeber the thread
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Programming pattern thread
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).d11wtq wrote: 1. MVC
2. Factory
3. Singleton
4. Registry
5. Decorator
(#10850)
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Programming pattern thread
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).
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>
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 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)
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I'm glad the list I put together elsewhere correlates fairly well with your judgementsweatje 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)
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
What do you mean? Are you insulting my abilities?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
Code: Select all
<!-- PASTE THIS CODE INTO YOUR WEBSITE... Bookmark http://www.<span style='color:blue' title='I'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>