Re: Including Functions; one file or many?
| From: | Jochem Maas | Date: | Fri, 26 May 2006 15:46:22 +0000 |
| Subject: | Re: Including Functions; one file or many? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-236965@lists.php.net to get a copy of this message | ||
Mark Kelly wrote:
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.At 9:02 AM +0100 5/26/06, Mark Kelly wrote: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.TIA in advance for any advice,
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