cbrooks Posted November 3, 2009 Share Posted November 3, 2009 I said, Gurus, but I accept the fact that I may be the only person that does not know the answer to this question. I have a PHP application and have created several files such as: output_functions.php user_functions.php data_functions.php well, you get the picture. So, will the size of these files have any effect on the total application(say in speed or anthing else)? Should I limit the size of these files? If they get to a certain size, should I break them up into 2 or more smaller files. Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 3, 2009 Share Posted November 3, 2009 It's not the size that matters (and in this case it's true). It's what these scripts are supposed to do (and how). Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted November 3, 2009 Share Posted November 3, 2009 Plus, if you have 1 huge file that you need to load, splitting it into 2 smaller files isn't going to magically make you not have to load the entire script anyways. It just (potentially) increases readability, and makes the code easier to navigate. Not that splitting up huge files is bad, but it won't really increase the speed of the script more than smart coding would Quote Link to comment Share on other sites More sharing options...
abazoskib Posted November 3, 2009 Share Posted November 3, 2009 I once read a benchmark on inclusion, and it was clear that including one file was faster than many. In your case, I would include files as needed. For example, don't include everything at the top, use condition checks to determine if you need the includes. This will make your code faster. Now if you need all of them, then code optimization comes into play, database query optimization(if applicable), etc. Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 3, 2009 Share Posted November 3, 2009 I pretty much concur with the above. I would split out the functions into separate files based upon which ones are used together. For example, if you have a set of functions that are only used for pages that include a form, for validation and such, then I would only load those functions on pages which include forms. Not knowing what functions are in those files or how they are used it's difficult to say if that is optimal. But, I do like using smaller files with specific usage - it makes debugging and modifications much easier. For example, if you are needing to modify a function that is used to display a set of records, it is much safer if that file does not also include functions that insert/delete records. Otherwise you could accidentally instroduce a typo into other functions in that file and not know right away because you are only testing the display output. Anyway, that's my two cents. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted November 3, 2009 Share Posted November 3, 2009 including code/files conditionally, along with a tight cache system (if applicable - using API's, redundant db queries, etc., a decent cache system is a time saver and a half), and your pages will be flyin'! it is all about smart coding (i learn new techniques and figure out more efficient ways of coding almost on a daily basis). bottom line is: don't have code execute that doesn't need to be. that's the basis of site optimization IMO. Quote Link to comment Share on other sites More sharing options...
cbrooks Posted November 5, 2009 Author Share Posted November 5, 2009 I want to thank everyone that answered this query!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.