Jump to content

[SOLVED] Classes question


jaymc

Recommended Posts

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!

 

Link to comment
https://forums.phpfreaks.com/topic/87928-solved-classes-question/
Share on other sites

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".

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.