Re: Including Functions; one file or many?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Kelly wrote:
At 9:02 AM +0100 5/26/06, Mark Kelly wrote:

TIA in advance for any advice,


And thanks in arrears to all who responded.

Since there appears to be no compelling reason to go either way, and we already have subdivided include files for functions (to a limited extent) I've decided to go with a different file for each kind of data; ie. db_employees.inc, db_contacts.inc, db_products.inc etc. so I can load the ones that are relevant to the current page, not all 2 squillion funcs.

seems like a sane comprimise between performance and maintainability -
pretty much what I would go for too.

I would suggest, as someone else has, considering refactoring your functions
into classes (even though you may only be using the classes as namespaces - i.e.
calling methods statically) because it means you lesseen the possiblity of
function name conflicts ... it's always recommended practice to avoid polluting
the global namespace whenever/where-ever possible.

using objects (or even just classes if your using php5) means you can avoid
have global declarations at the top of each function for things like db connnections -
instead you can store such resources/stuff as properties of the object/class - again avoiding
coing a few extra lines AND at the same time polluting the global namespace a
little less.


This was TBH my preference anyway, I just wanted to make sure that more experienced heads than mine didn't know of any compelling reasons for another method.

Thanks again for all the replies.

Mark


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux