rohitcoder
rohitcoder

Reputation: 400

Is there Any CONS of making a big common function file in php / or other languages

I just wanted to ask is there any problem or cons if I keep adding new functions to a single file and if I import this function file everwhere. Currently, I am having 280 Functions in functions.php and 5335 Line of codes in functions.php

I am expecting to add more around 500+ functions in the future. Is there any cons in terms of Best practices / Optimization?

My main focus is on optimization.

Upvotes: 0

Views: 56

Answers (1)

CDS
CDS

Reputation: 216

Along with what Nigel Ren already commented above, as much as possible, we want our code to be re-usable. If someone is going to use your code, or if you're going back to your code after weeks of not touching it, having a logical file structure where each file clearly communicates its purpose helps a lot. Look at external libraries for example, if they put functions that aren't related in any way into one file, it would be much harder for us developers to use them. Therefore, having a logical structure helps when you're using someone else's code.

Upvotes: 1

Related Questions