/    Sign up×
Community /Pin to ProfileBookmark

How to structure include files

Hi

I have recently finished my, so far, largest PHP-script. In total there are about 5000 lines of code, and it does nothing visual actually. I have divided the script into several include-files, each of these containing functions with similar functionality (like createCustomer, updateCustomer, deleteCustomer in one file. createToDo, updateToDo, deleteToDo in another etc). I have one main file which call all these functions.
Is it any point in doing it like this? Should I just have one include-file with all functions, like myproject_functions.inc.php? I’m thinking first of all about readability for later developers/maintainers.
When I started I was thinking that I could use one or more of the include-files in other scripts, but so far I can’t see it happening with these specific files/functions…

Thanks for any advice.
Lubox

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@shimonJun 16.2005 — Yes, there is a real value in splitting up your files like that - 5,000 lines is [b]huge[/b] for a single script. Just imagine some poor maintenance programmer having to try to understand what your 5000 lines of code do! I wouldn't want to be that poor guy/girl ?

By splitting your functions into smaller libraries of related functions, you're taking a big step towards legibility and maintainability. I would even recommend that you take things further, and get into object-oriented programming, as this will help you structure your code in even more beautiful ways ?
×

Success!

Help @Lubox spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...