Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   Design Patterns In PHP (http://www.programmingforums.org/showthread.php?t=8272)

Eryk Feb 5th, 2006 2:16 PM

Design Patterns In PHP
 
I'm trying to learn about design patterns right now, but I really don't know where to start. All of the tutorials that I have found seem like they either use PHP 5, or require the use of other design patterns, so I can't really seem to catch on. I purchased Design Patterns, a catalogue of several patterns, but the SmallTalk and C++ is very confusing to me.

I do use OOP, though I'm not sure if I know all that I need to. I know about object inheritance, polymorphism, and encapsulation. Is there anything else that I really need to learn before I can really understand these?

Could anyone recommend a starting place?

Thanks.

DaWei Feb 5th, 2006 3:46 PM

The thing about object oriented design is to not get snowed by all the academic pronouncements and high-priestly bool cheet. An object is a thing, like a table. Procedural stuff is like cleaning up your room. Some of the things you need for making solutions are best built as objects, others are better when done procedurally. Just think about your problem and use your common sense. Then fill in the details with your studies and investigations.

Eryk Feb 5th, 2006 3:54 PM

Quote:

Originally Posted by DaWei
The thing about object oriented design is to not get snowed by all the academic pronouncements and high-priestly bool cheet. An object is a thing, like a table. Procedural stuff is like cleaning up your room. Some of the things you need for making solutions are best built as objects, others are better when done procedurally. Just think about your problem and use your common sense. Then fill in the details with your studies and investigations.

Thanks for the response, I appreciate it.


I'm going to hijack my own thread by adding on, but the topics are somewhat similar :P. I'm working on my website, and the way I would like to set it up is to have the base, and then have extensions to add on to it. The problem I'm running into is that I would really like the extensions to be as separate as they can be from the original source code. Though I run into problems when some extensions requie others. How would you recommend going about setting up a system which can adapt easily to this?

DaWei Feb 5th, 2006 4:29 PM

I'm not sure what you mean by 'extensions', but check out templates and the include statement.

Eryk Feb 5th, 2006 4:53 PM

By extensions I mean like new features to the code.

My basic code would have things like:
-A CMS
-A membership system
-An article system
-User groups
-Categories
-et cetera

Then the extensions would be things like:
-Image gallery
-User's own blog
-Calendar
-Download manager
-Poll(s)
-et cetera

So basically I need a way to implement new features into the website application, without really changing the basic code. The problem that I expect to run into is not really knowing when I'll need the new files. For example, some might be on every page, while others might be on their own pages, as unique sections of the site.

DaWei Feb 5th, 2006 5:08 PM

Again, check out templates and the include statement.

Eryk Feb 5th, 2006 5:12 PM

Quote:

Originally Posted by DaWei
Again, check out templates and the include statement.

I know how to work with the include/require statement. Though by templates do you mean something like Smarty?

Cerulean Feb 5th, 2006 6:10 PM

You just want to create a simple plugin system, with some basic dependancy management so that one plugin can require another. The plugins get access to bits of your main API and go from there to provide the extra functionality. For example, a simple text editor might provide plugins with reference/pointer to the main text box, so that the plugin can read/write text to it.
The import statement has been mentioned by DaWei - it lets you load and execute a PHP file dynamically if you know its file name. You could use that to load your plugins, for example.

BlazingWolf Feb 5th, 2006 10:16 PM

Quote:

Originally Posted by Eryk
I know how to work with the include/require statement. Though by templates do you mean something like Smarty?

Like Smarty. There's also a lot of other ones. I've used Smarty before I like.

Eryk Feb 5th, 2006 10:25 PM

Quote:

Originally Posted by BlazingWolf
Like Smarty. There's also a lot of other ones. I've used Smarty before I like.

I'm familiar with Smarty as well, but I really don't see what that has to do with extensions, or as Cerulean calls them, plugins. I do know how to use include/require as I already said. The problem really isn't getting the files, but how to make sure that everything has access to everything else, and knowing when to include a certain extension. For example, a poll might be displayed on every page, while a gallery would only be displayed when that page was accessed. How would set it up so that you would know what extensions to use and when? So really this isn't a matter of not knowing the programming, but more of not knowing the theory, or abstraction that I should put to it.


All times are GMT -5. The time now is 8:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC