![]() |
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. |
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.
|
Quote:
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? |
I'm not sure what you mean by 'extensions', but check out templates and the include statement.
|
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. |
Again, check out templates and the include statement.
|
Quote:
|
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. |
Quote:
|
Quote:
|
| 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