Code and Good Design Methods

This is a discussion on Code and Good Design Methods within the PHP General forums, part of the PHP Programming Forums category; I am reading PHP and MySQL web development 2nd edition book. Chapter 6 talks about displaying dynamic web content using ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-13-2003
Dan J. Rychlik
 
Posts: n/a
Default Code and Good Design Methods

I am reading PHP and MySQL web development 2nd edition book. Chapter 6 talks about displaying dynamic web content using class objects. For the type of project that I am building, this is not optimal. How do I keep my self from having html mixed with my PHP code? In other words how do I serperate the two. I need to concentrate on writing good code and not designing a nice looking website. (someone else is going to do that)

Can I assign include() statements to a variable ? How would you guys accomplish this?

Thanks so much in advance,
Daniel
Reply With Quote
  #2 (permalink)  
Old 07-13-2003
Zbranigan
 
Posts: n/a
Default Re: Code and Good Design Methods

>>>>> "Dan" == Dan J Rychlik <drychlik@tcsconsult.com> writes:

Dan> I am reading PHP and MySQL web development 2nd edition book.
Dan> Chapter 6 talks about displaying dynamic web content using
Dan> class objects. For the type of project that I am building,
Dan> this is not optimal. How do I keep my self from having html
Dan> mixed with my PHP code?

Ok, here's another one. I've never used the php port of TAL, but I've
used TAL a little bit in Zope and it's really nice.

Here's a link to an article on the zope site about TAL. One really
good thing about TAL (below) is that HTML editing tools tools like
Dreamweaver, Amaya or and GoLive, for instance, can be used to edit
the templates. So the Interface Engineers can do their 'thang' and the
programmers can do their 'thang' with less interference.


,----[ http://www.zope.org/Documentation/Articles/ZPT1 ]
| The tal:content attribute is a TAL statement. Since it has an XML
| namespace (the tal: part) most editing tools will not complain that
| they don't understand it, and will not remove it. It will not change
| the structure or appearance of the template when loaded into a
| WYSIWYG editor or a web browser. The name content indicates that it
| will set the content of the title tag, and the value "here/title" is
| an expression providing the text to insert into the tag.
`----

here's a link to the PHP port.
http://phptal.sourceforge.net/



--
no toll on the internet; there are paths of many kinds;
whoever passes this portal will travel freely in the world
Reply With Quote
  #3 (permalink)  
Old 07-13-2003
Dan J. Rychlik
 
Posts: n/a
Default Re: [PHP] Re: Code and Good Design Methods

hmm.. ill have a look. Thanks again.

----- Original Message -----
From: "zbranigan" <zbranigan@volcanomail.com>
To: <php-general@lists.php.net>
Sent: Saturday, July 12, 2003 9:15 PM
Subject: [php] Re: Code and Good Design Methods


> >>>>> "Dan" == Dan J Rychlik <drychlik@tcsconsult.com> writes:

>
> Dan> I am reading PHP and MySQL web development 2nd edition book.
> Dan> Chapter 6 talks about displaying dynamic web content using
> Dan> class objects. For the type of project that I am building,
> Dan> this is not optimal. How do I keep my self from having html
> Dan> mixed with my PHP code?
>
> try having a look at the Smarty templating engine.
>
>
> --
> no toll on the internet; there are paths of many kinds;
> whoever passes this portal will travel freely in the world
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Reply With Quote
  #4 (permalink)  
Old 07-13-2003
Ray Hunter
 
Posts: n/a
Default Re: [PHP] Code and Good Design Methods

Also u could build your own system that is php xml and xslt based. That
will really help you separate the logic from the presentation.

Check out (dom)xml and (dom)xslt. Sometimes there is still logic in the
presentation with template systems....with xslt however, it might be to
much for the design (interface) guys.

Those should help u out.

--
BigDog


On Sat, 2003-07-12 at 20:08, Dan J. Rychlik wrote:
> I am reading PHP and MySQL web development 2nd edition book. Chapter 6 talks about displaying dynamic web content using class objects. For the type of project that I am building, this is not optimal. How do I keep my self from having html mixed with my PHP code? In other words how do I serperate the two. I need to concentrate on writing good code and not designing a nice looking website. (someone else is going to do that)
>
> Can I assign include() statements to a variable ? How would you guys accomplish this?
>
> Thanks so much in advance,
> Daniel


Reply With Quote
  #5 (permalink)  
Old 07-15-2003
Joel Rees
 
Posts: n/a
Default Re: [PHP] Code and Good Design Methods

> Let's be honest, XSL is is one big logic step itself -- moreover it's a
> whole other language to learn.


<ramble>
I wouldn't call it a _big_ step. It only looks big when you look down.
8-)

I would tend rather to encourage the use of XSL, myself. If you can
pick up php okay, you ought to have few problems with XSL. (My biggest
problem with XSL is remembering to let the application language handle
the hard logic. Don't try to calculate the company budget in XSL, except
as a logic game to amuse yourself while riding the train home.)

You have your data in the database, and a filter (ergo, PHP code) to
extract the data, dress it up a bit and add XML tags. Then you have an
XSL filter to munge the XML into HTML. And the nice thing about XSL is
that the web page layout is all determined by the XSL.

Of course, it does work out to be a bit messier than it sounds, but the
benefits are definite.

To the OP -- don't focus on the code, don't focus on the coding style
either, focus on the problem. The object is not to avoid mixing PHP and
HTML, and the object is not to use (or not use) objects. Rather, it is
to separate processes that are more related to the business side of
things from processes that are more related to the presentation side.

My comments on XSL aside, you can program both business and presentation
in PHP. HTML will mostly be in the presentation side, but not
necessarily always. For instance, on the business side, you may
sometimes want to provide a table of the projected monthly profits for
the next year as a complete table wrapped in tags, rather than providing
the raw numbers to the presentation side.

If the design is in someone else's hands, you'll want a template engine.
The basic concept is that the designer designs the template, putting
template tags in where the data should go. The presentation code picks
up the data and the template, replaces the tags with the data, and spits
the result out at the viewer's browser.

Some template engines are better at actually conforming to that model
than others (particualarly in relation to your app), and XSL can
definitely be used in ways that don't conform to that model. That's no
big deal, just part of what makes life interesting.

(And if you get into Javaland, you'll hear a lot about MVC and
frameworks. That's a slightly more refined, uhm, model.)
</ramble>

--
Joel Rees, programmer, Kansai Systems Group
Altech Corporation (Alpsgiken), Osaka, Japan
http://www.alpsgiken.co.jp

Reply With Quote
  #6 (permalink)  
Old 07-15-2003
Hardik Doshi
 
Posts: n/a
Default Re: [PHP] Code and Good Design Methods

Hi Joel,

Thanks for nice comments on the XML, XSL.

I want to know more about it. can you please send me
some article, links and tutorials?

Thanks

Hardik

--- Joel Rees <joel@alpsgiken.gr.jp> wrote:
> > Let's be honest, XSL is is one big logic step

> itself -- moreover it's a
> > whole other language to learn.

>
> <ramble>
> I wouldn't call it a _big_ step. It only looks big
> when you look down.
> 8-)
>
> I would tend rather to encourage the use of XSL,
> myself. If you can
> pick up php okay, you ought to have few problems
> with XSL. (My biggest
> problem with XSL is remembering to let the
> application language handle
> the hard logic. Don't try to calculate the company
> budget in XSL, except
> as a logic game to amuse yourself while riding the
> train home.)
>
> You have your data in the database, and a filter
> (ergo, PHP code) to
> extract the data, dress it up a bit and add XML
> tags. Then you have an
> XSL filter to munge the XML into HTML. And the nice
> thing about XSL is
> that the web page layout is all determined by the
> XSL.
>
> Of course, it does work out to be a bit messier than
> it sounds, but the
> benefits are definite.
>
> To the OP -- don't focus on the code, don't focus on
> the coding style
> either, focus on the problem. The object is not to
> avoid mixing PHP and
> HTML, and the object is not to use (or not use)
> objects. Rather, it is
> to separate processes that are more related to the
> business side of
> things from processes that are more related to the
> presentation side.
>
> My comments on XSL aside, you can program both
> business and presentation
> in PHP. HTML will mostly be in the presentation
> side, but not
> necessarily always. For instance, on the business
> side, you may
> sometimes want to provide a table of the projected
> monthly profits for
> the next year as a complete table wrapped in tags,
> rather than providing
> the raw numbers to the presentation side.
>
> If the design is in someone else's hands, you'll
> want a template engine.
> The basic concept is that the designer designs the
> template, putting
> template tags in where the data should go. The
> presentation code picks
> up the data and the template, replaces the tags with
> the data, and spits
> the result out at the viewer's browser.
>
> Some template engines are better at actually
> conforming to that model
> than others (particualarly in relation to your app),
> and XSL can
> definitely be used in ways that don't conform to
> that model. That's no
> big deal, just part of what makes life interesting.
>
> (And if you get into Javaland, you'll hear a lot
> about MVC and
> frameworks. That's a slightly more refined, uhm,
> model.)
> </ramble>
>
> --
> Joel Rees, programmer, Kansai Systems Group
> Altech Corporation (Alpsgiken), Osaka, Japan
> http://www.alpsgiken.co.jp
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
Reply With Quote
  #7 (permalink)  
Old 07-17-2003
Ray Hunter
 
Posts: n/a
Default Re: [PHP] Code and Good Design Methods

Actually, MVC works really well with XML technologies, however, there
needs alot of work in php's core to fully utilize the benefits of an mvc
paradigm.

--
BigDog


On Wed, 2003-07-16 at 04:12, Joel Rees wrote:
> > Hi Joel,
> >
> > Thanks for nice comments on the XML, XSL.
> >
> > I want to know more about it. can you please send me
> > some article, links and tutorials?
> >
> > Thanks
> >
> > Hardik

>
> The ultimate source for xml related technologies is the World
> Wide Web Consortium at
>
> http://www.w3.org
>
> Most of the pages there are legalese, and really deep swimming. I think
> they do have some introductory materials, however.
>
> Model/View/Controller materials are most likely to be found in relation
> to SmallTalk, Objective C, and Java, since the concepts were originally
> worked out in those arenas. MVC and XML don't mix well, but the MVC
> concept is good to keep in mind if you want to use XML well.
>
> Other than that, there is plenty of material on the web. I know weeding
> out the bad stuff is not easy, but many of the pages that got me started
> have moved, I know not where.
>
> --
> Joel Rees, programmer, Kansai Systems Group
> Altech Corporation (Alpsgiken), Osaka, Japan
> http://www.alpsgiken.co.jp
>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:36 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0