![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jul 2005
Posts: 62
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 | |
|
Programmer
Join Date: Jul 2005
Posts: 62
Rep Power: 4
![]() |
Quote:
I'm going to hijack my own thread by adding on, but the topics are somewhat similar . 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? |
|
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I'm not sure what you mean by 'extensions', but check out templates and the include statement.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jul 2005
Posts: 62
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Again, check out templates and the include statement.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 | |
|
Programmer
Join Date: Jul 2005
Posts: 62
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#8 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#9 | |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
Quote:
__________________
_______________________________ BlazingWolf |
|
|
|
|
|
|
#10 | |
|
Programmer
Join Date: Jul 2005
Posts: 62
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|