At 9:02 AM +0100 5/26/06, Mark Kelly wrote:
Hi
I'm writing a set of db abstraction functions for an internal app which will
give us a set of simple function calls for dealing with the db, like
$result = db_AddEmployee($EmployeeData);
$EmployeeData = db_GetEmployee($EmployeeID);
etc.
There will be quite a few functions needed to deal with all the different
ways the app touches the db, so my question is:
Am I better off putting all these functions into one big include file (which
could get pretty big) or using a seperate 'include' file for each function?
I'm thinking about the tradeoff between simplifying code by only having a
single include file (parsing a lot of functions that aren't used, but less
disk access) and having several include files (no extra funcs but lots more
disk access).
I realise there probably isn't a 'correct' way to do this, I'm curious about
which methods folk here use in situations like this.
TIA in advance for any advice,
Mark
Mark:
When I started started using includes (in another language, long long
ago), I placed all my functions into one large file. However, I soon
found that doing that lead to one big include, which because of it's
size had it's own problems.
So, thinking think heuristic, I started dividing things into logical
groups, like all dB operations into one include and all <whatever>
into other <whatever> includes. This isn't original by any means, but
is a good canonical approach. If you think about it, that's what
classes are in OOP.
So, my advice is to divide your functions into logical groups that
work for you.
As for disk IO times, I wouldn't be concerned, because whatever they
are today (which is minor), tomorrow they will be even less.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php