<[EMAIL PROTECTED]> Chris W. Parker: > 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.
_____hi, i have heard a lot of people commenting about the coding style of other programmers. i think everyone has his own style. but i also say that there should be a standard that should be followed by everyone. i know that there are many good tutorials that explain how to code. anyway i have my own style. i like keeping all the functions in one file and the include the file whenever i need any function. now there are few problems in that. i prefer writing functions for almost everything sometimes the functions file grows to over 5,000 lines. now this is not good. when ever i need one simple function i had to include all the file. now i also don't like keeping functions in every file that uses it. this is becoming a big problem for me. also i have seen some programmer that prefer to use only one file as front end and place switch or if conditions and include other files depending on the condition. i think its good way of doing things but when the magnitude of the projects grows i find it very difficult for me to keep working. i find it very hard to concentrate. 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. thanx in advance. Haseeb _______________________________________________ > > 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; > } Or just 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