jaymc Posted January 26, 2008 Share Posted January 26, 2008 Ok, I am switching to making most of my things with functions nested inside classes Here is my question, which has now turned into a little debate The standard way is to build your class with functions, then if you need to use a function inside the class, include the class file Well, lets say the class file is 3000 lines (accumulation of 30 functions) Well, what if you only need to use 2 of the functions in there, your including 3000 lines of code when you only need 200 lines of it.. I think this would be bad in terms if Disk access time.. so I think it may be better to put each function in a file.. that way if you only need to use 1 fiunction you includfe the little function file, not the entire class What is the best way to do this, I am focusing on optimal, not easy for a programmer.. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/87928-solved-classes-question/ Share on other sites More sharing options...
sKunKbad Posted January 26, 2008 Share Posted January 26, 2008 You are correct about wasting processing time if you only need one method inside your class. Quote Link to comment https://forums.phpfreaks.com/topic/87928-solved-classes-question/#findComment-449865 Share on other sites More sharing options...
toplay Posted January 26, 2008 Share Posted January 26, 2008 You may want to review your class. Instead of one big class, sometimes you may need to split it up into smaller classes. Having one file for related classes is the way I would go. So, one file may contain one or more classes (but related by functionality). Its really unheard of to create one file for each function. IMO, what you're worry about is not really an issue, and maintainability of code has to be factored into your evaluation. FYI - The "functions" inside classes are better known as "methods". Quote Link to comment https://forums.phpfreaks.com/topic/87928-solved-classes-question/#findComment-449866 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.