Re: Many Small Files or Larger Utility Files
| From: | Larry Garfield | Date: | Tue, 21 Jun 2016 18:26:14 +0000 |
| Subject: | Re: Many Small Files or Larger Utility Files | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325632@lists.php.net to get a copy of this message | ||
On 06/21/2016 11:52 AM, Christoph Becker wrote:
On 21.06.2016 at 15:57, Larry Garfield wrote:As have I, and I run screaming from it, too. :-)If you're using a mostly procedural code base, then clustering functions into manageable chunks makes sense. One function per file is ridiculous and unmanageable.That depends on the length of the function. I've seen functions consisting of several hundred lines, and heard about even longer functions. I don't recommend this coding style, though.
True, but in what situation would you not have an opcode cache available that is not one of: 1) Your PHP version is so out of date you may as well give up, because it's already insecure. 2) Your webhost is so terrible that the best thing you can do for your app is to get a new webhost. An opcode cache should just be assumed on any modern PHP installation; if it's not there, there are other, much larger problems to resolve first. --Larry GarfieldGenerally speaking, "class per file and don't sweat it" is the conventional approach, and what I'd recommend in most cases.Well said. :) However, if there is no bytecode cache available on the production system for whatever reason, it's still possible to merge all (or some reasonable subsets of) classes into a single file (a few files) during build time.