RE: [PHP] Cleaning up my messy code
| From: | Robert Cummings | Date: | Tue, 30 Sep 2003 01:08:40 +0000 |
| Subject: | RE: [PHP] Cleaning up my messy code | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164328@lists.php.net to get a copy of this message | ||
On Mon, 2003-09-29 at 20:27, Chris L wrote:
> robert@interjinn.com (Robert Cummings) wrote in
> news:1064878415.9370.6.camel@blobule.suds:
>
>
> > *heh* I like being able to look at project 2 and say to myself, hmm
> > needs an authentication just like project 1, but with a different
> > look. Or wants a news feed, like project 1, buyt the data source is
> > different, I'll just re-use the renderer and logic and recode the data
> > retriever. I guess it depends on preference. I find I can do fully
> > customized management projects from scratch with serious backend and
> > front end functionality in very short time (weeks). And when I can
> > re-use a component or module, I just shave off more time. The nice
> > thing about re-using components and modules too, is that I know it
> > works, the testing has been done, let alone the coding.
> >
> > Cheers,
> > Rob.
>
> I like that idea too-- I just don't like having to learn what amounts to a
> third language to do it. Does one have to have a templating engine in order
> to achieve this?
>
> I find reusability to be, largely, a theoretical mantra, templates or not.
> In general, between applications, so much changes that even the same basic
> idea means that the most reusable part are SQL queries and such, and I
> already keep THOSE separate.
>
> And I've been looking for good examples of code on the web-- examples that
> exemplify forethought and reusability. I must be looking in the wrong
> places :)
Well an example I'm experiencing right now with my template system which
is making my life so much easier and saving me oodles of time -- is
creating a PDF version of my site. To do this doing a few things:
1. creating a new site configuration (actually a copy of the
InterJinn site configuration with a few changes)
2. Creating a new set of template patterns for this configuration
(2 to be exact)
3. Creating one new layout template for the PDF version.
4. Creating one master source file which provides a chapter
mechanism for the InterJinn site's sections.
5. extending the original jinnDoc tag compiler to provide support
for a <jinnDoc:chapter/> and <jinnDoc:subChapter/> tag and to
reduce the <h?/> tag ranks for the current <jinnDoc:title/>,
<jinnDoc:subTitle/>, etc. tags.
6. Compiling the new site patterns.
7. running htmldoc on the output.
So in 7 fairly easy steps (once you know the framework) I've converted
my InterJinn site into an easily downloadable PDF for offline reading.
Total time invested: 3 hours. later I'll add support for
<jinnDoc:pdfOnly/> and <jinnDoc:webOnly/> tags to properly separate out
content that makes no sense in the website or vice versa.
The nice thing about this was I hadn't even planned on doing a PDF till
someone requested it via a comment on the website. I'll probably release
interJinn-0.9.2 next weekend, so you can see the code then if you want
since I include the InterJinn site as it's own example :) As is you can
see the non PDF stuff if you download the current version.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'