bgzee wrote:A seperate file for each function? That sounds like complete insanity and a huge mess of includes. I could understand function libraries, but even those are like, so 2002.
I disagree, but let me explain my reasoning.
I'm working on a huge chunk of ~2000 era code, filled with procedural nightmares that would make OOP purists run away in horror.
As I refactor the code, where possible, I'm moving *true functions* into seperate files. I'm selectively defining true functions as a function with a clear and defined input, process, and output, in under 200 lines of code.
By doing so, I'm able to compartmentalize the code, which (much further down the road) can lead to them becoming testable classes, and (oh holy day) actual solid OOP objects and methods.
The path from spaghetti to purity does have some nasty bumps along the way, and having standalone functions in seperate files isn't a net bad thing. I consider it a distinct improvement over raw mixed procedural code by a long shot. (At least with a defined input/process/output, I can hack up tests for that function, and later replace it with a full test-driven designed OOP member).
Not to mention, I've heard comments in multiple areas (notably including PanamaJack) that classes can add substantial overhead compared to raw includes and function calls. He has accomplished substantial gains in his "lite" implementations of adodb and Smarty, so he'd be a good one to ask if he finds that to be the case.
Regardless, as an interim step towards OOP, I don't find standalone function files to be a step back, or a bad thing.