|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Design Pattern Advice?
Hi all
I'm working on a PHP5 framework for use on a couple of personal projects. After reading Patterns of Enterprise Application Architecture I thing I've got a decent beginner's handle on things. However, there's one thing troubling me... I'm storing all my output in a Data Transfer Object so I can serialise it into XML, HTML, and text. I have a class for each render method, and a parent "Renderer" class (from which the other objects inherrit common methods). When I call my DTO's serialise() method, I want to initialise the "Renderer" object and get back, for example, the XMLRenderer based on a setting elsewhere in the app. Is there a specific pattern I should be looking for, or is it as simple as: PHP Code:
Cheers!
__________________
R.T.F.M - Its the only way to fly... "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds." Personal: experience// 8 Years Web Development technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs packages// Photoshop, Illustrator, Flash/Fireworks/Director environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi site// //refactored.net/ (Coming soon...) quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning... |
|
#2
|
||||
|
||||
|
No help with this? I've looked at the remote facade pattern, but because its a distributed method its not suitable. Is there something similar?
|
|
#3
|
||||
|
||||
|
You're describing a pattern catalogued in the Design Patterns book called a Strategy pattern, where you vary an algorithm, which is represented by a class, at runtime. In this sense you're varying the View that you're outputting (are you familiar w/ the MVC concept? ) based on a configuration parameter, outputting XML, HTML or text. You could also include PDF or Excel format, based on this paradigm, as long as a class was available to do the transformation.
FWIW, although great experience is to be gained by writing your own MVC framework, I would highly recommend instead contributing to a mature framework. I've been spending more time in the Java/J2EE world of late, but I'm fairly certain there are analogues to Java's Struts, Shale, Spring, etc MVC frameworks in the PHP world - in fact, I know I've seen a Struts port in PHP on Sourceforge. It would be better to spend your efforts helping to mature a PHP MVC framework that already has a userbase, rather than creating one yourself... unless, of course, the idea(s) you have are too off course for any of the existing MVC projects to accommodate.
__________________
Give a person code, and they'll hack for a day; Teach them how to code, and they'll hack forever. Analyze twice; hack once. The world's first existential ITIL question: If a change is released into production without a ticket to track it, was it actually released? About DrGroove: ITIL-Certified IT Process Engineer - Enterprise Application Architect - Freelance IT Journalist - Devshed Moderator - Funk Bassist Extraordinaire |
|
#4
|
||||
|
||||
|
Quote:
Thanks. I'll have a look. I knew there was something, just couldn't think of the pattern name. Quote:
Actually, I've been using a reasonably mature framework for a while, and I've spent some time looking at the PHP frameworks. Frankly I'm dissappointed - they all seem to be very bloated. While the ports of java MVCs are great for Java Developers looking to use PHP, they're not all that good for a PHP developer looking to Get Things Done. I'm building a light-weight framework with (hopefully) minimal configuration. It'll suit my needs, and hopefully it might help others too. ![]() |
|
#5
|
||||
|
||||
|
If you think your approach adds significant value over whats available, then by all means, forge ahead.
I would strongly recommend reading the seminal Design Patterns book before getting too deep into your project, however. Martin Fowler's book is meant to augment the already catalogued patterns, not supplant them; I don't believe you'll have the full picture of patterns until you've read and throught through the "Gang of Four" book. |
|
#6
|
||||
|
||||
|
Quote:
Wonderful, thanks. Its advice like that you don't find online unless you actually "chat" with someone. Most of the blogs are aimed at people who are new to programming or have been doing it for a long time - there's no middle-ground. I'll purchase today! |
|
#7
|
||||
|
||||
|
Well, fwiw, I've been developing and architecting for about 10 years, and work @ a top 5 IT company as a consultant; this company's clients are Fortune 2000 companies. I bring slightly more to the table than your average developer. But, only slightly.
![]() |
|
#8
|
||||
|
||||
|
Quote:
|
|
#9
|
||||
|
||||
|
Quote:
It looks like another port of a framework designed for another language (Perl, in this case). I'm not a fan of ports - they're not designed for the language they're using, and IMO can't be using the benefits of said language. Plus it uses Smarty. I'd rather have my teeth pulled than use that. ![]() |
|
#10
|
||||
|
||||
|
Since there are no PHP frameworks that fit your requirements, have you thought about open sourcing your framework? Perhaps there are similar-minded people out there
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > Design Pattern Advice? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|