|
Posted by Rik on 08/15/06 22:18
Chung Leong wrote:
> Rik wrote:
>> Pardon, 'reuse'? How many heads/closing html tags do you want in a
>> page? I normally opt for just one, but hey, that's silly me.
>
> Code reuse typically means using the same code in more than one place,
> as opposed to it being used multiple time in a single operation.
Well, the template file can also be reused as easily :-). But this is just a
sidetrack, I understand you want the same function to apply to different
pages, even projects, and keep them alike. If one only plans on doing one
project (someone only doing his own homepage, something like that), you CAN
make your code as reusable as hell, but it probably isn't worth the hassle.
>> Well, that's indeed a pro to the include.
>> However, a con is this: If I want to change something in the head
>> once the project is running, I usually don't want to fiddle around
>> in files anymore, I want to be able to change it in an interface.
>> While a *.php page can just be opened and displayed in an textarea,
>> I'm definitely more at ease working on the plain HTML bits.
>
> I would hardly call that a con. You can easily accommodate such a
> requirement by changing the function. Since it's easier to edit the
> template as a whole as opposed to it being splitted (since start tags
> have to be reconciled with the end tag), you can load the whole frame
> into the editor then use a keyword to determine where the split should
> occur.
Let's say I have an included file with all my functions. One blurts out a
header, another one a footer, and another a tablecell, an anchor, you name
it. I'd have a hell of a time to make an interface where people couldn't
change the functions, but can change the HTML, and only the HTML.
Keeping it in different files, or even in a database, will make live a lit
simpler for me and for the code of the UI.
>> Then again, my bigger projects all have a dynamically built head
>> section, little to no actual static HTML content there.
>
> One shouldn't confuse implementation with purpose. The purpose is the
> same whether it's a block of static HTML or some super dynamic
> code--to output a page header. When you have code that's properly
> encapsulated,
> the caller wouldn't need to know how the process is implemented.
That was not the pont I was trying to make. What I actually ment to say was:
due to the fact I dynamically create all the content of the <head> section
(<link>'s, <meta>'s ), and want complete control over them by an interface,
I've never used the option to include() a static head. The option to include
a file with only a single '<html>' doesn't seem very worthwhile.
So to sum it up: you have a point from a developers standpoint. For someone
doing one page in his spare time it could well be overkill.
I'm not aware of any performance issue between the 2 different approaches,
but if there are, let me know.
Grtz,
--
Rik Wasmus
[Back to original message]
|