ComexEP <mailto:[EMAIL PROTECTED]>
    on Monday, July 21, 2003 1:48 PM said:

>> this is the problem, i have thought of the solution i.e. divide the
>> functions into files. and then include only that file that has the
>> function. but i thought i would ask you people how you handle this.
>> may be i would find something that suits me more then this solution.

Hey sorry I just joined this list and I don't think I have seen the
original post so I'm just responding to a response.

Haseeb,

Certain things have to do with programming style, other things are just
bad practice.

Here is an example of coding style:

V1:
function additself($number) {
        return $number += $number;
}

V2:
function additself($number)
{
        return $number += $number;
}

Personally I prefer V4.

Now let's talk about bad practice.

It's bad practice to do what you used to do. That is, to have one huge
file that contains ALL your functions and objects/classes that will ever
be used in your program. To find out just *how* bad it is you can test
the time it takes to include that file using microtime().

Then, after you've split up the file, do the same test and see how much
quicker it is to include three small files than it is to include one
huge file.

You should split up your files by purpose and not by which page they are
included in.

For example, let's say your building an ecommerce store from the ground
up. You'll likely have some functions that perform certain tasks. i.e.
accessing the database, managing your cart, managing users.

Don't be tempted to create different include files for all the different
pages in your cart. Just group them by function/purpose and include only
the files necessary.

Sure it may cause a litle more overhead than if you created include
files specific to each page, but in the long run it will be much less
overhead than if you included everything in every page.

Hope this helps,


Chris.

p.s. I'd appreciate any comments on what I've said that can help improve
my method.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to