Programming pattern thread

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Programming pattern thread

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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/
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Programming pattern thread

Post 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
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Programming pattern thread

Post 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).
(#10850)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Programming pattern thread

Post 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>
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post 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)
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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:
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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>
Post Reply