Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 4th, 2006, 10:34 AM
neobuddah's Avatar
neobuddah neobuddah is offline
cosmos curator
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2002
Location: Leeds, UK
Posts: 678 neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 14 h 17 m 49 sec
Reputation Power: 8
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:
function serialise()
 {
    
$output = new Renderer($renderMethod);
 } 
If so, is there a name for that in OOP terms?

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...

Reply With Quote
  #2  
Old January 16th, 2006, 10:01 AM
neobuddah's Avatar
neobuddah neobuddah is offline
cosmos curator
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2002
Location: Leeds, UK
Posts: 678 neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 14 h 17 m 49 sec
Reputation Power: 8
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?

Reply With Quote
  #3  
Old January 16th, 2006, 06:51 PM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,225 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 48 m 15 sec
Reputation Power: 174
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


Reply With Quote
  #4  
Old January 20th, 2006, 12:16 PM
neobuddah's Avatar
neobuddah neobuddah is offline
cosmos curator
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2002
Location: Leeds, UK
Posts: 678 neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 14 h 17 m 49 sec
Reputation Power: 8
Quote:
Originally Posted by drgroove
You're describing a pattern ... called a Strategy pattern

Thanks. I'll have a look. I knew there was something, just couldn't think of the pattern name.
Quote:
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.

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.

Reply With Quote
  #5  
Old January 20th, 2006, 05:19 PM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,225 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 48 m 15 sec
Reputation Power: 174
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.

Reply With Quote
  #6  
Old January 23rd, 2006, 08:20 AM
neobuddah's Avatar
neobuddah neobuddah is offline
cosmos curator
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2002
Location: Leeds, UK
Posts: 678 neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 14 h 17 m 49 sec
Reputation Power: 8
Quote:
Originally Posted by drgroove
I don't believe you'll have the full picture of patterns until you've read and throught through the "Gang of Four" book.


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!

Reply With Quote
  #7  
Old January 23rd, 2006, 08:25 PM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,225 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 48 m 15 sec
Reputation Power: 174
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.

Reply With Quote
  #8  
Old January 25th, 2006, 04:08 PM
Conundrum's Avatar
Conundrum Conundrum is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2004
Posts: 1,116 Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 16 h 59 m 53 sec
Reputation Power: 130
Quote:
Originally Posted by neobuddah
I've spent some time looking at the PHP frameworks. Frankly I'm dissappointed - they all seem to be very bloated.
Have you looked at cgiapp.class.php. It's in production and might be along what you're looking for in a less comprehensive PHP framework.

Reply With Quote
  #9  
Old January 26th, 2006, 05:05 AM
neobuddah's Avatar
neobuddah neobuddah is offline
cosmos curator
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2002
Location: Leeds, UK
Posts: 678 neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level)neobuddah User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 14 h 17 m 49 sec
Reputation Power: 8
Quote:
Originally Posted by Conundrum
Have you looked at cgiapp.class.php. It's in production and might be along what you're looking for in a less comprehensive PHP framework.

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.

Reply With Quote
  #10  
Old January 26th, 2006, 03:01 PM
Conundrum's Avatar
Conundrum Conundrum is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2004
Posts: 1,116 Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level)Conundrum User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 16 h 59 m 53 sec
Reputation Power: 130
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Design Pattern Advice?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |