Does a large class trigger on the page?

I am in the process of writing a class that is likely to turn out to be around 3,000 lines of code.

What I would like to know is very simple, initiates this class at the top of each page, slows down the page execution time, although only one / two methods of objects will be used? Will I have more load on my server if it is accessed several thousand times a day?

If so, should I look for creating extensions to handle each method, and not for the entire class in a single file?

EDITED

Firstly, to fix KingCrunch and Kenaniah, this class is intended for my API, which, in the end, means that it contains many functions for extracting data that will be displayed on the website and in our iPhone application, as well as in our Facebook application. So 3000 lines are pretty damn small, considering the size and capabilities of our site, not to mention that more than 700 of these lines are comments. Therefore, I can assure you that there is no design flaw, although there may be a structural flaw, so I ask this question ...

The construct function simply sets default values ​​for certain variables, no more.

I completely rewrote this file from scratch, so there is no old code, and I'm sure the methods in the class are as efficient as they can be.

I track my server usage, etc., and also simulate large amounts of traffic using the apache ab tool, and although my memory usage is increasing, everything seems to be in order.

+8
php class lines-of-code
source share
3 answers

initiates this class at the top of each page, slows down page execution time

Will this be added at runtime? Yes. Of course. Nothing is free. Each line of code is parsed with little overhead (however, you can get rid of most of this cost with a transaction operations cache such as APC). However, we are talking about sub-millisecond overhead, perhaps. The only way to make sure that he is the profile itself.

Will there be much more load on my server if it is accessed several thousand times a day?

From personal experience, no. But then again, profile and measure yourself. You should keep track of key performance indicators on your server (CPU usage, average load, etc.). Expand your change and see your metrics.

+4
source share

No, instantiating a class consisting of a large number of LOCs does not automatically slow down.

That is, if you are not doing anything in the constructor, but then it depends on what you are doing there, and not on how big the class is.

+1
source share

no, actually it is faster than splitting it into several files.

the only problem is that often there is a large block of code and modifications are more difficult to do.

EDIT: It will be faster if all lines are useful. if you have a lot of old code you might consider cleaning up

+1
source share

All Articles