Split up Code in .inc files
dereine - May 29, 2009 - 15:55
| Project: | Module Builder |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
What about splitting up code into .inc files, for example .admin.inc and .pages.inc
This will save memory and its easier to work on the module, for example for #464504: Drush Command

#1
here is a patch for creating a admin.inc
#2
Good call.
Memory is perhaps not crucial on development sites, but would definitely make it easier to work with the code in smaller files.
But the whole of this module seems like admin to me, so perhaps use different filenames?
I don't have the code in front of me, but we could have:
- settings.inc -- the settings page
- update.inc or fetch.inc -- any functions that handle downloading hooks from API sites.
- pages.inc -- the pages and functions that make the module. We could split the form pages into one file and the actual logic into another, which is good for external use, and put the generating function into generate.inc. Though that is perhaps too many inc files now. I will have a look at the code and think about how best to slice it up.
#3
thx
i would be perfect to have a generate.inc, which could be just copied for a drush script. So drush can create modules without a running drupal
#4
Yup, we need to think about this in light of drush support.
This module has the following modes of operation:
1 download hook files
2 process hook files into data about them
3 collect user input in a form
4 generate module code from user input
Only 3 is irrelevant to drush.
See also #530768: running drush command without module installed for taking drush support further.
#5
I've split code into:
- common -- code for both drush and drupal ui
- update
- process
- generate
process is a bit of a misnomer as code to load data is there too. will probably split that into process and load, or load and move the rest with update.
#6
Is there a script script that will split a module and write the hooks in it to a separate file(s)? Alternately how does one separate the hooks manually?